devrail 0.1.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/LICENSE +21 -0
- package/README.md +273 -0
- package/dist/chunk-J22FFU7Z.js +575 -0
- package/dist/chunk-J22FFU7Z.js.map +1 -0
- package/dist/chunk-ZDEEHXE7.js +1298 -0
- package/dist/chunk-ZDEEHXE7.js.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1346 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +312 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/rules-XIWD4KI4.js +17 -0
- package/dist/rules-XIWD4KI4.js.map +1 -0
- package/package.json +88 -0
- package/templates/github-actions/vibeguard.yml +102 -0
- package/templates/gitlab-ci/vibeguard.yml +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Devrail Team
|
|
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,273 @@
|
|
|
1
|
+
# Devrail 🛤️
|
|
2
|
+
|
|
3
|
+
**Security & Quality Guardrails** — Adoption-first developer discipline
|
|
4
|
+
|
|
5
|
+
Stop fighting your team about guidelines. **Devrail blocks mistakes automatically** and lets you adopt security incrementally with baseline + diff-only mode.
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
devrail:
|
|
9
|
+
preset: "node-api" # Auto-detected!
|
|
10
|
+
level: "standard"
|
|
11
|
+
baseline: ".devrail/baseline.json" # Accept existing, block new
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick Start (3 minutes)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Install
|
|
18
|
+
npm install -g devrail
|
|
19
|
+
|
|
20
|
+
# Initialize - auto-detects your stack!
|
|
21
|
+
npx devrail init
|
|
22
|
+
|
|
23
|
+
# See what's wrong
|
|
24
|
+
npx devrail check
|
|
25
|
+
|
|
26
|
+
# Fix safe issues automatically
|
|
27
|
+
npx devrail fix
|
|
28
|
+
|
|
29
|
+
# Accept existing issues, block only NEW ones
|
|
30
|
+
npx devrail baseline
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Why Devrail?
|
|
34
|
+
|
|
35
|
+
**The problem**: Vibecoding is fun until you ship secrets to GitHub, forget input validation, or deploy with 47 critical vulnerabilities.
|
|
36
|
+
|
|
37
|
+
**The solution**: Opinionated guardrails that:
|
|
38
|
+
- ✅ Block secrets in code (gitleaks)
|
|
39
|
+
- ✅ Block vulnerable dependencies (osv-scanner)
|
|
40
|
+
- ✅ Block dangerous patterns (semgrep)
|
|
41
|
+
- ✅ Enforce tests & coverage
|
|
42
|
+
- ✅ Generate CI pipelines automatically
|
|
43
|
+
|
|
44
|
+
## Presets
|
|
45
|
+
|
|
46
|
+
| Preset | Description |
|
|
47
|
+
|--------|-------------|
|
|
48
|
+
| `node-api` | Express, Fastify, Koa backends |
|
|
49
|
+
| `nextjs-app` | Next.js full-stack apps |
|
|
50
|
+
| `python-api` | FastAPI, Flask, Django (coming soon) |
|
|
51
|
+
| `cli-tool` | CLI applications |
|
|
52
|
+
| `library` | npm/PyPI packages |
|
|
53
|
+
| `monorepo` | Multi-package repositories |
|
|
54
|
+
|
|
55
|
+
## Levels
|
|
56
|
+
|
|
57
|
+
| Level | Description |
|
|
58
|
+
|-------|-------------|
|
|
59
|
+
| `basic` | Low friction, maximum adoption. Only critical issues. |
|
|
60
|
+
| `standard` | Recommended default. Balanced security + quality. |
|
|
61
|
+
| `strict` | Hard blocking. For mature teams. |
|
|
62
|
+
|
|
63
|
+
## CLI Commands
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
devrail init # Auto-detect stack, bootstrap config
|
|
67
|
+
devrail check # Fast local check
|
|
68
|
+
devrail check --changed # Only check changed files (PR mode)
|
|
69
|
+
devrail ci # Full CI check (blocking)
|
|
70
|
+
devrail fix # Apply safe automatic fixes
|
|
71
|
+
devrail fix --all # Include fixes that need review
|
|
72
|
+
devrail baseline # Accept existing issues
|
|
73
|
+
devrail baseline --update # Update baseline with current state
|
|
74
|
+
devrail explain <rule> # Explain a rule + how to fix
|
|
75
|
+
devrail rules # List all rules
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Rules (30 MVP)
|
|
79
|
+
|
|
80
|
+
### Secrets
|
|
81
|
+
- `secrets.no-plaintext` — Detect hardcoded secrets
|
|
82
|
+
- `secrets.no-env-commit` — Block .env files in git
|
|
83
|
+
- `secrets.gitignore-required` — Ensure proper .gitignore
|
|
84
|
+
|
|
85
|
+
### Dependencies
|
|
86
|
+
- `deps.lockfile.required` — Require lockfile
|
|
87
|
+
- `deps.no-unpinned` — Warn about ^, ~, * versions
|
|
88
|
+
- `deps.no-git-deps` — Block git:// dependencies
|
|
89
|
+
- `deps.no-vulnerable` — Scan for CVEs
|
|
90
|
+
- `deps.no-typosquatting` — Detect malicious packages
|
|
91
|
+
- `deps.license-check` — Check license compatibility
|
|
92
|
+
|
|
93
|
+
### Security
|
|
94
|
+
- `security.headers.required` — Require security headers
|
|
95
|
+
- `security.cors.safe-default` — Block `origin: *`
|
|
96
|
+
- `security.no-eval` — Block eval/Function
|
|
97
|
+
- `security.no-unsafe-regex` — Detect ReDoS patterns
|
|
98
|
+
- `security.no-prototype-pollution` — Block prototype pollution
|
|
99
|
+
|
|
100
|
+
### Auth
|
|
101
|
+
- `auth.no-weak-jwt` — Block weak JWT configs
|
|
102
|
+
- `auth.no-hardcoded-credentials` — Block hardcoded creds
|
|
103
|
+
- `auth.session-secure` — Require secure cookies
|
|
104
|
+
|
|
105
|
+
### API
|
|
106
|
+
- `api.validation.required` — Require input validation
|
|
107
|
+
- `api.rate-limiting` — Require rate limiting
|
|
108
|
+
- `api.no-sensitive-logging` — Block PII in logs
|
|
109
|
+
|
|
110
|
+
### SQL
|
|
111
|
+
- `sql.no-string-concat` — Block SQL injection patterns
|
|
112
|
+
- `sql.no-raw-queries` — Prefer ORM
|
|
113
|
+
|
|
114
|
+
### Tests
|
|
115
|
+
- `tests.unit.required` — Require test files
|
|
116
|
+
- `tests.coverage.min-50` — 50% coverage minimum
|
|
117
|
+
- `tests.coverage.min-80` — 80% coverage (strict)
|
|
118
|
+
- `tests.no-skipped` — Block .skip()/.only()
|
|
119
|
+
|
|
120
|
+
### Logging
|
|
121
|
+
- `logging.no-pii` — Block PII in logs
|
|
122
|
+
- `logging.no-console` — Use proper logger
|
|
123
|
+
|
|
124
|
+
### Code Quality
|
|
125
|
+
- `code.no-any` — Block TypeScript any
|
|
126
|
+
- `code.strict-mode` — Require TS strict
|
|
127
|
+
- `code.no-unused-vars` — Remove dead code
|
|
128
|
+
|
|
129
|
+
### Config
|
|
130
|
+
- `config.node-version` — Specify Node version
|
|
131
|
+
- `config.editor-config` — Require .editorconfig
|
|
132
|
+
|
|
133
|
+
## Configuration
|
|
134
|
+
|
|
135
|
+
### Full Config Example
|
|
136
|
+
|
|
137
|
+
```yaml
|
|
138
|
+
devrail:
|
|
139
|
+
preset: "node-api"
|
|
140
|
+
level: "standard"
|
|
141
|
+
|
|
142
|
+
# Baseline: accept existing, block new
|
|
143
|
+
baseline: ".devrail/baseline.json"
|
|
144
|
+
|
|
145
|
+
# Override specific rules
|
|
146
|
+
rules:
|
|
147
|
+
secrets.no-plaintext:
|
|
148
|
+
enabled: true
|
|
149
|
+
severity: error
|
|
150
|
+
deps.no-unpinned:
|
|
151
|
+
enabled: false # Disable this rule
|
|
152
|
+
tests.coverage.min-80:
|
|
153
|
+
enabled: true
|
|
154
|
+
blocking: false # Warn but don't fail
|
|
155
|
+
|
|
156
|
+
# CI settings
|
|
157
|
+
ci:
|
|
158
|
+
failOn: error # error | warn | info
|
|
159
|
+
reportFormat: console # console | json | sarif
|
|
160
|
+
|
|
161
|
+
# Tool toggles
|
|
162
|
+
tools:
|
|
163
|
+
eslint: true
|
|
164
|
+
semgrep: true
|
|
165
|
+
gitleaks: true
|
|
166
|
+
osvScanner: true
|
|
167
|
+
|
|
168
|
+
# File patterns
|
|
169
|
+
include:
|
|
170
|
+
- "src/**/*"
|
|
171
|
+
exclude:
|
|
172
|
+
- "**/*.test.ts"
|
|
173
|
+
- "dist/**"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Config File Locations
|
|
177
|
+
|
|
178
|
+
Devrail looks for config in:
|
|
179
|
+
- `devrail.config.yaml`
|
|
180
|
+
- `devrail.config.yml`
|
|
181
|
+
- `devrail.config.json`
|
|
182
|
+
- `devrail.config.js`
|
|
183
|
+
- `.devrailrc`
|
|
184
|
+
- `package.json` (under `devrail` key)
|
|
185
|
+
|
|
186
|
+
## CI Integration
|
|
187
|
+
|
|
188
|
+
### GitHub Actions
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
# .github/workflows/devrail.yml
|
|
192
|
+
name: Devrail Security
|
|
193
|
+
on: [push, pull_request]
|
|
194
|
+
|
|
195
|
+
jobs:
|
|
196
|
+
security:
|
|
197
|
+
runs-on: ubuntu-latest
|
|
198
|
+
steps:
|
|
199
|
+
- uses: actions/checkout@v4
|
|
200
|
+
- uses: actions/setup-node@v4
|
|
201
|
+
with:
|
|
202
|
+
node-version: '20'
|
|
203
|
+
- run: npm ci
|
|
204
|
+
- run: npm install -g devrail
|
|
205
|
+
- run: devrail ci --format sarif > results.sarif
|
|
206
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
207
|
+
with:
|
|
208
|
+
sarif_file: results.sarif
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### GitLab CI
|
|
212
|
+
|
|
213
|
+
```yaml
|
|
214
|
+
devrail:
|
|
215
|
+
image: node:20
|
|
216
|
+
script:
|
|
217
|
+
- npm ci
|
|
218
|
+
- npm install -g devrail
|
|
219
|
+
- devrail ci --fail-on error
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Tool Requirements
|
|
223
|
+
|
|
224
|
+
Devrail wraps existing best-in-class tools:
|
|
225
|
+
|
|
226
|
+
| Tool | Purpose | Install |
|
|
227
|
+
|------|---------|---------|
|
|
228
|
+
| [gitleaks](https://github.com/gitleaks/gitleaks) | Secret scanning | `brew install gitleaks` |
|
|
229
|
+
| [osv-scanner](https://github.com/google/osv-scanner) | Dependency vulnerabilities | `brew install osv-scanner` |
|
|
230
|
+
| [semgrep](https://semgrep.dev) | SAST | `pip install semgrep` |
|
|
231
|
+
|
|
232
|
+
Devrail gracefully skips tools that aren't installed.
|
|
233
|
+
|
|
234
|
+
## Philosophy
|
|
235
|
+
|
|
236
|
+
1. **Opinionated** — We make decisions so you don't have to
|
|
237
|
+
2. **Composable** — Mix presets and rules like Tailwind classes
|
|
238
|
+
3. **Frictionless** — 10-minute setup, not 10-day integration
|
|
239
|
+
4. **Blocking** — Fail fast, fix early
|
|
240
|
+
5. **Wrapper-based** — We don't reinvent scanners, we orchestrate them
|
|
241
|
+
|
|
242
|
+
## Key Innovation: Adoption-First
|
|
243
|
+
|
|
244
|
+
Unlike other tools that dump 400 errors on day one, Devrail:
|
|
245
|
+
|
|
246
|
+
1. **Baseline** - Accept existing issues, only block NEW ones
|
|
247
|
+
2. **Diff-only** - By default, only scan changed files in PRs
|
|
248
|
+
3. **Auto-fix** - Safe fixes applied automatically
|
|
249
|
+
4. **Levels** - Start with `basic`, graduate to `strict`
|
|
250
|
+
|
|
251
|
+
## Roadmap
|
|
252
|
+
|
|
253
|
+
- [x] Baseline system (accept existing, block new)
|
|
254
|
+
- [x] Auto stack detection
|
|
255
|
+
- [x] Diff-only mode
|
|
256
|
+
- [ ] ESLint integration with security rules
|
|
257
|
+
- [ ] Python preset (pytest, bandit, safety)
|
|
258
|
+
- [ ] Watch mode (`devrail guard --watch`)
|
|
259
|
+
- [ ] VS Code extension
|
|
260
|
+
- [ ] Custom rule definitions
|
|
261
|
+
|
|
262
|
+
## Contributing
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
git clone https://github.com/your-org/devrail
|
|
266
|
+
cd devrail
|
|
267
|
+
npm install
|
|
268
|
+
npm run dev
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
|
|
273
|
+
MIT
|