mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Restructure to monorepo (#6907)
* wip: restructure to monorepo Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * refactor create-release-pr to a package Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * build fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * github workflow fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix typo Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * add webpack-env types to core Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix github workflows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * refactor/fix integration tests Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * lint fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * yarn run dev Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * eslint settings for vscode Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * move templates to right package Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * open-lens build fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * integration test fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix nx task dependencies Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * use bash shell for unit tests in test workflow Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix test:unit for windows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix win-ca webpack error in open-lens Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix win-ca webpack error in open-lens Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix build:app on windows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * remove ELECTRON_BUILDER_EXTRA_ARGS Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * sync src/ from master Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * remove Makefile from core Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
0066ca4ea2
commit
2657df2293
3321 files changed
+28699
-11447
No files matched your search
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getRequestChannel } from "../../../common/utils/channel/get-request-channel";
|
||||
|
||||
export const casChannel = getRequestChannel<void, string[]>("certificate-authorities");
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { globalAgent } from "https";
|
||||
import { requestSystemCAsInjectionToken } from "./request-system-cas-token";
|
||||
|
||||
// DST Root CA X3, which was expired on 9.30.2021
|
||||
const DSTRootCAX3 = "-----BEGIN CERTIFICATE-----\nMIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/\nMSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\nDkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow\nPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD\nEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\nAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O\nrz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq\nOLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b\nxiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw\n7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD\naeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV\nHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG\nSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69\nikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr\nAvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz\nR8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5\nJDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo\nOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ\n-----END CERTIFICATE-----\n";
|
||||
|
||||
function isCertActive(cert: string) {
|
||||
const isExpired = typeof cert !== "string" || cert.includes(DSTRootCAX3);
|
||||
|
||||
return !isExpired;
|
||||
}
|
||||
|
||||
const injectSystemCAsInjectable = getInjectable({
|
||||
id: "inject-system-cas",
|
||||
instantiate: (di) => {
|
||||
const requestSystemCAs = di.inject(requestSystemCAsInjectionToken);
|
||||
|
||||
return async () => {
|
||||
const certs = await requestSystemCAs();
|
||||
|
||||
if (certs.length === 0) {
|
||||
// Leave the global option alone
|
||||
return;
|
||||
}
|
||||
|
||||
const cas = (() => {
|
||||
if (Array.isArray(globalAgent.options.ca)) {
|
||||
return globalAgent.options.ca;
|
||||
}
|
||||
|
||||
if (globalAgent.options.ca) {
|
||||
return [globalAgent.options.ca];
|
||||
}
|
||||
|
||||
return [];
|
||||
})();
|
||||
|
||||
for (const cert of certs) {
|
||||
if (!isCertActive(cert)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!cas.includes(cert)) {
|
||||
cas.push(cert);
|
||||
}
|
||||
}
|
||||
|
||||
globalAgent.options.ca = cas;
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default injectSystemCAsInjectable;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
|
||||
export const requestSystemCAsInjectionToken = getInjectionToken<() => Promise<string[]>>({
|
||||
id: "request-system-cas-token",
|
||||
});
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getGlobalOverride } from "../../../common/test-utils/get-global-override";
|
||||
import { casChannel } from "../common/channel";
|
||||
import certificateAuthoritiesChannelListenerInjectable from "./channel-handler.injectable";
|
||||
|
||||
export default getGlobalOverride(certificateAuthoritiesChannelListenerInjectable, () => ({
|
||||
channel: casChannel,
|
||||
handler: () => [],
|
||||
}));
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getRequestChannelListenerInjectable } from "../../../main/utils/channel/channel-listeners/listener-tokens";
|
||||
import { casChannel } from "../common/channel";
|
||||
import { globalAgent } from "https";
|
||||
import { isString } from "../../../common/utils";
|
||||
|
||||
const certificateAuthoritiesChannelListenerInjectable = getRequestChannelListenerInjectable({
|
||||
channel: casChannel,
|
||||
handler: () => () => {
|
||||
if (Array.isArray(globalAgent.options.ca)) {
|
||||
return globalAgent.options.ca.filter(isString);
|
||||
}
|
||||
|
||||
if (typeof globalAgent.options.ca === "string") {
|
||||
return [globalAgent.options.ca];
|
||||
}
|
||||
|
||||
return [];
|
||||
},
|
||||
});
|
||||
|
||||
export default certificateAuthoritiesChannelListenerInjectable;
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import execFileInjectable from "../../../common/fs/exec-file.injectable";
|
||||
import loggerInjectable from "../../../common/logger.injectable";
|
||||
import type { AsyncResult } from "../../../common/utils/async-result";
|
||||
import { requestSystemCAsInjectionToken } from "../common/request-system-cas-token";
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet#other_assertions
|
||||
const certSplitPattern = /(?=-----BEGIN\sCERTIFICATE-----)/g;
|
||||
|
||||
const requestSystemCAsInjectable = getInjectable({
|
||||
id: "request-system-cas",
|
||||
instantiate: (di) => {
|
||||
const execFile = di.inject(execFileInjectable);
|
||||
const logger = di.inject(loggerInjectable);
|
||||
|
||||
const execSecurity = async (...args: string[]): Promise<AsyncResult<string[]>> => {
|
||||
const result = await execFile("/usr/bin/security", args);
|
||||
|
||||
if (!result.callWasSuccessful) {
|
||||
return {
|
||||
callWasSuccessful: false,
|
||||
error: result.error.stderr || result.error.message,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
callWasSuccessful: true,
|
||||
response: result.response.split(certSplitPattern),
|
||||
};
|
||||
};
|
||||
|
||||
return async () => {
|
||||
const [trustedResult, rootCAResult] = await Promise.all([
|
||||
execSecurity("find-certificate", "-a", "-p"),
|
||||
execSecurity("find-certificate", "-a", "-p", "/System/Library/Keychains/SystemRootCertificates.keychain"),
|
||||
]);
|
||||
|
||||
if (!trustedResult.callWasSuccessful) {
|
||||
logger.warn(`[INJECT-CAS]: Error retreiving trusted CAs: ${trustedResult.error}`);
|
||||
} else if (!rootCAResult.callWasSuccessful) {
|
||||
logger.warn(`[INJECT-CAS]: Error retreiving root CAs: ${rootCAResult.error}`);
|
||||
} else {
|
||||
return [...new Set([...trustedResult.response, ...rootCAResult.response])];
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
},
|
||||
causesSideEffects: true,
|
||||
injectionToken: requestSystemCAsInjectionToken,
|
||||
});
|
||||
|
||||
export default requestSystemCAsInjectable;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { requestSystemCAsInjectionToken } from "../common/request-system-cas-token";
|
||||
|
||||
const requestSystemCAsInjectable = getInjectable({
|
||||
id: "request-system-cas",
|
||||
instantiate: () => async () => [],
|
||||
injectionToken: requestSystemCAsInjectionToken,
|
||||
});
|
||||
|
||||
export default requestSystemCAsInjectable;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { requestSystemCAsInjectionToken } from "../common/request-system-cas-token";
|
||||
|
||||
const requestSystemCAsInjectable = getInjectable({
|
||||
id: "request-system-cas",
|
||||
instantiate: () => async () => [],
|
||||
injectionToken: requestSystemCAsInjectionToken,
|
||||
});
|
||||
|
||||
export default requestSystemCAsInjectable;
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import execFileInjectable from "../../../common/fs/exec-file.injectable";
|
||||
import loggerInjectable from "../../../common/logger.injectable";
|
||||
import { requestSystemCAsInjectionToken } from "../common/request-system-cas-token";
|
||||
|
||||
const pemEncoding = (hexEncodedCert: String) => {
|
||||
const certData = Buffer.from(hexEncodedCert, "hex").toString("base64");
|
||||
const lines = ["-----BEGIN CERTIFICATE-----"];
|
||||
|
||||
for (let i = 0; i < certData.length; i += 64) {
|
||||
lines.push(certData.substring(i, i + 64));
|
||||
}
|
||||
|
||||
lines.push("-----END CERTIFICATE-----", "");
|
||||
|
||||
return lines.join("\r\n");
|
||||
};
|
||||
|
||||
const requestSystemCAsInjectable = getInjectable({
|
||||
id: "request-system-cas",
|
||||
instantiate: (di) => {
|
||||
const wincaRootsExePath: string = __non_webpack_require__.resolve("win-ca/lib/roots.exe");
|
||||
const execFile = di.inject(execFileInjectable);
|
||||
const logger = di.inject(loggerInjectable);
|
||||
|
||||
return async () => {
|
||||
/**
|
||||
* This needs to be done manually because for some reason calling the api from "win-ca"
|
||||
* directly fails to load "child_process" correctly on renderer
|
||||
*/
|
||||
const result = await execFile(wincaRootsExePath, {
|
||||
maxBuffer: 128 * 1024 * 1024, // 128 MiB
|
||||
});
|
||||
|
||||
if (!result.callWasSuccessful) {
|
||||
logger.warn(`[INJECT-CAS]: Error retreiving CAs`, result.error);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
return result
|
||||
.response
|
||||
.split("\r\n")
|
||||
.filter(Boolean)
|
||||
.map(pemEncoding);
|
||||
};
|
||||
},
|
||||
causesSideEffects: true,
|
||||
injectionToken: requestSystemCAsInjectionToken,
|
||||
});
|
||||
|
||||
export default requestSystemCAsInjectable;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { requestFromChannelInjectionToken } from "../../../common/utils/channel/request-from-channel-injection-token";
|
||||
import { casChannel } from "../common/channel";
|
||||
import { requestSystemCAsInjectionToken } from "../common/request-system-cas-token";
|
||||
|
||||
const requestSystemCAsInjectable = getInjectable({
|
||||
id: "request-system-cas",
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
|
||||
return () => requestFromChannel(casChannel);
|
||||
},
|
||||
injectionToken: requestSystemCAsInjectionToken,
|
||||
});
|
||||
|
||||
export default requestSystemCAsInjectable;
|
||||
Reference in new issue
Block a user