@aikidosec/safe-chain 1.1.10 → 1.2.0
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/README.md +70 -35
- package/bin/aikido-bun.js +4 -2
- package/bin/aikido-bunx.js +4 -2
- package/bin/aikido-npm.js +4 -2
- package/bin/aikido-npx.js +4 -2
- package/bin/aikido-pip.js +5 -3
- package/bin/aikido-pip3.js +5 -3
- package/bin/aikido-pnpm.js +4 -2
- package/bin/aikido-pnpx.js +4 -2
- package/bin/aikido-python.js +15 -13
- package/bin/aikido-python3.js +15 -13
- package/bin/aikido-uv.js +5 -3
- package/bin/aikido-yarn.js +4 -2
- package/bin/safe-chain.js +106 -10
- package/docs/banner.svg +151 -0
- package/docs/npm-to-binary-migration.md +89 -0
- package/package.json +5 -4
- package/src/packagemanager/pip/runPipCommand.js +25 -0
- package/src/registryProxy/mitmRequestHandler.js +8 -4
- package/src/shell-integration/helpers.js +73 -12
- package/src/shell-integration/path-wrappers/templates/unix-wrapper.template.sh +2 -2
- package/src/shell-integration/path-wrappers/templates/windows-wrapper.template.cmd +2 -2
- package/src/shell-integration/setup-ci.js +26 -9
- package/src/shell-integration/setup.js +17 -5
- package/src/shell-integration/startup-scripts/include-python/init-fish.fish +45 -43
- package/src/shell-integration/startup-scripts/include-python/init-posix.sh +36 -39
- package/src/shell-integration/startup-scripts/include-python/init-pwsh.ps1 +65 -61
- package/src/shell-integration/startup-scripts/init-fish.fish +39 -38
- package/src/shell-integration/startup-scripts/init-posix.sh +30 -34
- package/src/shell-integration/startup-scripts/init-pwsh.ps1 +42 -38
|
@@ -1,53 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
function printSafeChainWarning() {
|
|
3
|
-
# \033[43;30m is used to set the background color to yellow and text color to black
|
|
4
|
-
# \033[0m is used to reset the text formatting
|
|
5
|
-
printf "\033[43;30mWarning:\033[0m safe-chain is not available to protect you from installing malware. %s will run without it.\n" "$1"
|
|
6
|
-
# \033[36m is used to set the text color to cyan
|
|
7
|
-
printf "Install safe-chain by using \033[36mnpm install -g @aikidosec/safe-chain\033[0m.\n"
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function wrapSafeChainCommand() {
|
|
11
|
-
local original_cmd="$1"
|
|
12
|
-
local aikido_cmd="$2"
|
|
13
|
-
|
|
14
|
-
# Remove the first 2 arguments (original_cmd and aikido_cmd) from $@
|
|
15
|
-
# so that "$@" now contains only the arguments passed to the original command
|
|
16
|
-
shift 2
|
|
17
|
-
|
|
18
|
-
if command -v "$aikido_cmd" > /dev/null 2>&1; then
|
|
19
|
-
# If the aikido command is available, just run it with the provided arguments
|
|
20
|
-
"$aikido_cmd" "$@"
|
|
21
|
-
else
|
|
22
|
-
# If the aikido command is not available, print a warning and run the original command
|
|
23
|
-
printSafeChainWarning "$original_cmd"
|
|
24
|
-
|
|
25
|
-
command "$original_cmd" "$@"
|
|
26
|
-
fi
|
|
27
|
-
}
|
|
1
|
+
export PATH="$PATH:$HOME/.safe-chain/bin"
|
|
28
2
|
|
|
29
3
|
function npx() {
|
|
30
|
-
wrapSafeChainCommand "npx" "
|
|
4
|
+
wrapSafeChainCommand "npx" "$@"
|
|
31
5
|
}
|
|
32
6
|
|
|
33
7
|
function yarn() {
|
|
34
|
-
wrapSafeChainCommand "yarn" "
|
|
8
|
+
wrapSafeChainCommand "yarn" "$@"
|
|
35
9
|
}
|
|
36
10
|
|
|
37
11
|
function pnpm() {
|
|
38
|
-
wrapSafeChainCommand "pnpm" "
|
|
12
|
+
wrapSafeChainCommand "pnpm" "$@"
|
|
39
13
|
}
|
|
40
14
|
|
|
41
15
|
function pnpx() {
|
|
42
|
-
wrapSafeChainCommand "pnpx" "
|
|
16
|
+
wrapSafeChainCommand "pnpx" "$@"
|
|
43
17
|
}
|
|
44
18
|
|
|
45
19
|
function bun() {
|
|
46
|
-
wrapSafeChainCommand "bun" "
|
|
20
|
+
wrapSafeChainCommand "bun" "$@"
|
|
47
21
|
}
|
|
48
22
|
|
|
49
23
|
function bunx() {
|
|
50
|
-
wrapSafeChainCommand "bunx" "
|
|
24
|
+
wrapSafeChainCommand "bunx" "$@"
|
|
51
25
|
}
|
|
52
26
|
|
|
53
27
|
function npm() {
|
|
@@ -58,5 +32,27 @@ function npm() {
|
|
|
58
32
|
return
|
|
59
33
|
fi
|
|
60
34
|
|
|
61
|
-
wrapSafeChainCommand "npm" "
|
|
35
|
+
wrapSafeChainCommand "npm" "$@"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function printSafeChainWarning() {
|
|
39
|
+
# \033[43;30m is used to set the background color to yellow and text color to black
|
|
40
|
+
# \033[0m is used to reset the text formatting
|
|
41
|
+
printf "\033[43;30mWarning:\033[0m safe-chain is not available to protect you from installing malware. %s will run without it.\n" "$1"
|
|
42
|
+
# \033[36m is used to set the text color to cyan
|
|
43
|
+
printf "Install safe-chain by using \033[36mnpm install -g @aikidosec/safe-chain\033[0m.\n"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function wrapSafeChainCommand() {
|
|
47
|
+
local original_cmd="$1"
|
|
48
|
+
|
|
49
|
+
if command -v safe-chain > /dev/null 2>&1; then
|
|
50
|
+
# If the aikido command is available, just run it with the provided arguments
|
|
51
|
+
safe-chain "$@"
|
|
52
|
+
else
|
|
53
|
+
# If the aikido command is not available, print a warning and run the original command
|
|
54
|
+
printSafeChainWarning "$original_cmd"
|
|
55
|
+
|
|
56
|
+
command "$original_cmd" "$@"
|
|
57
|
+
fi
|
|
62
58
|
}
|
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
# Use cross-platform path separator (: on Unix, ; on Windows)
|
|
2
|
+
$pathSeparator = if ($IsWindows) { ';' } else { ':' }
|
|
3
|
+
$safeChainBin = Join-Path $HOME '.safe-chain' 'bin'
|
|
4
|
+
$env:PATH = "$env:PATH$pathSeparator$safeChainBin"
|
|
5
|
+
|
|
6
|
+
function npx {
|
|
7
|
+
Invoke-WrappedCommand "npx" $args
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function yarn {
|
|
11
|
+
Invoke-WrappedCommand "yarn" $args
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function pnpm {
|
|
15
|
+
Invoke-WrappedCommand "pnpm" $args
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function pnpx {
|
|
19
|
+
Invoke-WrappedCommand "pnpx" $args
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function bun {
|
|
23
|
+
Invoke-WrappedCommand "bun" $args
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function bunx {
|
|
27
|
+
Invoke-WrappedCommand "bunx" $args
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function npm {
|
|
31
|
+
# If args is just -v or --version and nothing else, just run the npm version command
|
|
32
|
+
# This is because nvm uses this to check the version of npm
|
|
33
|
+
if (($args.Length -eq 1) -and (($args[0] -eq "-v") -or ($args[0] -eq "--version"))) {
|
|
34
|
+
Invoke-RealCommand "npm" $args
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Invoke-WrappedCommand "npm" $args
|
|
39
|
+
}
|
|
40
|
+
|
|
1
41
|
function Write-SafeChainWarning {
|
|
2
42
|
param([string]$Command)
|
|
3
43
|
|
|
@@ -39,50 +79,14 @@ function Invoke-RealCommand {
|
|
|
39
79
|
function Invoke-WrappedCommand {
|
|
40
80
|
param(
|
|
41
81
|
[string]$OriginalCmd,
|
|
42
|
-
[string]$AikidoCmd,
|
|
43
82
|
[string[]]$Arguments
|
|
44
83
|
)
|
|
45
84
|
|
|
46
|
-
if (Test-CommandAvailable
|
|
47
|
-
& $
|
|
85
|
+
if (Test-CommandAvailable "safe-chain") {
|
|
86
|
+
& safe-chain $OriginalCmd @Arguments
|
|
48
87
|
}
|
|
49
88
|
else {
|
|
50
89
|
Write-SafeChainWarning $OriginalCmd
|
|
51
90
|
Invoke-RealCommand $OriginalCmd $Arguments
|
|
52
91
|
}
|
|
53
92
|
}
|
|
54
|
-
|
|
55
|
-
function npx {
|
|
56
|
-
Invoke-WrappedCommand "npx" "aikido-npx" $args
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function yarn {
|
|
60
|
-
Invoke-WrappedCommand "yarn" "aikido-yarn" $args
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function pnpm {
|
|
64
|
-
Invoke-WrappedCommand "pnpm" "aikido-pnpm" $args
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function pnpx {
|
|
68
|
-
Invoke-WrappedCommand "pnpx" "aikido-pnpx" $args
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function bun {
|
|
72
|
-
Invoke-WrappedCommand "bun" "aikido-bun" $args
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function bunx {
|
|
76
|
-
Invoke-WrappedCommand "bunx" "aikido-bunx" $args
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function npm {
|
|
80
|
-
# If args is just -v or --version and nothing else, just run the npm version command
|
|
81
|
-
# This is because nvm uses this to check the version of npm
|
|
82
|
-
if (($args.Length -eq 1) -and (($args[0] -eq "-v") -or ($args[0] -eq "--version"))) {
|
|
83
|
-
Invoke-RealCommand "npm" $args
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
Invoke-WrappedCommand "npm" "aikido-npm" $args
|
|
88
|
-
}
|