@socketsecurity/cli-with-sentry 0.14.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +121 -0
- package/bin/cli.js +57 -0
- package/bin/npm-cli.js +6 -0
- package/bin/npx-cli.js +6 -0
- package/dist/constants.d.ts +162 -0
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/init.gradle +250 -0
- package/dist/instrument-with-sentry.d.ts +1 -0
- package/dist/instrument-with-sentry.js +58 -0
- package/dist/instrument-with-sentry.js.map +1 -0
- package/dist/module-sync/cli.d.ts +2 -0
- package/dist/module-sync/cli.js +6851 -0
- package/dist/module-sync/cli.js.map +1 -0
- package/dist/module-sync/constants.js +3 -0
- package/dist/module-sync/constants2.d.ts +0 -0
- package/dist/module-sync/constants2.js +231 -0
- package/dist/module-sync/constants2.js.map +1 -0
- package/dist/module-sync/debug.d.ts +3 -0
- package/dist/module-sync/edge.d.ts +66 -0
- package/dist/module-sync/errors.d.ts +14 -0
- package/dist/module-sync/index.d.ts +192 -0
- package/dist/module-sync/index.js +1879 -0
- package/dist/module-sync/index.js.map +1 -0
- package/dist/module-sync/logging.d.ts +16 -0
- package/dist/module-sync/node.d.ts +84 -0
- package/dist/module-sync/npm-injection.d.ts +1 -0
- package/dist/module-sync/npm-injection.js +26 -0
- package/dist/module-sync/npm-injection.js.map +1 -0
- package/dist/module-sync/npm-paths.d.ts +15 -0
- package/dist/module-sync/npm-paths.js +423 -0
- package/dist/module-sync/npm-paths.js.map +1 -0
- package/dist/module-sync/npm.d.ts +24 -0
- package/dist/module-sync/npm.js +99 -0
- package/dist/module-sync/npm.js.map +1 -0
- package/dist/module-sync/path-resolve.d.ts +12 -0
- package/dist/module-sync/proc-log.d.ts +3 -0
- package/dist/module-sync/reify.d.ts +1018 -0
- package/dist/module-sync/sdk.d.ts +5 -0
- package/dist/module-sync/settings.d.ts +15 -0
- package/dist/module-sync/shadow-bin.d.ts +2 -0
- package/dist/module-sync/shadow-bin.js +103 -0
- package/dist/module-sync/shadow-bin.js.map +1 -0
- package/dist/module-sync/types.d.ts +45 -0
- package/dist/require/cli.js +6848 -0
- package/dist/require/constants.js +3 -0
- package/dist/require/index.js +3 -0
- package/dist/require/npm-injection.js +3 -0
- package/dist/require/npm-paths.js +3 -0
- package/dist/require/npm.js +3 -0
- package/dist/require/shadow-bin.js +3 -0
- package/dist/require/vendor.js +11474 -0
- package/package.json +245 -0
- package/shadow-bin/npm +4 -0
- package/shadow-bin/npx +4 -0
- package/translations.json +592 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Socket Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Socket CLI
|
|
2
|
+
|
|
3
|
+
[](https://socket.dev/npm/package/socket)
|
|
4
|
+
[](https://twitter.com/SocketSecurity)
|
|
5
|
+
|
|
6
|
+
> CLI tool for [Socket.dev](https://socket.dev/)
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g socket
|
|
12
|
+
socket --help
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
- `socket npm [args...]` and `socket npx [args...]` - Wraps `npm` and `npx` to
|
|
18
|
+
integrate Socket and preempt installation of alerted packages using the
|
|
19
|
+
builtin resolution of `npm` to precisely determine package installations.
|
|
20
|
+
|
|
21
|
+
- `socket optimize` - Optimize dependencies with
|
|
22
|
+
[`@socketregistry`](https://github.com/SocketDev/socket-registry) overrides!
|
|
23
|
+
_(👀 [our blog post](https://socket.dev/blog/introducing-socket-optimize))_
|
|
24
|
+
|
|
25
|
+
- `--pin` - Pin overrides to their latest version.
|
|
26
|
+
- `--prod` - Add overrides for only production dependencies.
|
|
27
|
+
|
|
28
|
+
- `socket cdxgen [command]` - Call out to
|
|
29
|
+
[cdxgen](https://cyclonedx.github.io/cdxgen/#/?id=getting-started). See
|
|
30
|
+
[their documentation](https://cyclonedx.github.io/cdxgen/#/CLI?id=getting-help)
|
|
31
|
+
for commands.
|
|
32
|
+
|
|
33
|
+
## Aliases
|
|
34
|
+
|
|
35
|
+
All aliases support the flags and arguments of the commands they alias.
|
|
36
|
+
|
|
37
|
+
- `socket ci` - alias for `socket report create --view --strict` which creates a
|
|
38
|
+
report and quits with an exit code if the result is unhealthy. Use like eg.
|
|
39
|
+
`socket ci .` for a report for the current folder
|
|
40
|
+
|
|
41
|
+
## Flags
|
|
42
|
+
|
|
43
|
+
### Command specific flags
|
|
44
|
+
|
|
45
|
+
- `--view` - when set on `socket report create` the command will immediately do
|
|
46
|
+
a `socket report view` style view of the created report, waiting for the
|
|
47
|
+
server to complete it
|
|
48
|
+
|
|
49
|
+
### Output flags
|
|
50
|
+
|
|
51
|
+
- `--json` - outputs result as json which you can then pipe into
|
|
52
|
+
[`jq`](https://stedolan.github.io/jq/) and other tools
|
|
53
|
+
- `--markdown` - outputs result as markdown which you can then copy into an
|
|
54
|
+
issue, PR or even chat
|
|
55
|
+
|
|
56
|
+
## Strictness flags
|
|
57
|
+
|
|
58
|
+
- `--all` - by default only `high` and `critical` issues are included, by
|
|
59
|
+
setting this flag all issues will be included
|
|
60
|
+
- `--strict` - when set, exits with an error code if report result is deemed
|
|
61
|
+
unhealthy
|
|
62
|
+
|
|
63
|
+
### Other flags
|
|
64
|
+
|
|
65
|
+
- `--dry-run` - like all CLI tools that perform an action should have, we have a
|
|
66
|
+
dry run flag. Eg. `socket report create` supports running the command without
|
|
67
|
+
actually uploading anything
|
|
68
|
+
- `--debug` - outputs additional debug output. Great for debugging, geeks and us
|
|
69
|
+
who develop. Hopefully you will never _need_ it, but it can still be fun,
|
|
70
|
+
right?
|
|
71
|
+
- `--help` - prints the help for the current command. All CLI tools should have
|
|
72
|
+
this flag
|
|
73
|
+
- `--version` - prints the version of the tool. All CLI tools should have this
|
|
74
|
+
flag
|
|
75
|
+
|
|
76
|
+
## Configuration files
|
|
77
|
+
|
|
78
|
+
The CLI reads and uses data from a
|
|
79
|
+
[`socket.yml` file](https://docs.socket.dev/docs/socket-yml) in the folder you
|
|
80
|
+
run it in. It supports the version 2 of the `socket.yml` file format and makes
|
|
81
|
+
use of the `projectIgnorePaths` to excludes files when creating a report.
|
|
82
|
+
|
|
83
|
+
## Environment variables
|
|
84
|
+
|
|
85
|
+
- `SOCKET_SECURITY_API_TOKEN` - if set, this will be used as the API-key
|
|
86
|
+
|
|
87
|
+
## Contributing
|
|
88
|
+
|
|
89
|
+
### Setup
|
|
90
|
+
|
|
91
|
+
To run dev locally you can run these steps
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
npm install
|
|
95
|
+
npm run build:dist
|
|
96
|
+
npm exec socket
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
That should invoke it from local sources. If you make changes you run
|
|
100
|
+
`build:dist` again.
|
|
101
|
+
|
|
102
|
+
### Environment variables for development
|
|
103
|
+
|
|
104
|
+
- `SOCKET_SECURITY_API_BASE_URL` - if set, this will be the base for all
|
|
105
|
+
API-calls. Defaults to `https://api.socket.dev/v0/`
|
|
106
|
+
- `SOCKET_SECURITY_API_PROXY` - if set to something like
|
|
107
|
+
[`http://127.0.0.1:9090`](https://docs.proxyman.io/troubleshooting/couldnt-see-any-requests-from-3rd-party-network-libraries),
|
|
108
|
+
then all request will be proxied through that proxy
|
|
109
|
+
|
|
110
|
+
## Similar projects
|
|
111
|
+
|
|
112
|
+
- [`@socketsecurity/sdk`](https://github.com/SocketDev/socket-sdk-js) - the SDK
|
|
113
|
+
used in this CLI
|
|
114
|
+
|
|
115
|
+
## See also
|
|
116
|
+
|
|
117
|
+
- [Announcement blog post](https://socket.dev/blog/announcing-socket-cli-preview)
|
|
118
|
+
- [Socket API Reference](https://docs.socket.dev/reference) - the API used in
|
|
119
|
+
this CLI
|
|
120
|
+
- [Socket GitHub App](https://github.com/apps/socket-security) - the
|
|
121
|
+
plug-and-play GitHub App
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
const process = require('node:process')
|
|
5
|
+
|
|
6
|
+
const constants = require('../dist/constants')
|
|
7
|
+
|
|
8
|
+
const { CLI, DIST_TYPE, SOCKET_CLI_SENTRY_BUILD } = constants
|
|
9
|
+
|
|
10
|
+
if (
|
|
11
|
+
DIST_TYPE === 'require' &&
|
|
12
|
+
// Lazily access constants.ENV[SOCKET_CLI_SENTRY_BUILD].
|
|
13
|
+
!constants.ENV[SOCKET_CLI_SENTRY_BUILD]
|
|
14
|
+
) {
|
|
15
|
+
// Lazily access constants.distPath.
|
|
16
|
+
require(`${constants.distPath}/${CLI}.js`)
|
|
17
|
+
} else {
|
|
18
|
+
const path = require('node:path')
|
|
19
|
+
const spawn = require('@npmcli/promise-spawn')
|
|
20
|
+
const { abortSignal } = constants
|
|
21
|
+
|
|
22
|
+
process.exitCode = 1
|
|
23
|
+
const spawnPromise = spawn(
|
|
24
|
+
// Lazily access constants.execPath.
|
|
25
|
+
constants.execPath,
|
|
26
|
+
[
|
|
27
|
+
// Lazily access constants.nodeNoWarningsFlags.
|
|
28
|
+
...constants.nodeNoWarningsFlags,
|
|
29
|
+
// Lazily access constants.ENV[SOCKET_CLI_SENTRY_BUILD].
|
|
30
|
+
...(constants.ENV[SOCKET_CLI_SENTRY_BUILD]
|
|
31
|
+
? [
|
|
32
|
+
'--require',
|
|
33
|
+
// Lazily access constants.instrumentWithSentryPath.
|
|
34
|
+
constants.instrumentWithSentryPath
|
|
35
|
+
]
|
|
36
|
+
: []),
|
|
37
|
+
// Lazily access constants.distPath.
|
|
38
|
+
path.join(constants.distPath, `${CLI}.js`),
|
|
39
|
+
...process.argv.slice(2)
|
|
40
|
+
],
|
|
41
|
+
{
|
|
42
|
+
signal: abortSignal,
|
|
43
|
+
stdio: 'inherit'
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
// See https://nodejs.org/api/all.html#all_child_process_event-exit.
|
|
47
|
+
spawnPromise.process.on('exit', (code, signalName) => {
|
|
48
|
+
if (abortSignal.aborted) {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
if (signalName) {
|
|
52
|
+
process.kill(process.pid, signalName)
|
|
53
|
+
} else if (code !== null) {
|
|
54
|
+
process.exit(code)
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
}
|
package/bin/npm-cli.js
ADDED
package/bin/npx-cli.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import registryConstants from '@socketsecurity/registry/lib/constants';
|
|
3
|
+
import { Remap } from '@socketsecurity/registry/lib/objects';
|
|
4
|
+
type RegistryEnv = typeof registryConstants.ENV;
|
|
5
|
+
type RegistryInternals = (typeof registryConstants)['Symbol(kInternalsSymbol)'];
|
|
6
|
+
type Sentry = any;
|
|
7
|
+
type Internals = Remap<Omit<RegistryInternals, 'getIPC'> & Readonly<{
|
|
8
|
+
getIPC: {
|
|
9
|
+
(): Promise<IPC>;
|
|
10
|
+
<K extends keyof IPC | undefined>(key?: K): Promise<K extends keyof IPC ? IPC[K] : IPC>;
|
|
11
|
+
};
|
|
12
|
+
getSentry: () => Sentry;
|
|
13
|
+
setSentry(Sentry: Sentry): boolean;
|
|
14
|
+
}>>;
|
|
15
|
+
type ENV = Remap<RegistryEnv & Readonly<{
|
|
16
|
+
SOCKET_CLI_DEBUG: boolean;
|
|
17
|
+
SOCKET_CLI_LEGACY_BUILD: boolean;
|
|
18
|
+
SOCKET_CLI_PUBLISHED_BUILD: boolean;
|
|
19
|
+
SOCKET_CLI_SENTRY_BUILD: boolean;
|
|
20
|
+
SOCKET_CLI_VERSION_HASH: string;
|
|
21
|
+
}>>;
|
|
22
|
+
type IPC = Readonly<{
|
|
23
|
+
SOCKET_CLI_FIX?: string;
|
|
24
|
+
SOCKET_CLI_OPTIMIZE?: boolean;
|
|
25
|
+
SOCKET_CLI_SAFE_WRAPPER?: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
declare const constants: {
|
|
28
|
+
readonly [kInternalsSymbol]: registryConstants.Internals;
|
|
29
|
+
readonly NODE_MODULES: "node_modules";
|
|
30
|
+
readonly PACKAGE_JSON: "package.json";
|
|
31
|
+
readonly TAP: "TAP";
|
|
32
|
+
readonly kInternalsSymbol: unique symbol;
|
|
33
|
+
readonly CI: "CI";
|
|
34
|
+
readonly NODE_AUTH_TOKEN: "NODE_AUTH_TOKEN";
|
|
35
|
+
readonly NODE_ENV: "NODE_ENV";
|
|
36
|
+
readonly PRE_COMMIT: "PRE_COMMIT";
|
|
37
|
+
readonly VITEST: "VITEST";
|
|
38
|
+
readonly AT_LATEST: "@latest";
|
|
39
|
+
readonly BIOME_JSON: "biome.json";
|
|
40
|
+
readonly COLUMN_LIMIT: 80;
|
|
41
|
+
readonly EMPTY_FILE: "/* empty */\n";
|
|
42
|
+
readonly ESLINT_CONFIG_JS: "eslint.config.js";
|
|
43
|
+
readonly ESNEXT: "esnext";
|
|
44
|
+
readonly EXTENSIONS: "extensions";
|
|
45
|
+
readonly EXTENSIONS_JSON: "extensions.json";
|
|
46
|
+
readonly GIT_IGNORE: ".gitignore";
|
|
47
|
+
readonly LATEST: "latest";
|
|
48
|
+
readonly LICENSE: "LICENSE";
|
|
49
|
+
readonly LICENSE_GLOB: "LICEN[CS]E{[.-]*,}";
|
|
50
|
+
readonly LICENSE_GLOB_RECURSIVE: "**/LICEN[CS]E{[.-]*,}";
|
|
51
|
+
readonly LICENSE_ORIGINAL: "LICENSE.original";
|
|
52
|
+
readonly LICENSE_ORIGINAL_GLOB: "*.original{.*,}";
|
|
53
|
+
readonly LICENSE_ORIGINAL_GLOB_RECURSIVE: "**/*.original{.*,}";
|
|
54
|
+
readonly LOOP_SENTINEL: 1000000;
|
|
55
|
+
readonly MANIFEST_JSON: "manifest.json";
|
|
56
|
+
readonly MIT: "MIT";
|
|
57
|
+
readonly NODE_MODULES_GLOB_RECURSIVE: "**/node_modules";
|
|
58
|
+
readonly NODE_WORKSPACES: "node_workspaces";
|
|
59
|
+
readonly NODE_VERSION: string;
|
|
60
|
+
readonly NPM: "npm";
|
|
61
|
+
readonly NPM_ORG: "socketregistry";
|
|
62
|
+
readonly OVERRIDES: "overrides";
|
|
63
|
+
readonly PACKAGE_DEFAULT_SOCKET_CATEGORIES: readonly ["cleanup"];
|
|
64
|
+
readonly PACKAGE_DEFAULT_NODE_RANGE: string;
|
|
65
|
+
readonly PACKAGE_DEFAULT_VERSION: "1.0.0";
|
|
66
|
+
readonly PACKAGE_LOCK: "package-lock.json";
|
|
67
|
+
readonly PACKAGE_SCOPE: "@socketregistry";
|
|
68
|
+
readonly README_GLOB: "README{.*,}";
|
|
69
|
+
readonly README_GLOB_RECURSIVE: "**/README{.*,}";
|
|
70
|
+
readonly README_MD: "README.md";
|
|
71
|
+
readonly REGISTRY: "registry";
|
|
72
|
+
readonly REGISTRY_SCOPE_DELIMITER: "__";
|
|
73
|
+
readonly RESOLUTIONS: "resolutions";
|
|
74
|
+
readonly SOCKET_IPC_HANDSHAKE: "SOCKET_IPC_HANDSHAKE";
|
|
75
|
+
readonly SOCKET_PUBLIC_API_KEY: string;
|
|
76
|
+
readonly SOCKET_PUBLIC_API_TOKEN: string;
|
|
77
|
+
readonly SOCKET_REPO_ORG: "SocketDev";
|
|
78
|
+
readonly SOCKET_REGISTRY_REPO_NAME: "socket-registry";
|
|
79
|
+
readonly SUPPORTS_NODE_DISABLE_WARNING_FLAG: boolean;
|
|
80
|
+
readonly SUPPORTS_NODE_REQUIRE_MODULE: boolean;
|
|
81
|
+
readonly SUPPORTS_NODE_RUN: boolean;
|
|
82
|
+
readonly SUPPORTS_PROCESS_SEND: boolean;
|
|
83
|
+
readonly TEMPLATE_CJS: "cjs";
|
|
84
|
+
readonly TEMPLATE_CJS_BROWSER: "cjs-browser";
|
|
85
|
+
readonly TEMPLATE_CJS_ESM: "cjs-esm";
|
|
86
|
+
readonly TEMPLATE_ES_SHIM_CONSTRUCTOR: "es-shim-constructor";
|
|
87
|
+
readonly TEMPLATE_ES_SHIM_PROTOTYPE_METHOD: "es-shim-prototype-method";
|
|
88
|
+
readonly TEMPLATE_ES_SHIM_STATIC_METHOD: "es-shim-static-method";
|
|
89
|
+
readonly TSCONFIG_JSON: "tsconfig.json";
|
|
90
|
+
readonly UNDEFINED_TOKEN: {};
|
|
91
|
+
readonly UNLICENCED: "UNLICENCED";
|
|
92
|
+
readonly UNLICENSED: "UNLICENSED";
|
|
93
|
+
readonly WIN32: boolean;
|
|
94
|
+
readonly abortController: AbortController;
|
|
95
|
+
readonly abortSignal: AbortSignal;
|
|
96
|
+
readonly copyLeftLicenses: ReadonlySet<string>;
|
|
97
|
+
readonly execPath: string;
|
|
98
|
+
readonly ignoreGlobs: readonly ["**/.git", "**/.npmrc", "**/bun.lockb?", "**/node_modules", "**/package-lock.json", "**/pnpm-lock.ya?ml", "**/yarn.lock", "**/.DS_Store", "**/.gitignore", "**/.hg", "**/.lock-wscript", "**/.npmignore", "**/.svn", "**/.wafpickle-*", "**/.*.swp", "**/._*/**", "**/archived-packages/**", "**/build/config.gypi", "**/CVS", "**/npm-debug.log", "**/*.orig", "**/.env", "**/.eslintcache", "**/.nvm", "**/.tap", "**/.tapci.yaml", "**/.vscode", "**/*.tsbuildinfo", "**/Thumbs.db"];
|
|
99
|
+
readonly lifecycleScriptNames: ReadonlySet<string>;
|
|
100
|
+
readonly maintainedNodeVersions: registryConstants.MaintainedNodeVersions;
|
|
101
|
+
readonly nodeNoWarningsFlags: readonly string[];
|
|
102
|
+
readonly npmExecPath: string;
|
|
103
|
+
readonly packageExtensions: readonly [string, object][];
|
|
104
|
+
readonly packumentCache: Map<unknown, unknown>;
|
|
105
|
+
readonly pacoteCachePath: string;
|
|
106
|
+
readonly parseArgsConfig: registryConstants.ParseArgsConfig;
|
|
107
|
+
readonly skipTestsByEcosystem: Readonly<Record<string, ReadonlySet<string>>>;
|
|
108
|
+
readonly tsLibsAvailable: ReadonlySet<string>;
|
|
109
|
+
readonly tsTypesAvailable: ReadonlySet<string>;
|
|
110
|
+
readonly win32EnsureTestsByEcosystem: Readonly<Record<string, ReadonlySet<string>>>;
|
|
111
|
+
readonly 'Symbol(kInternalsSymbol)': Internals;
|
|
112
|
+
readonly ALERT_TYPE_CRITICAL_CVE: 'criticalCVE';
|
|
113
|
+
readonly ALERT_TYPE_CVE: 'cve';
|
|
114
|
+
readonly ALERT_TYPE_MEDIUM_CVE: 'mediumCVE';
|
|
115
|
+
readonly ALERT_TYPE_MILD_CVE: 'mildCVE';
|
|
116
|
+
readonly ALERT_TYPE_SOCKET_UPGRADE_AVAILABLE: 'socketUpgradeAvailable';
|
|
117
|
+
readonly API_V0_URL: 'https://api.socket.dev/v0';
|
|
118
|
+
readonly BABEL_RUNTIME: '@babel/runtime';
|
|
119
|
+
readonly BATCH_PURL_ENDPOINT: 'https://api.socket.dev/v0/purl?alerts=true&compact=true';
|
|
120
|
+
readonly BINARY_LOCK_EXT: '.lockb';
|
|
121
|
+
readonly BUN: 'bun';
|
|
122
|
+
readonly CLI: 'cli';
|
|
123
|
+
readonly CVE_ALERT_PROPS_FIRST_PATCHED_VERSION_IDENTIFIER: 'firstPatchedVersionIdentifier';
|
|
124
|
+
readonly CVE_ALERT_PROPS_VULNERABLE_VERSION_RANGE: 'vulnerableVersionRange';
|
|
125
|
+
readonly ENV: ENV;
|
|
126
|
+
readonly DIST_TYPE: 'module-sync' | 'require';
|
|
127
|
+
readonly IPC: IPC;
|
|
128
|
+
readonly LOCK_EXT: '.lock';
|
|
129
|
+
readonly MODULE_SYNC: 'module-sync';
|
|
130
|
+
readonly NPM_INJECTION: 'npm-injection';
|
|
131
|
+
readonly NPM_REGISTRY_URL: 'https://registry.npmjs.org';
|
|
132
|
+
readonly NPX: 'npx';
|
|
133
|
+
readonly PNPM: 'pnpm';
|
|
134
|
+
readonly REQUIRE: 'require';
|
|
135
|
+
readonly SHADOW_BIN: 'shadow-bin';
|
|
136
|
+
readonly SOCKET: 'socket';
|
|
137
|
+
readonly SOCKET_CLI_DEBUG: 'SOCKET_CLI_DEBUG';
|
|
138
|
+
readonly SOCKET_CLI_FIX: 'SOCKET_CLI_FIX';
|
|
139
|
+
readonly SOCKET_CLI_ISSUES_URL: 'https://github.com/SocketDev/socket-cli/issues';
|
|
140
|
+
readonly SOCKET_CLI_LEGACY_BUILD: 'SOCKET_CLI_LEGACY_BUILD';
|
|
141
|
+
readonly SOCKET_CLI_OPTIMIZE: 'SOCKET_CLI_OPTIMIZE';
|
|
142
|
+
readonly SOCKET_CLI_PUBLISHED_BUILD: 'SOCKET_CLI_PUBLISHED_BUILD';
|
|
143
|
+
readonly SOCKET_CLI_SAFE_WRAPPER: 'SOCKET_CLI_SAFE_WRAPPER';
|
|
144
|
+
readonly SOCKET_CLI_SENTRY_BUILD: 'SOCKET_CLI_SENTRY_BUILD';
|
|
145
|
+
readonly SOCKET_CLI_VERSION_HASH: 'SOCKET_CLI_VERSION_HASH';
|
|
146
|
+
readonly VLT: 'vlt';
|
|
147
|
+
readonly YARN: 'yarn';
|
|
148
|
+
readonly YARN_BERRY: 'yarn/berry';
|
|
149
|
+
readonly YARN_CLASSIC: 'yarn/classic';
|
|
150
|
+
readonly cdxgenBinPath: string;
|
|
151
|
+
readonly distPath: string;
|
|
152
|
+
readonly instrumentWithSentryPath: string;
|
|
153
|
+
readonly nmBinPath: string;
|
|
154
|
+
readonly npmInjectionPath: string;
|
|
155
|
+
readonly rootBinPath: string;
|
|
156
|
+
readonly rootDistPath: string;
|
|
157
|
+
readonly rootPath: string;
|
|
158
|
+
readonly rootPkgJsonPath: string;
|
|
159
|
+
readonly shadowBinPath: string;
|
|
160
|
+
readonly synpBinPath: string;
|
|
161
|
+
};
|
|
162
|
+
export { constants as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;","debugId":"415faf35-61fa-4973-8b4c-040eacb52c54"}
|
package/dist/init.gradle
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// This is a Gradle initialization script that generates Maven POM files for projects
|
|
2
|
+
// A POM file describes a project's dependencies and other metadata in XML format
|
|
3
|
+
|
|
4
|
+
// This script:
|
|
5
|
+
// - Generates Maven POM files for Java/Kotlin/Android projects
|
|
6
|
+
// - Handles different types of dependencies (direct, project, version catalog)
|
|
7
|
+
// - Supports different project types (Java, Android, root project)
|
|
8
|
+
// - Can be invoked with `./gradlew --init-script /path/to/this/script pom` to generate POM files
|
|
9
|
+
// - Copies the generated POM to a target location (default: pom.xml)
|
|
10
|
+
|
|
11
|
+
initscript {
|
|
12
|
+
repositories {
|
|
13
|
+
// We need these repositories for Gradle's plugin resolution system
|
|
14
|
+
// TODO: it's not clear if we actually need them.
|
|
15
|
+
gradlePluginPortal()
|
|
16
|
+
mavenCentral()
|
|
17
|
+
google()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
dependencies {
|
|
21
|
+
// No external dependencies needed as we only use Gradle's built-in maven-publish plugin
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Apply these configurations to all projects in the build
|
|
26
|
+
gradle.allprojects { project ->
|
|
27
|
+
// Create a unique name for the Maven publication
|
|
28
|
+
// Example: project ':foo:bar' becomes 'maven-foo-bar'
|
|
29
|
+
def publicationName = "maven-${project.path.replace(':', '-')}"
|
|
30
|
+
if (publicationName.startsWith('maven--')) {
|
|
31
|
+
publicationName = 'maven-root' // Special case for root project
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Apply the Maven Publish plugin if not already applied
|
|
35
|
+
if (!project.plugins.hasPlugin('maven-publish')) {
|
|
36
|
+
project.plugins.apply('maven-publish')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Register a new task called 'pom' that will generate the POM file.
|
|
40
|
+
// This is what allows us to do `gradlew pom`. We could rename it to
|
|
41
|
+
// something like socket-generate-pom instead. It should be invisible
|
|
42
|
+
// to the user because this script is not part of their repo.
|
|
43
|
+
project.tasks.register('pom') {
|
|
44
|
+
group = 'publishing' // Group tasks are shown together in ./gradlew tasks (irrelevant)
|
|
45
|
+
description = 'Generates a POM file'
|
|
46
|
+
// Force task to run every time. Otherwise caching would cause
|
|
47
|
+
// subsequent runs without changes to do anything.
|
|
48
|
+
// There may be room for improvement; I think this may cause
|
|
49
|
+
// everything to run which is theorietically not necessary.
|
|
50
|
+
outputs.upToDateWhen { false }
|
|
51
|
+
|
|
52
|
+
// Define where POM files will be generated and copied
|
|
53
|
+
def defaultPomFile = project.file("build/publications/${publicationName}/pom-default.xml")
|
|
54
|
+
def targetPomFile = project.hasProperty('pomPath') ?
|
|
55
|
+
project.file(project.property('pomPath')) : // Custom location if specified. You can use `./gradlew pom -PpomPath=path/to/pom.xml` to specify a custom location.
|
|
56
|
+
project.file('pom.xml') // Default location
|
|
57
|
+
|
|
58
|
+
// Declare task inputs and outputs for Gradle's incremental build system
|
|
59
|
+
inputs.file(defaultPomFile)
|
|
60
|
+
outputs.file(targetPomFile)
|
|
61
|
+
|
|
62
|
+
// The actual work of copying the POM file happens here
|
|
63
|
+
doLast {
|
|
64
|
+
if (defaultPomFile.exists()) {
|
|
65
|
+
// Print the generated POM for inspection
|
|
66
|
+
println "\nGenerated POM file for ${publicationName}:"
|
|
67
|
+
// println "=================================="
|
|
68
|
+
// println defaultPomFile.text
|
|
69
|
+
// println "=================================="
|
|
70
|
+
|
|
71
|
+
// Copy the POM file to its target location
|
|
72
|
+
targetPomFile.parentFile.mkdirs()
|
|
73
|
+
targetPomFile.text = defaultPomFile.text
|
|
74
|
+
println "\nPOM file copied to: ${targetPomFile.absolutePath}"
|
|
75
|
+
} else {
|
|
76
|
+
println "No POM file generated at ${defaultPomFile.absolutePath}"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Wait for project evaluation to complete before configuring publication
|
|
82
|
+
project.afterEvaluate { p ->
|
|
83
|
+
p.plugins.withId('maven-publish') {
|
|
84
|
+
// Gather project information
|
|
85
|
+
def projectPath = p.path
|
|
86
|
+
def projectName = p.name
|
|
87
|
+
def projectDesc = p.description ?: p.name
|
|
88
|
+
def isRootProject = p.path == ':' && !p.subprojects.isEmpty()
|
|
89
|
+
def isAndroidProject = p.plugins?.hasPlugin('com.android.library') ||
|
|
90
|
+
p.plugins?.hasPlugin('com.android.application')
|
|
91
|
+
def hasJavaComponent = p.extensions?.findByName('components')?.findByName('java') != null
|
|
92
|
+
|
|
93
|
+
// Store all dependencies we find here
|
|
94
|
+
def projectDependencies = []
|
|
95
|
+
|
|
96
|
+
// Find all relevant dependency configurations
|
|
97
|
+
// We care about implementation, api, compile, and runtime configurations
|
|
98
|
+
// TODO: anything we're missing here? tests maybe?
|
|
99
|
+
def relevantConfigs = p.configurations.findAll { config ->
|
|
100
|
+
!config.name.toLowerCase().contains('test') &&
|
|
101
|
+
(config.name.endsWith('Implementation') ||
|
|
102
|
+
config.name.endsWith('Api') ||
|
|
103
|
+
config.name == 'implementation' ||
|
|
104
|
+
config.name == 'api' ||
|
|
105
|
+
config.name == 'compile' ||
|
|
106
|
+
config.name == 'runtime')
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Process each configuration to find dependencies
|
|
110
|
+
relevantConfigs.each { config ->
|
|
111
|
+
config.dependencies.each { dep ->
|
|
112
|
+
if (dep instanceof ProjectDependency) {
|
|
113
|
+
// Handle project dependencies (e.g., implementation(project(":other-module")))
|
|
114
|
+
def depProjectPath = dep.dependencyProject.path
|
|
115
|
+
def depProjectName = depProjectPath.substring(depProjectPath.lastIndexOf(':') + 1)
|
|
116
|
+
projectDependencies << [
|
|
117
|
+
group: p.group ?: p.rootProject.name,
|
|
118
|
+
name: depProjectName,
|
|
119
|
+
version: p.version ?: 'unspecified',
|
|
120
|
+
scope: config.name.contains('api') ? 'compile' : 'runtime'
|
|
121
|
+
]
|
|
122
|
+
} else {
|
|
123
|
+
// Handle all other types of dependencies
|
|
124
|
+
try {
|
|
125
|
+
def group = dep.group
|
|
126
|
+
def name = dep.name
|
|
127
|
+
def version = dep.version
|
|
128
|
+
|
|
129
|
+
// Handle version catalog dependencies (e.g., implementation(libs.some.library))
|
|
130
|
+
if (!group && p.findProperty('libs')) {
|
|
131
|
+
def depString = dep.toString()
|
|
132
|
+
|
|
133
|
+
// Skip bundles and file dependencies as they need special handling
|
|
134
|
+
if (!depString.contains('Bundle') && !dep.toString().contains('DefaultFileCollectionDependency')) {
|
|
135
|
+
try {
|
|
136
|
+
// Extract library name from version catalog reference
|
|
137
|
+
def libName = depString.contains('libs.') ?
|
|
138
|
+
depString.substring(depString.indexOf('libs.') + 5) :
|
|
139
|
+
depString
|
|
140
|
+
def libProvider = p.libs.findLibrary(libName)
|
|
141
|
+
if (libProvider.present) {
|
|
142
|
+
def dependency = libProvider.get()
|
|
143
|
+
projectDependencies << [
|
|
144
|
+
group: dependency.get().module.group,
|
|
145
|
+
name: dependency.get().module.name,
|
|
146
|
+
version: dependency.versionConstraint.requiredVersion,
|
|
147
|
+
scope: config.name.contains('api') ? 'compile' : 'runtime'
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
} catch (Exception e) {
|
|
151
|
+
println " - Skipping non-catalog dependency: ${dep}"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
} else if (group && name) {
|
|
155
|
+
// Handle regular dependencies (e.g., implementation("group:name:version"))
|
|
156
|
+
projectDependencies << [
|
|
157
|
+
group: group,
|
|
158
|
+
name: name,
|
|
159
|
+
version: version ?: 'unspecified',
|
|
160
|
+
scope: config.name.contains('api') ? 'compile' : 'runtime'
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
} catch (Exception e) {
|
|
164
|
+
println " - Failed to process dependency: ${e.message}"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Configure the Maven publication
|
|
171
|
+
p.publishing {
|
|
172
|
+
publications {
|
|
173
|
+
if (!publications.findByName(publicationName)) {
|
|
174
|
+
create(publicationName, MavenPublication) {
|
|
175
|
+
// Handle different project types
|
|
176
|
+
if (isAndroidProject) {
|
|
177
|
+
// For Android libraries, we need to wait for the Android plugin to set up
|
|
178
|
+
afterEvaluate {
|
|
179
|
+
def android = p.extensions.findByName('android')
|
|
180
|
+
if (android) {
|
|
181
|
+
// Try to get the release variant component
|
|
182
|
+
def components = p.components
|
|
183
|
+
def componentNames = components.names
|
|
184
|
+
|
|
185
|
+
// Look for specific variant components
|
|
186
|
+
// Prefer release over debug
|
|
187
|
+
if (components.findByName("release")) {
|
|
188
|
+
from components.release
|
|
189
|
+
} else if (components.findByName("debug")) {
|
|
190
|
+
from components.debug
|
|
191
|
+
} else {
|
|
192
|
+
println "Warning: No release or debug component found for Android project ${p.name}"
|
|
193
|
+
// Skip the component for now, will still generate POM
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
println "Warning: Android extension not found for project ${p.name}"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} else if (!isRootProject && hasJavaComponent) {
|
|
200
|
+
// For Java libraries, use the java component
|
|
201
|
+
from components.java
|
|
202
|
+
}
|
|
203
|
+
// Root project doesn't need a 'from' clause as it's just a POM
|
|
204
|
+
|
|
205
|
+
// Configure the POM file content
|
|
206
|
+
pom {
|
|
207
|
+
// Set packaging type based on project type (why is this necessary?)
|
|
208
|
+
packaging = isRootProject ? 'pom' : (isAndroidProject ? 'aar' : 'jar')
|
|
209
|
+
name = projectName
|
|
210
|
+
description = projectDesc
|
|
211
|
+
|
|
212
|
+
// Customize the POM XML
|
|
213
|
+
withXml { xml ->
|
|
214
|
+
def root = xml.asNode()
|
|
215
|
+
def dependencies = root.appendNode('dependencies')
|
|
216
|
+
|
|
217
|
+
// Add all collected dependencies to the POM
|
|
218
|
+
projectDependencies.each { dep ->
|
|
219
|
+
def dependency = dependencies.appendNode('dependency')
|
|
220
|
+
// Ensure all values are strings
|
|
221
|
+
dependency.appendNode('groupId', String.valueOf(dep.group))
|
|
222
|
+
dependency.appendNode('artifactId', String.valueOf(dep.name))
|
|
223
|
+
dependency.appendNode('version', String.valueOf(dep.version ?: 'unspecified'))
|
|
224
|
+
dependency.appendNode('scope', String.valueOf(dep.scope))
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Add standard properties for root project
|
|
228
|
+
if (isRootProject) {
|
|
229
|
+
def properties = root.appendNode('properties')
|
|
230
|
+
properties.appendNode('kotlin.version', String.valueOf('1.9.0'))
|
|
231
|
+
properties.appendNode('java.version', String.valueOf('11'))
|
|
232
|
+
properties.appendNode('project.build.sourceEncoding', String.valueOf('UTF-8'))
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Make our pom task depend on the actual POM generation task
|
|
242
|
+
project.tasks.named('pom') {
|
|
243
|
+
def pomTask = "generatePomFileFor${publicationName.capitalize()}Publication"
|
|
244
|
+
if (project.tasks?.findByName(pomTask)) {
|
|
245
|
+
dependsOn(pomTask)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|