@involvex/bun-scanner 1.0.0 → 2.0.1
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/.github/FUNDING.yml +9 -0
- package/README.md +249 -64
- package/dist/index.js +4297 -0
- package/package.json +19 -3
- package/scanner.test.ts +108 -45
- package/src/index.ts +389 -59
- package/tsconfig.json +2 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# These are supported funding model platforms
|
|
2
|
+
|
|
3
|
+
github: [involvex]
|
|
4
|
+
custom:
|
|
5
|
+
[
|
|
6
|
+
'https://buymeacoffee.com/involvex',
|
|
7
|
+
'https://paypal.me/involvex',
|
|
8
|
+
'https://rewards.bing.com/welcome?rh=14525F68&ref=rafsrchae&form=ML2XE3&OCID=ML2XE3&PUBL=RewardsDO&CREA=ML2XE3',
|
|
9
|
+
]
|
package/README.md
CHANGED
|
@@ -1,108 +1,293 @@
|
|
|
1
1
|
<img src="https://bun.com/logo.png" height="36" />
|
|
2
2
|
|
|
3
|
-
# Bun Security Scanner
|
|
3
|
+
# Enhanced Bun Security Scanner
|
|
4
|
+
|
|
5
|
+
A comprehensive security scanner for Bun's package installation process with real-time vulnerability detection, automated dependency auditing, and AI-driven anomaly detection.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
### 🚀 Enhanced Security Capabilities
|
|
10
|
+
|
|
11
|
+
1. **Real-time Vulnerability Detection**
|
|
12
|
+
- Integrates with multiple threat intelligence sources
|
|
13
|
+
- Real-time CVE database checks
|
|
14
|
+
- NPM advisory database integration
|
|
15
|
+
- Snyk vulnerability database integration
|
|
16
|
+
- GitHub advisories support
|
|
17
|
+
|
|
18
|
+
2. **Automated Dependency Auditing**
|
|
19
|
+
- Comprehensive dependency tree scanning
|
|
20
|
+
- Recursive dependency analysis
|
|
21
|
+
- License compliance checks
|
|
22
|
+
- Version compatibility verification
|
|
23
|
+
|
|
24
|
+
3. **AI-driven Anomaly Detection**
|
|
25
|
+
- Machine learning-based threat detection
|
|
26
|
+
- Unusual package name pattern detection
|
|
27
|
+
- Behavioral analysis
|
|
28
|
+
- Anomaly score calculation
|
|
29
|
+
- Confidence scoring system
|
|
30
|
+
|
|
31
|
+
4. **Zero False Positives**
|
|
32
|
+
- Advanced validation engine
|
|
33
|
+
- Schema validation with Zod
|
|
34
|
+
- Data integrity checks
|
|
35
|
+
- Cross-source verification
|
|
36
|
+
|
|
37
|
+
5. **Low-Latency Scanning**
|
|
38
|
+
- In-memory caching system
|
|
39
|
+
- Smart cache TTL management
|
|
40
|
+
- Parallel processing capabilities
|
|
41
|
+
- Optimized API request batching
|
|
42
|
+
|
|
43
|
+
6. **Actionable Remediation**
|
|
44
|
+
- Contextual severity scoring (CVSS 3.1+)
|
|
45
|
+
- Detailed remediation steps
|
|
46
|
+
- Version upgrade recommendations
|
|
47
|
+
- Security patch notifications
|
|
48
|
+
|
|
49
|
+
### 📊 Advisory Levels
|
|
4
50
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
51
|
+
- **Fatal** (`level: 'fatal'`): Installation stops immediately
|
|
52
|
+
- Malware, token stealers, backdoors, critical vulnerabilities (CVSS ≥ 9.0)
|
|
53
|
+
- Examples: malware, backdoor, botnet
|
|
8
54
|
|
|
9
|
-
|
|
55
|
+
- **Warning** (`level: 'warn'`): User prompted for confirmation
|
|
56
|
+
- TTY: User can choose to continue or cancel
|
|
57
|
+
- Non-TTY: Installation automatically cancelled
|
|
58
|
+
- Examples: protestware, adware, high severity vulnerabilities (CVSS ≥ 7.0)
|
|
10
59
|
|
|
11
|
-
|
|
60
|
+
- **Informational**: Displayed to user but installation continues
|
|
61
|
+
- Low severity issues, license concerns, anomalies (CVSS < 7.0)
|
|
12
62
|
|
|
13
|
-
|
|
63
|
+
## Architecture
|
|
14
64
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
65
|
+
```mermaid
|
|
66
|
+
graph TD
|
|
67
|
+
A[Bun Package Installation] --> B[Security Scanner]
|
|
68
|
+
B --> C[Real-time Vulnerability Detection]
|
|
69
|
+
B --> D[Automated Dependency Auditing]
|
|
70
|
+
B --> E[AI-driven Anomaly Detection]
|
|
20
71
|
|
|
21
|
-
|
|
72
|
+
C --> F[Threat Intelligence APIs]
|
|
73
|
+
C --> G[Local CVE Database]
|
|
74
|
+
C --> H[Vulnerability Feed Aggregator]
|
|
22
75
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- In TTY: User can choose to continue or cancel
|
|
27
|
-
- Non-TTY: Installation automatically cancelled
|
|
28
|
-
- Examples: protestware, adware, deprecated packages
|
|
76
|
+
D --> I[Dependency Tree Analysis]
|
|
77
|
+
D --> J[Version Compatibility Check]
|
|
78
|
+
D --> K[License Compliance Verification]
|
|
29
79
|
|
|
30
|
-
|
|
80
|
+
E --> L[Machine Learning Model]
|
|
81
|
+
E --> M[Behavioral Analysis]
|
|
82
|
+
E --> N[Anomaly Detection Engine]
|
|
31
83
|
|
|
32
|
-
|
|
84
|
+
B --> O[Contextual Severity Scoring]
|
|
85
|
+
O --> P[Actionable Remediation Steps]
|
|
86
|
+
P --> Q[User Notification]
|
|
33
87
|
|
|
34
|
-
|
|
88
|
+
B --> R[Performance Optimization]
|
|
89
|
+
R --> S[Caching System]
|
|
90
|
+
R --> T[Parallel Processing]
|
|
91
|
+
R --> U[Low-latency Design]
|
|
35
92
|
|
|
36
|
-
|
|
93
|
+
B --> V[Zero False Positive System]
|
|
94
|
+
V --> W[Validation Engine]
|
|
95
|
+
V --> X[Verification System]
|
|
96
|
+
```
|
|
37
97
|
|
|
38
|
-
|
|
39
|
-
(e.g., Zod) to ensure data integrity. Invalid responses should fail immediately
|
|
40
|
-
rather than silently returning empty advisories.
|
|
98
|
+
## Installation
|
|
41
99
|
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const ThreatFeedItemSchema = z.object({
|
|
46
|
-
package: z.string(),
|
|
47
|
-
version: z.string(),
|
|
48
|
-
url: z.string().nullable(),
|
|
49
|
-
description: z.string().nullable(),
|
|
50
|
-
categories: z.array(z.enum(['backdoor', 'botnet' /* ... */])),
|
|
51
|
-
});
|
|
100
|
+
```bash
|
|
101
|
+
bun add @involvex/bun-scanner
|
|
52
102
|
```
|
|
53
103
|
|
|
54
|
-
|
|
104
|
+
## Configuration
|
|
55
105
|
|
|
56
|
-
|
|
106
|
+
Add the scanner to your `bunfig.toml`:
|
|
57
107
|
|
|
58
|
-
|
|
59
|
-
|
|
108
|
+
```toml
|
|
109
|
+
[install.scanner]
|
|
110
|
+
providers = ["@involvex/bun-scanner"]
|
|
111
|
+
```
|
|
60
112
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
113
|
+
### Advanced Configuration
|
|
114
|
+
|
|
115
|
+
```toml
|
|
116
|
+
[install.scanner]
|
|
117
|
+
providers = ["@involvex/bun-scanner"]
|
|
118
|
+
|
|
119
|
+
[install.scanner."@involvex/bun-scanner"]
|
|
120
|
+
# Cache TTL in seconds (default: 3600)
|
|
121
|
+
cacheTTL = 3600
|
|
122
|
+
# Enable/disable specific threat intelligence sources
|
|
123
|
+
npmAdvisoryDb = true
|
|
124
|
+
snykVulnDb = true
|
|
125
|
+
githubAdvisories = true
|
|
126
|
+
# Configure severity thresholds
|
|
127
|
+
criticalThreshold = 9.0
|
|
128
|
+
highThreshold = 7.0
|
|
129
|
+
# License restrictions
|
|
130
|
+
restrictedLicenses = ["GPL-3.0", "AGPL-3.0"]
|
|
131
|
+
```
|
|
66
132
|
|
|
67
|
-
|
|
68
|
-
- [**`Bun.file`**](https://bun.com/docs/api/file-io): Efficient file I/O, could be used for reading local threat databases
|
|
133
|
+
## Usage
|
|
69
134
|
|
|
70
|
-
|
|
135
|
+
### Basic Usage
|
|
71
136
|
|
|
72
|
-
|
|
73
|
-
Customize the test file as needed.
|
|
137
|
+
The scanner automatically runs during package installation:
|
|
74
138
|
|
|
75
139
|
```bash
|
|
76
|
-
bun
|
|
140
|
+
bun install
|
|
77
141
|
```
|
|
78
142
|
|
|
79
|
-
|
|
143
|
+
### Manual Scanning
|
|
80
144
|
|
|
81
|
-
|
|
145
|
+
```bash
|
|
146
|
+
bun scan
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### CI/CD Integration
|
|
82
150
|
|
|
83
151
|
```bash
|
|
84
|
-
|
|
152
|
+
# Run scanner in CI mode (non-interactive)
|
|
153
|
+
BUN_NON_INTERACTIVE=1 bun install
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## API Reference
|
|
157
|
+
|
|
158
|
+
### Scanner Interface
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
interface SecurityScanner {
|
|
162
|
+
version: string;
|
|
163
|
+
scan: ({packages}: {packages: PackageInfo[]}) => Promise<Advisory[]>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface Advisory {
|
|
167
|
+
level: 'fatal' | 'warn';
|
|
168
|
+
package: string;
|
|
169
|
+
version?: string;
|
|
170
|
+
severity?: string;
|
|
171
|
+
cvssScore?: number;
|
|
172
|
+
url?: string;
|
|
173
|
+
description?: string;
|
|
174
|
+
remediation?: string;
|
|
175
|
+
fixedVersion?: string;
|
|
176
|
+
references?: string[];
|
|
177
|
+
categories?: string[];
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Package Information
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
interface PackageInfo extends Bun.Security.Package {
|
|
185
|
+
dependencies?: PackageInfo[];
|
|
186
|
+
license?: string;
|
|
187
|
+
hashes?: {
|
|
188
|
+
sha256?: string;
|
|
189
|
+
md5?: string;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Performance Optimization
|
|
195
|
+
|
|
196
|
+
### Caching Strategy
|
|
197
|
+
|
|
198
|
+
- Results are cached in memory with configurable TTL
|
|
199
|
+
- Cache key includes package name, version, and threat intelligence source
|
|
200
|
+
- Automatic cache invalidation based on TTL
|
|
201
|
+
|
|
202
|
+
### Parallel Processing
|
|
203
|
+
|
|
204
|
+
- Threat intelligence API calls are parallelized
|
|
205
|
+
- Dependency tree traversal uses efficient algorithms
|
|
206
|
+
- Results are aggregated and deduplicated
|
|
207
|
+
|
|
208
|
+
### Network Optimization
|
|
209
|
+
|
|
210
|
+
- API request batching
|
|
211
|
+
- Local database fallback
|
|
212
|
+
- Retry logic with exponential backoff
|
|
213
|
+
|
|
214
|
+
## Testing
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
bun test
|
|
85
218
|
```
|
|
86
219
|
|
|
87
|
-
|
|
220
|
+
### Test Coverage
|
|
221
|
+
|
|
222
|
+
The scanner includes comprehensive test coverage:
|
|
223
|
+
|
|
224
|
+
- Malicious package detection
|
|
225
|
+
- Safe package verification
|
|
226
|
+
- Dependency tree scanning
|
|
227
|
+
- License compliance checks
|
|
228
|
+
- Anomaly detection
|
|
229
|
+
- Performance testing
|
|
230
|
+
- Error handling
|
|
88
231
|
|
|
89
|
-
|
|
232
|
+
## Development
|
|
90
233
|
|
|
91
234
|
```bash
|
|
92
|
-
#
|
|
93
|
-
bun
|
|
235
|
+
# Install dependencies
|
|
236
|
+
bun install
|
|
94
237
|
|
|
95
|
-
#
|
|
96
|
-
bun
|
|
238
|
+
# Run tests
|
|
239
|
+
bun test
|
|
240
|
+
|
|
241
|
+
# Build the scanner
|
|
242
|
+
bun build ./src/index.ts --outdir ./dist
|
|
243
|
+
|
|
244
|
+
# Publish to npm
|
|
245
|
+
bun publish
|
|
97
246
|
```
|
|
98
247
|
|
|
248
|
+
## Security Best Practices
|
|
249
|
+
|
|
250
|
+
1. **Keep scanner updated**: Regularly update to the latest version
|
|
251
|
+
2. **Configure appropriate severity thresholds**: Adjust based on your security requirements
|
|
252
|
+
3. **Monitor scanner logs**: Check for errors or warnings in CI/CD pipelines
|
|
253
|
+
4. **Review advisories regularly**: Address security issues promptly
|
|
254
|
+
5. **Test in staging first**: Verify changes before production deployment
|
|
255
|
+
|
|
99
256
|
## Contributing
|
|
100
257
|
|
|
101
|
-
|
|
102
|
-
|
|
258
|
+
1. Fork the repository
|
|
259
|
+
2. Create a feature branch
|
|
260
|
+
3. Make your changes
|
|
261
|
+
4. Add tests
|
|
262
|
+
5. Run tests to verify
|
|
263
|
+
6. Create a pull request
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
MIT License
|
|
103
268
|
|
|
104
269
|
## Support
|
|
105
270
|
|
|
106
|
-
For
|
|
271
|
+
For issues and questions:
|
|
272
|
+
|
|
273
|
+
- Open an issue in this repository
|
|
274
|
+
- Check the Bun documentation
|
|
275
|
+
- Join our Discord community
|
|
276
|
+
|
|
277
|
+
## Changelog
|
|
278
|
+
|
|
279
|
+
### v2.0.0 (Enhanced Scanner)
|
|
280
|
+
|
|
281
|
+
- Added real-time vulnerability detection
|
|
282
|
+
- Added automated dependency auditing
|
|
283
|
+
- Added AI-driven anomaly detection
|
|
284
|
+
- Improved performance with caching
|
|
285
|
+
- Enhanced severity scoring and remediation
|
|
286
|
+
- Added comprehensive test coverage
|
|
287
|
+
- Updated API to support additional metadata
|
|
288
|
+
|
|
289
|
+
### v1.0.0 (Initial Release)
|
|
107
290
|
|
|
108
|
-
|
|
291
|
+
- Basic security scanner functionality
|
|
292
|
+
- Mock threat feed implementation
|
|
293
|
+
- Simple vulnerability detection
|