@aikidosec/safe-chain 1.2.2 → 1.3.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.
Files changed (28) hide show
  1. package/README.md +24 -55
  2. package/bin/aikido-poetry.js +13 -0
  3. package/bin/safe-chain.js +2 -11
  4. package/package.json +2 -1
  5. package/src/config/cliArguments.js +1 -17
  6. package/src/config/configFile.js +1 -1
  7. package/src/config/settings.js +1 -1
  8. package/src/main.js +4 -2
  9. package/src/packagemanager/currentPackageManager.js +3 -0
  10. package/src/packagemanager/pip/runPipCommand.js +6 -3
  11. package/src/packagemanager/poetry/createPoetryPackageManager.js +77 -0
  12. package/src/registryProxy/certBundle.js +99 -13
  13. package/src/registryProxy/certUtils.js +55 -5
  14. package/src/registryProxy/getConnectTimeout.js +13 -0
  15. package/src/registryProxy/interceptors/interceptorBuilder.js +6 -0
  16. package/src/registryProxy/interceptors/pipInterceptor.js +23 -9
  17. package/src/registryProxy/registryProxy.js +15 -7
  18. package/src/registryProxy/tunnelRequestHandler.js +4 -14
  19. package/src/shell-integration/helpers.js +20 -0
  20. package/src/shell-integration/setup-ci.js +3 -9
  21. package/src/shell-integration/setup.js +4 -6
  22. package/src/shell-integration/startup-scripts/init-fish.fish +27 -0
  23. package/src/shell-integration/startup-scripts/init-posix.sh +27 -0
  24. package/src/shell-integration/startup-scripts/init-pwsh.ps1 +30 -1
  25. package/src/shell-integration/teardown.js +43 -1
  26. package/src/shell-integration/startup-scripts/include-python/init-fish.fish +0 -94
  27. package/src/shell-integration/startup-scripts/include-python/init-posix.sh +0 -81
  28. package/src/shell-integration/startup-scripts/include-python/init-pwsh.ps1 +0 -115
@@ -1,81 +0,0 @@
1
- export PATH="$PATH:$HOME/.safe-chain/bin"
2
-
3
- function npx() {
4
- wrapSafeChainCommand "npx" "$@"
5
- }
6
-
7
- function yarn() {
8
- wrapSafeChainCommand "yarn" "$@"
9
- }
10
-
11
- function pnpm() {
12
- wrapSafeChainCommand "pnpm" "$@"
13
- }
14
-
15
- function pnpx() {
16
- wrapSafeChainCommand "pnpx" "$@"
17
- }
18
-
19
- function bun() {
20
- wrapSafeChainCommand "bun" "$@"
21
- }
22
-
23
- function bunx() {
24
- wrapSafeChainCommand "bunx" "$@"
25
- }
26
-
27
- function npm() {
28
- if [[ "$1" == "-v" || "$1" == "--version" ]] && [[ $# -eq 1 ]]; then
29
- # If args is just -v or --version and nothing else, just run the npm version command
30
- # This is because nvm uses this to check the version of npm
31
- command npm "$@"
32
- return
33
- fi
34
-
35
- wrapSafeChainCommand "npm" "$@"
36
- }
37
-
38
-
39
- function pip() {
40
- wrapSafeChainCommand "pip" "$@"
41
- }
42
-
43
- function pip3() {
44
- wrapSafeChainCommand "pip3" "$@"
45
- }
46
-
47
- function uv() {
48
- wrapSafeChainCommand "uv" "$@"
49
- }
50
-
51
- # `python -m pip`, `python -m pip3`.
52
- function python() {
53
- wrapSafeChainCommand "python" "$@"
54
- }
55
-
56
- # `python3 -m pip`, `python3 -m pip3'.
57
- function python3() {
58
- wrapSafeChainCommand "python3" "$@"
59
- }
60
-
61
- function printSafeChainWarning() {
62
- # \033[43;30m is used to set the background color to yellow and text color to black
63
- # \033[0m is used to reset the text formatting
64
- printf "\033[43;30mWarning:\033[0m safe-chain is not available to protect you from installing malware. %s will run without it.\n" "$1"
65
- # \033[36m is used to set the text color to cyan
66
- printf "Install safe-chain by using \033[36mnpm install -g @aikidosec/safe-chain\033[0m.\n"
67
- }
68
-
69
- function wrapSafeChainCommand() {
70
- local original_cmd="$1"
71
-
72
- if command -v safe-chain > /dev/null 2>&1; then
73
- # If the aikido command is available, just run it with the provided arguments
74
- safe-chain "$@"
75
- else
76
- # If the aikido command is not available, print a warning and run the original command
77
- printSafeChainWarning "$original_cmd"
78
-
79
- command "$original_cmd" "$@"
80
- fi
81
- }
@@ -1,115 +0,0 @@
1
- # Use cross-platform path separator (: on Unix, ; on Windows)
2
- $pathSeparator = if ($IsWindows) { ';' } else { ':' }
3
- $safeChainBin = Join-Path (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
-
41
- function pip {
42
- Invoke-WrappedCommand "pip" $args
43
- }
44
-
45
- function pip3 {
46
- Invoke-WrappedCommand "pip3" $args
47
- }
48
-
49
- function uv {
50
- Invoke-WrappedCommand "uv" $args
51
- }
52
-
53
- # `python -m pip`, `python -m pip3`.
54
- function python {
55
- Invoke-WrappedCommand 'python' $args
56
- }
57
-
58
- # `python3 -m pip`, `python3 -m pip3'.
59
- function python3 {
60
- Invoke-WrappedCommand 'python3' $args
61
- }
62
-
63
-
64
- function Write-SafeChainWarning {
65
- param([string]$Command)
66
-
67
- # PowerShell equivalent of ANSI color codes: yellow background, black text for "Warning:"
68
- Write-Host "Warning:" -BackgroundColor Yellow -ForegroundColor Black -NoNewline
69
- Write-Host " safe-chain is not available to protect you from installing malware. $Command will run without it."
70
-
71
- # Cyan text for the install command
72
- Write-Host "Install safe-chain by using " -NoNewline
73
- Write-Host "npm install -g @aikidosec/safe-chain" -ForegroundColor Cyan -NoNewline
74
- Write-Host "."
75
- }
76
-
77
- function Test-CommandAvailable {
78
- param([string]$Command)
79
-
80
- try {
81
- Get-Command $Command -ErrorAction Stop | Out-Null
82
- return $true
83
- }
84
- catch {
85
- return $false
86
- }
87
- }
88
-
89
- function Invoke-RealCommand {
90
- param(
91
- [string]$Command,
92
- [string[]]$Arguments
93
- )
94
-
95
- # Find the real executable to avoid calling our wrapped functions
96
- $realCommand = Get-Command -Name $Command -CommandType Application | Select-Object -First 1
97
- if ($realCommand) {
98
- & $realCommand.Source @Arguments
99
- }
100
- }
101
-
102
- function Invoke-WrappedCommand {
103
- param(
104
- [string]$OriginalCmd,
105
- [string[]]$Arguments
106
- )
107
-
108
- if (Test-CommandAvailable "safe-chain") {
109
- & safe-chain $OriginalCmd @Arguments
110
- }
111
- else {
112
- Write-SafeChainWarning $OriginalCmd
113
- Invoke-RealCommand $OriginalCmd $Arguments
114
- }
115
- }