@aikidosec/safe-chain 0.0.1-custom-install-dir
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 +674 -0
- package/README.md +537 -0
- package/bin/aikido-bun.js +14 -0
- package/bin/aikido-bunx.js +14 -0
- package/bin/aikido-npm.js +14 -0
- package/bin/aikido-npx.js +14 -0
- package/bin/aikido-pip.js +17 -0
- package/bin/aikido-pip3.js +17 -0
- package/bin/aikido-pipx.js +16 -0
- package/bin/aikido-pnpm.js +14 -0
- package/bin/aikido-pnpx.js +14 -0
- package/bin/aikido-poetry.js +13 -0
- package/bin/aikido-python.js +19 -0
- package/bin/aikido-python3.js +19 -0
- package/bin/aikido-uv.js +16 -0
- package/bin/aikido-uvx.js +16 -0
- package/bin/aikido-yarn.js +14 -0
- package/bin/safe-chain.js +147 -0
- package/docs/Release.md +25 -0
- package/docs/banner.svg +151 -0
- package/docs/safe-package-manager-demo.gif +0 -0
- package/docs/safe-package-manager-demo.png +0 -0
- package/docs/shell-integration.md +149 -0
- package/docs/troubleshooting.md +321 -0
- package/npm-shrinkwrap.json +3180 -0
- package/package.json +71 -0
- package/src/api/aikido.js +187 -0
- package/src/api/npmApi.js +71 -0
- package/src/config/cliArguments.js +161 -0
- package/src/config/configFile.js +327 -0
- package/src/config/environmentVariables.js +57 -0
- package/src/config/safeChainDir.js +71 -0
- package/src/config/settings.js +247 -0
- package/src/environment/environment.js +14 -0
- package/src/environment/userInteraction.js +122 -0
- package/src/installLocation.js +42 -0
- package/src/main.js +123 -0
- package/src/packagemanager/_shared/commandErrors.js +17 -0
- package/src/packagemanager/_shared/matchesCommand.js +18 -0
- package/src/packagemanager/bun/createBunPackageManager.js +48 -0
- package/src/packagemanager/currentPackageManager.js +82 -0
- package/src/packagemanager/npm/createPackageManager.js +72 -0
- package/src/packagemanager/npm/dependencyScanner/commandArgumentScanner.js +74 -0
- package/src/packagemanager/npm/dependencyScanner/nullScanner.js +9 -0
- package/src/packagemanager/npm/parsing/parsePackagesFromInstallArgs.js +144 -0
- package/src/packagemanager/npm/runNpmCommand.js +20 -0
- package/src/packagemanager/npm/utils/abbrevs-generated.js +359 -0
- package/src/packagemanager/npm/utils/cmd-list.js +174 -0
- package/src/packagemanager/npm/utils/npmCommands.js +34 -0
- package/src/packagemanager/npx/createPackageManager.js +15 -0
- package/src/packagemanager/npx/dependencyScanner/commandArgumentScanner.js +43 -0
- package/src/packagemanager/npx/parsing/parsePackagesFromArguments.js +130 -0
- package/src/packagemanager/npx/runNpxCommand.js +20 -0
- package/src/packagemanager/pip/createPackageManager.js +25 -0
- package/src/packagemanager/pip/pipSettings.js +6 -0
- package/src/packagemanager/pip/runPipCommand.js +209 -0
- package/src/packagemanager/pipx/createPipXPackageManager.js +18 -0
- package/src/packagemanager/pipx/runPipXCommand.js +60 -0
- package/src/packagemanager/pnpm/createPackageManager.js +57 -0
- package/src/packagemanager/pnpm/dependencyScanner/commandArgumentScanner.js +35 -0
- package/src/packagemanager/pnpm/parsing/parsePackagesFromArguments.js +109 -0
- package/src/packagemanager/pnpm/runPnpmCommand.js +32 -0
- package/src/packagemanager/poetry/createPoetryPackageManager.js +72 -0
- package/src/packagemanager/uv/createUvPackageManager.js +18 -0
- package/src/packagemanager/uv/runUvCommand.js +66 -0
- package/src/packagemanager/uvx/createUvxPackageManager.js +18 -0
- package/src/packagemanager/yarn/createPackageManager.js +41 -0
- package/src/packagemanager/yarn/dependencyScanner/commandArgumentScanner.js +35 -0
- package/src/packagemanager/yarn/parsing/parsePackagesFromArguments.js +128 -0
- package/src/packagemanager/yarn/runYarnCommand.js +36 -0
- package/src/registryProxy/certBundle.js +203 -0
- package/src/registryProxy/certUtils.js +178 -0
- package/src/registryProxy/getConnectTimeout.js +13 -0
- package/src/registryProxy/http-utils.js +80 -0
- package/src/registryProxy/interceptors/createInterceptorForEcoSystem.js +25 -0
- package/src/registryProxy/interceptors/interceptorBuilder.js +179 -0
- package/src/registryProxy/interceptors/minimumPackageAgeExclusions.js +33 -0
- package/src/registryProxy/interceptors/npm/modifyNpmInfo.js +180 -0
- package/src/registryProxy/interceptors/npm/npmInterceptor.js +101 -0
- package/src/registryProxy/interceptors/npm/parseNpmPackageUrl.js +60 -0
- package/src/registryProxy/interceptors/pip/modifyPipInfo.js +167 -0
- package/src/registryProxy/interceptors/pip/modifyPipJsonResponse.js +176 -0
- package/src/registryProxy/interceptors/pip/parsePipPackageUrl.js +162 -0
- package/src/registryProxy/interceptors/pip/pipInterceptor.js +122 -0
- package/src/registryProxy/interceptors/pip/pipMetadataResponseUtils.js +27 -0
- package/src/registryProxy/interceptors/pip/pipMetadataVersionUtils.js +131 -0
- package/src/registryProxy/interceptors/suppressedVersionsState.js +21 -0
- package/src/registryProxy/isImdsEndpoint.js +13 -0
- package/src/registryProxy/mitmRequestHandler.js +240 -0
- package/src/registryProxy/plainHttpProxy.js +95 -0
- package/src/registryProxy/registryProxy.js +255 -0
- package/src/registryProxy/tunnelRequestHandler.js +213 -0
- package/src/scanning/audit/index.js +129 -0
- package/src/scanning/index.js +82 -0
- package/src/scanning/malwareDatabase.js +131 -0
- package/src/scanning/newPackagesDatabaseBuilder.js +71 -0
- package/src/scanning/newPackagesDatabaseWarnings.js +17 -0
- package/src/scanning/newPackagesListCache.js +126 -0
- package/src/scanning/packageNameVariants.js +29 -0
- package/src/shell-integration/helpers.js +296 -0
- package/src/shell-integration/path-wrappers/templates/unix-wrapper.template.sh +37 -0
- package/src/shell-integration/path-wrappers/templates/windows-wrapper.template.cmd +25 -0
- package/src/shell-integration/setup-ci.js +152 -0
- package/src/shell-integration/setup.js +110 -0
- package/src/shell-integration/shellDetection.js +39 -0
- package/src/shell-integration/startup-scripts/init-fish.fish +122 -0
- package/src/shell-integration/startup-scripts/init-posix.sh +112 -0
- package/src/shell-integration/startup-scripts/init-pwsh.ps1 +176 -0
- package/src/shell-integration/supported-shells/bash.js +222 -0
- package/src/shell-integration/supported-shells/fish.js +97 -0
- package/src/shell-integration/supported-shells/powershell.js +102 -0
- package/src/shell-integration/supported-shells/windowsPowershell.js +102 -0
- package/src/shell-integration/supported-shells/zsh.js +94 -0
- package/src/shell-integration/teardown.js +114 -0
- package/src/utils/safeSpawn.js +153 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Shell Integration
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The shell integration automatically wraps common package manager commands (`npm`, `npx`, `yarn`, `pnpm`, `pnpx`, `bun`, `bunx`, `pip`, `pip3`, `uv`, `uvx`, `poetry`, `pipx`) with Aikido's security scanning functionality. It also intercepts Python module invocations for pip when available: `python -m pip`, `python -m pip3`, `python3 -m pip`, `python3 -m pip3`. This is achieved by sourcing startup scripts that define shell functions to wrap these commands with their Aikido-protected equivalents.
|
|
6
|
+
|
|
7
|
+
## Supported Shells
|
|
8
|
+
|
|
9
|
+
Aikido Safe Chain supports integration with the following shells.
|
|
10
|
+
|
|
11
|
+
| Shell | Startup File |
|
|
12
|
+
| ---------------------- | ---------------------------- |
|
|
13
|
+
| **Bash** | `~/.bashrc` |
|
|
14
|
+
| **Zsh** | `~/.zshrc` |
|
|
15
|
+
| **Fish** | `~/.config/fish/config.fish` |
|
|
16
|
+
| **PowerShell Core** | `$PROFILE` |
|
|
17
|
+
| **Windows PowerShell** | `$PROFILE` |
|
|
18
|
+
|
|
19
|
+
## Setup Commands
|
|
20
|
+
|
|
21
|
+
### Setup Shell Integration
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
safe-chain setup
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This command:
|
|
28
|
+
|
|
29
|
+
- Copies necessary startup scripts to Safe Chain's installation directory (`~/.safe-chain/scripts`)
|
|
30
|
+
- Detects all supported shells on your system
|
|
31
|
+
- Sources each shell's startup file to add Safe Chain functions for `npm`, `npx`, `yarn`, `pnpm`, `pnpx`, `bun`, `bunx`, `pip`, `pip3`, `uv`, `uvx`, `poetry` and `pipx`
|
|
32
|
+
- Adds lightweight interceptors so `python -m pip[...]` and `python3 -m pip[...]` route through Safe Chain when invoked by name
|
|
33
|
+
|
|
34
|
+
❗ After running this command, **you must restart your terminal** for the changes to take effect. This ensures that the startup scripts are sourced correctly.
|
|
35
|
+
|
|
36
|
+
### Remove Shell Integration
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
safe-chain teardown
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This command:
|
|
43
|
+
|
|
44
|
+
- Detects all supported shells on your system
|
|
45
|
+
- Removes the Safe Chain scripts from each shell's startup file, restoring the original commands
|
|
46
|
+
|
|
47
|
+
❗ After running this command, **you must restart your terminal** to restore the original commands.
|
|
48
|
+
|
|
49
|
+
## File Locations
|
|
50
|
+
|
|
51
|
+
The system modifies the following files to source Safe Chain startup scripts:
|
|
52
|
+
|
|
53
|
+
### Unix/Linux/macOS
|
|
54
|
+
|
|
55
|
+
- **Bash**: `~/.bashrc`
|
|
56
|
+
- **Zsh**: `~/.zshrc`
|
|
57
|
+
- **Fish**: `~/.config/fish/config.fish`
|
|
58
|
+
- **PowerShell Core**: `$PROFILE` (usually `~/.config/powershell/profile.ps1`)
|
|
59
|
+
|
|
60
|
+
### Windows
|
|
61
|
+
|
|
62
|
+
- **PowerShell**: Determined by `$PROFILE` variable
|
|
63
|
+
- **PowerShell Core**: Also determined by `$PROFILE` variable
|
|
64
|
+
|
|
65
|
+
## Troubleshooting
|
|
66
|
+
|
|
67
|
+
### Common Issues
|
|
68
|
+
|
|
69
|
+
**Shell functions not working after setup:**
|
|
70
|
+
|
|
71
|
+
- Make sure to restart your terminal
|
|
72
|
+
- Check that the startup file was modified to source Safe Chain scripts
|
|
73
|
+
- Check the sourced file exists at `~/.safe-chain/scripts/`
|
|
74
|
+
- Verify your shell is reading the correct startup file
|
|
75
|
+
|
|
76
|
+
**Getting 'command not found: aikido-npm' error:**
|
|
77
|
+
|
|
78
|
+
This means the shell functions are working but the Aikido commands aren't installed or available in your PATH:
|
|
79
|
+
|
|
80
|
+
- Make sure Aikido Safe Chain is properly installed on your system
|
|
81
|
+
- Verify the `aikido-npm`, `aikido-npx`, `aikido-yarn`, `aikido-pnpm`, `aikido-pnpx`, `aikido-bun`, `aikido-bunx`, `aikido-pip`, `aikido-pip3`, `aikido-uv`, `aikido-uvx`, `aikido-poetry` and `aikido-pipx` commands exist
|
|
82
|
+
- Check that these commands are in your system's PATH
|
|
83
|
+
|
|
84
|
+
### Manual Verification
|
|
85
|
+
|
|
86
|
+
To verify the integration is working, follow these steps:
|
|
87
|
+
|
|
88
|
+
1. **Check if startup scripts were sourced in your shell startup file:**
|
|
89
|
+
|
|
90
|
+
- **For Bash**: Open `~/.bashrc` in your text editor
|
|
91
|
+
- **For Zsh**: Open `~/.zshrc` in your text editor
|
|
92
|
+
- **For Fish**: Open `~/.config/fish/config.fish` in your text editor
|
|
93
|
+
- **For PowerShell**: Open your PowerShell profile file (run `$PROFILE` in PowerShell to see the path)
|
|
94
|
+
|
|
95
|
+
Look for lines that source the Safe Chain startup scripts from `~/.safe-chain/scripts/`
|
|
96
|
+
|
|
97
|
+
2. **Test that shell functions are active in your terminal:**
|
|
98
|
+
|
|
99
|
+
After restarting your terminal, run these commands:
|
|
100
|
+
|
|
101
|
+
- `npm --version` - Should show output from the Aikido-wrapped version
|
|
102
|
+
- `type npm` - Should show that `npm` is a function
|
|
103
|
+
|
|
104
|
+
3. **If you need to remove the integration manually:**
|
|
105
|
+
|
|
106
|
+
Edit the same startup file from step 1 and delete any lines that source Safe Chain scripts from `~/.safe-chain/scripts/`.
|
|
107
|
+
|
|
108
|
+
## Manual Setup
|
|
109
|
+
|
|
110
|
+
For advanced users who prefer manual configuration, you can create wrapper functions directly in your shell's startup file. Shell functions take precedence over commands in PATH, so defining an `npm` function will intercept all `npm` calls:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Example for Bash/Zsh
|
|
114
|
+
npm() {
|
|
115
|
+
if command -v aikido-npm > /dev/null 2>&1; then
|
|
116
|
+
aikido-npm "$@"
|
|
117
|
+
else
|
|
118
|
+
echo "Warning: safe-chain is not installed. npm will run without protection."
|
|
119
|
+
command npm "$@"
|
|
120
|
+
fi
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Repeat this pattern for `npx`, `yarn`, `pnpm`, `pnpx`, `bun`, `bunx`, `pip`, `pip3`, `uv`, `uvx`, `poetry` and `pipx` using their respective `aikido-*` commands. After adding these functions, restart your terminal to apply the changes.
|
|
125
|
+
|
|
126
|
+
To intercept Python module invocations for pip without altering Python itself, you can add small forwarding functions:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Example for Bash/Zsh
|
|
130
|
+
python() {
|
|
131
|
+
if [[ "$1" == "-m" && "$2" == pip* ]]; then
|
|
132
|
+
local mod="$2"; shift 2
|
|
133
|
+
if [[ "$mod" == "pip3" ]]; then aikido-pip3 "$@"; else aikido-pip "$@"; fi
|
|
134
|
+
else
|
|
135
|
+
command python "$@"
|
|
136
|
+
fi
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
python3() {
|
|
140
|
+
if [[ "$1" == "-m" && "$2" == pip* ]]; then
|
|
141
|
+
local mod="$2"; shift 2
|
|
142
|
+
if [[ "$mod" == "pip3" ]]; then aikido-pip3 "$@"; else aikido-pip "$@"; fi
|
|
143
|
+
else
|
|
144
|
+
command python3 "$@"
|
|
145
|
+
fi
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Limitations: these only apply when invoking `python`/`python3` by name. Absolute paths (e.g., `/usr/bin/python -m pip`) bypass shell functions.
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
This guide helps you diagnose and resolve common issues with Aikido Safe Chain.
|
|
4
|
+
|
|
5
|
+
## Verification & Diagnostics
|
|
6
|
+
|
|
7
|
+
### Check Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Check version
|
|
11
|
+
safe-chain --version
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Verify Shell Integration
|
|
15
|
+
|
|
16
|
+
Run the verification command for your package manager:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm safe-chain-verify
|
|
20
|
+
pnpm safe-chain-verify
|
|
21
|
+
pip safe-chain-verify
|
|
22
|
+
uv safe-chain-verify
|
|
23
|
+
|
|
24
|
+
# Any other supported package manager: {packagemanager} safe-chain-verify
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Expected output: `OK: Safe-chain works!`
|
|
28
|
+
|
|
29
|
+
### Test Malware Blocking
|
|
30
|
+
|
|
31
|
+
Verify that malware detection is working:
|
|
32
|
+
|
|
33
|
+
**For JavaScript/Node.js:**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install safe-chain-test
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**For Python:**
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip3 install safe-chain-pi-test
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
These test packages are flagged as malware and should be blocked by Safe Chain.
|
|
46
|
+
|
|
47
|
+
**If the test package installs successfully instead of being blocked**, see [Malware Not Being Blocked](#malware-not-being-blocked) below.
|
|
48
|
+
|
|
49
|
+
### Logging Options
|
|
50
|
+
|
|
51
|
+
Use logging flags or environment variables to get more information:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Verbose mode - detailed diagnostic output for troubleshooting
|
|
55
|
+
npm install express --safe-chain-logging=verbose
|
|
56
|
+
|
|
57
|
+
# Or set it globally for all commands in your session
|
|
58
|
+
export SAFE_CHAIN_LOGGING=verbose
|
|
59
|
+
npm install express
|
|
60
|
+
|
|
61
|
+
# Silent mode - suppress all output except malware blocking
|
|
62
|
+
npm install express --safe-chain-logging=silent
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Common Issues
|
|
66
|
+
|
|
67
|
+
### Malware Not Being Blocked
|
|
68
|
+
|
|
69
|
+
**Symptom:** Test malware packages (like `safe-chain-test`) install successfully when they should be blocked
|
|
70
|
+
|
|
71
|
+
**Most Common Cause:** The package is cached in your package manager's local store
|
|
72
|
+
|
|
73
|
+
Safe-chain blocks malicious packages by intercepting network requests to package registries using its proxy.
|
|
74
|
+
|
|
75
|
+
When a package is already cached locally, the package manager skips downloading it from the registry, which bypasses the proxy.
|
|
76
|
+
|
|
77
|
+
**Resolution Steps:**
|
|
78
|
+
|
|
79
|
+
1. **Clear your package manager's cache:**
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# For npm
|
|
83
|
+
npm cache clean --force
|
|
84
|
+
|
|
85
|
+
# For pnpm
|
|
86
|
+
pnpm store prune
|
|
87
|
+
|
|
88
|
+
# For yarn (classic)
|
|
89
|
+
yarn cache clean
|
|
90
|
+
|
|
91
|
+
# For yarn (berry/v2+)
|
|
92
|
+
yarn cache clean --all
|
|
93
|
+
|
|
94
|
+
# For bun
|
|
95
|
+
bun pm cache rm
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
> **⚠️ Warning:** Cache clearing is safe but will remove all cached packages. Subsequent installations will need to re-download packages. In CI/CD environments or monorepos, this may affect build times.
|
|
99
|
+
|
|
100
|
+
2. **Clean local installation artifacts:**
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Remove node_modules if you want a completely fresh install
|
|
104
|
+
rm -rf node_modules
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
3. **Re-test malware blocking:**
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npm install safe-chain-test # Should be blocked
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Shell Aliases Not Working After Installation
|
|
114
|
+
|
|
115
|
+
**Symptom:** Running `npm` shows regular npm instead of safe-chain wrapped version
|
|
116
|
+
|
|
117
|
+
**First step:** Restart your terminal (most common fix)
|
|
118
|
+
|
|
119
|
+
**Verify it's working:**
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
type npm
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Should show: `npm is a function`
|
|
126
|
+
|
|
127
|
+
**If still not working:**
|
|
128
|
+
|
|
129
|
+
Check that your startup file sources safe-chain scripts from `~/.safe-chain/scripts/`:
|
|
130
|
+
|
|
131
|
+
- Bash: `~/.bashrc`
|
|
132
|
+
- Zsh: `~/.zshrc`
|
|
133
|
+
- Fish: `~/.config/fish/config.fish`
|
|
134
|
+
- PowerShell: `$PROFILE`
|
|
135
|
+
|
|
136
|
+
### "Command Not Found: safe-chain"
|
|
137
|
+
|
|
138
|
+
**Symptom:** Binary not found in PATH
|
|
139
|
+
|
|
140
|
+
**First step:** Restart your terminal
|
|
141
|
+
|
|
142
|
+
**Check PATH:**
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
echo $PATH
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Should include `~/.safe-chain/bin`
|
|
149
|
+
|
|
150
|
+
**If persists:** Re-run the installation script
|
|
151
|
+
|
|
152
|
+
### PowerShell Execution Policy Blocks Scripts (Windows)
|
|
153
|
+
|
|
154
|
+
**Symptom:** When opening PowerShell, you see an error like:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
. : File C:\Users\<username>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because
|
|
158
|
+
running scripts is disabled on this system.
|
|
159
|
+
CategoryInfo : SecurityError: (:) [], PSSecurityException
|
|
160
|
+
FullyQualifiedErrorId : UnauthorizedAccess
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Cause:** Windows PowerShell's default execution policy (`Restricted`) blocks all script execution, including safe-chain's initialization script that's sourced from your PowerShell profile.
|
|
164
|
+
|
|
165
|
+
**Resolution:**
|
|
166
|
+
|
|
167
|
+
1. **Set the execution policy to allow local scripts:**
|
|
168
|
+
|
|
169
|
+
Open PowerShell as Administrator and run:
|
|
170
|
+
|
|
171
|
+
```powershell
|
|
172
|
+
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
This allows:
|
|
176
|
+
- Local scripts (like safe-chain's) to run without signing
|
|
177
|
+
- Downloaded scripts to run only if signed by a trusted publisher
|
|
178
|
+
|
|
179
|
+
2. **Restart PowerShell** and verify the error is resolved.
|
|
180
|
+
|
|
181
|
+
> **Note:** `RemoteSigned` is Microsoft's recommended execution policy for client computers. It provides a good balance between security and usability.
|
|
182
|
+
|
|
183
|
+
### Shell Aliases Persist After Uninstallation
|
|
184
|
+
|
|
185
|
+
**Symptom:** safe-chain commands still active after running uninstall script
|
|
186
|
+
|
|
187
|
+
**Steps:**
|
|
188
|
+
|
|
189
|
+
1. Run `safe-chain teardown` (if binary still exists)
|
|
190
|
+
2. Restart your terminal
|
|
191
|
+
3. If still present, manually edit shell config files:
|
|
192
|
+
- Bash: `~/.bashrc`
|
|
193
|
+
- Zsh: `~/.zshrc`
|
|
194
|
+
- Fish: `~/.config/fish/config.fish`
|
|
195
|
+
- PowerShell: `$PROFILE`
|
|
196
|
+
4. Remove lines that source scripts from `~/.safe-chain/scripts/`
|
|
197
|
+
5. Restart terminal again
|
|
198
|
+
|
|
199
|
+
## Manual Verification Steps
|
|
200
|
+
|
|
201
|
+
### Check Installation Status
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Check installation location (helps identify if installed via npm or as standalone binary)
|
|
205
|
+
which safe-chain
|
|
206
|
+
|
|
207
|
+
# Verify binary exists
|
|
208
|
+
ls ~/.safe-chain/bin/safe-chain
|
|
209
|
+
|
|
210
|
+
# Check version
|
|
211
|
+
safe-chain --version
|
|
212
|
+
|
|
213
|
+
# Test shell integration
|
|
214
|
+
type npm
|
|
215
|
+
type pip
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Expected `which` output:**
|
|
219
|
+
|
|
220
|
+
- Standalone binary (correct): `~/.safe-chain/bin/safe-chain` or `/Users/<username>/.safe-chain/bin/safe-chain`
|
|
221
|
+
- npm global (outdated): path containing `node_modules` or nvm version paths
|
|
222
|
+
|
|
223
|
+
If `which` shows an npm installation, see [Check for Conflicting Installations](#check-for-conflicting-installations).
|
|
224
|
+
|
|
225
|
+
### Check Shell Integration
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Which shell you're using
|
|
229
|
+
echo $SHELL
|
|
230
|
+
|
|
231
|
+
# Check if startup file sources safe-chain
|
|
232
|
+
# For Bash:
|
|
233
|
+
grep safe-chain ~/.bashrc
|
|
234
|
+
|
|
235
|
+
# For Zsh:
|
|
236
|
+
grep safe-chain ~/.zshrc
|
|
237
|
+
|
|
238
|
+
# For Fish:
|
|
239
|
+
grep safe-chain ~/.config/fish/config.fish
|
|
240
|
+
|
|
241
|
+
# Verify scripts exist
|
|
242
|
+
ls ~/.safe-chain/scripts/
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Check for Conflicting Installations
|
|
246
|
+
|
|
247
|
+
> **Note:** The install/uninstall scripts automatically detect and remove conflicting installations, but you can manually check:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Check npm global
|
|
251
|
+
npm list -g @aikidosec/safe-chain
|
|
252
|
+
|
|
253
|
+
# Check Volta
|
|
254
|
+
volta list safe-chain
|
|
255
|
+
|
|
256
|
+
# Check nvm (all versions)
|
|
257
|
+
for version in $(nvm list | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+'); do
|
|
258
|
+
nvm exec "$version" npm list -g @aikidosec/safe-chain 2>/dev/null && echo "Found in $version"
|
|
259
|
+
done
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Manual Cleanup
|
|
263
|
+
|
|
264
|
+
> **Note:** The install and uninstall scripts automatically handle these cleanup steps. Use these manual commands only if automatic cleanup fails.
|
|
265
|
+
|
|
266
|
+
### Remove npm Global Installation
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
npm uninstall -g @aikidosec/safe-chain
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Remove Volta Installation
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
volta uninstall @aikidosec/safe-chain
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Remove nvm Installations (All Versions)
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
# Automated approach
|
|
282
|
+
for version in $(nvm list | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+'); do
|
|
283
|
+
nvm exec "$version" npm uninstall -g @aikidosec/safe-chain
|
|
284
|
+
done
|
|
285
|
+
|
|
286
|
+
# Or manual per version
|
|
287
|
+
nvm use <version>
|
|
288
|
+
npm uninstall -g @aikidosec/safe-chain
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Clean Shell Configuration Files
|
|
292
|
+
|
|
293
|
+
Manually remove safe-chain entries from:
|
|
294
|
+
|
|
295
|
+
- Bash: `~/.bashrc`
|
|
296
|
+
- Zsh: `~/.zshrc`
|
|
297
|
+
- Fish: `~/.config/fish/config.fish`
|
|
298
|
+
- PowerShell: `$PROFILE`
|
|
299
|
+
|
|
300
|
+
Look for and remove:
|
|
301
|
+
|
|
302
|
+
- Lines sourcing from `~/.safe-chain/scripts/`
|
|
303
|
+
- Any safe-chain related function definitions
|
|
304
|
+
|
|
305
|
+
### Remove Installation Directory
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
rm -rf ~/.safe-chain
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Report Issues
|
|
312
|
+
|
|
313
|
+
If you encounter problems:
|
|
314
|
+
|
|
315
|
+
1. Visit [GitHub Issues](https://github.com/AikidoSec/safe-chain/issues)
|
|
316
|
+
2. Include:
|
|
317
|
+
- Operating system and version
|
|
318
|
+
- Shell type and version
|
|
319
|
+
- `safe-chain --version` output
|
|
320
|
+
- Output from verification commands
|
|
321
|
+
- Verbose logs of the failing command (add the `--safe-chain-logging=verbose` argument)
|