@brett.buskirk/agent-gate 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 +196 -0
- package/action.yml +30 -0
- package/bin/agent-gate.js +3 -0
- package/lib/action.d.ts +2 -0
- package/lib/action.d.ts.map +1 -0
- package/lib/action.js +73 -0
- package/lib/cli.d.ts +3 -0
- package/lib/cli.d.ts.map +1 -0
- package/lib/cli.js +36 -0
- package/lib/config/load.d.ts +3 -0
- package/lib/config/load.d.ts.map +1 -0
- package/lib/config/load.js +14 -0
- package/lib/config/schema.d.ts +236 -0
- package/lib/config/schema.d.ts.map +1 -0
- package/lib/config/schema.js +66 -0
- package/lib/diff/git.d.ts +9 -0
- package/lib/diff/git.d.ts.map +1 -0
- package/lib/diff/git.js +20 -0
- package/lib/diff/github.d.ts +11 -0
- package/lib/diff/github.d.ts.map +1 -0
- package/lib/diff/github.js +33 -0
- package/lib/diff/parse.d.ts +24 -0
- package/lib/diff/parse.d.ts.map +1 -0
- package/lib/diff/parse.js +65 -0
- package/lib/diff/provider.d.ts +5 -0
- package/lib/diff/provider.d.ts.map +1 -0
- package/lib/diff/provider.js +2 -0
- package/lib/engine.d.ts +15 -0
- package/lib/engine.d.ts.map +1 -0
- package/lib/engine.js +22 -0
- package/lib/report/checkRun.d.ts +3 -0
- package/lib/report/checkRun.d.ts.map +1 -0
- package/lib/report/checkRun.js +51 -0
- package/lib/report/comment.d.ts +4 -0
- package/lib/report/comment.d.ts.map +1 -0
- package/lib/report/comment.js +71 -0
- package/lib/report/json.d.ts +4 -0
- package/lib/report/json.d.ts.map +1 -0
- package/lib/report/json.js +50 -0
- package/lib/report/summary.d.ts +4 -0
- package/lib/report/summary.d.ts.map +1 -0
- package/lib/report/summary.js +56 -0
- package/lib/rules/dangerousPatterns.d.ts +3 -0
- package/lib/rules/dangerousPatterns.d.ts.map +1 -0
- package/lib/rules/dangerousPatterns.js +42 -0
- package/lib/rules/dependencies.d.ts +3 -0
- package/lib/rules/dependencies.d.ts.map +1 -0
- package/lib/rules/dependencies.js +26 -0
- package/lib/rules/diffSize.d.ts +3 -0
- package/lib/rules/diffSize.d.ts.map +1 -0
- package/lib/rules/diffSize.js +31 -0
- package/lib/rules/index.d.ts +4 -0
- package/lib/rules/index.d.ts.map +1 -0
- package/lib/rules/index.js +17 -0
- package/lib/rules/scope.d.ts +3 -0
- package/lib/rules/scope.d.ts.map +1 -0
- package/lib/rules/scope.js +37 -0
- package/lib/rules/secrets.d.ts +3 -0
- package/lib/rules/secrets.d.ts.map +1 -0
- package/lib/rules/secrets.js +60 -0
- package/lib/rules/testsRequired.d.ts +3 -0
- package/lib/rules/testsRequired.d.ts.map +1 -0
- package/lib/rules/testsRequired.js +26 -0
- package/lib/rules/types.d.ts +18 -0
- package/lib/rules/types.d.ts.map +1 -0
- package/lib/rules/types.js +2 -0
- package/lib/utils/glob.d.ts +3 -0
- package/lib/utils/glob.d.ts.map +1 -0
- package/lib/utils/glob.js +42 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brett Buskirk
|
|
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,196 @@
|
|
|
1
|
+
# AgentGate
|
|
2
|
+
|
|
3
|
+
**Guardrail checks for AI-agent-generated pull requests.**
|
|
4
|
+
|
|
5
|
+
AgentGate runs in CI on every PR, inspects the diff for the risk signals that AI agents commonly introduce — leaked secrets, out-of-scope changes, missing tests, surprise dependencies — posts a structured review comment, and sets a pass/fail check. Your team gets eyes on agent work without rubber-stamping it.
|
|
6
|
+
|
|
7
|
+
> Built by [Brett Buskirk LLC](https://brett-buskirk.dev) as part of the **Agentic Development Workflow Setup** service — a productized safety net for teams shipping with AI coding agents.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Status
|
|
12
|
+
|
|
13
|
+
**v0.1.0 — active development.** All six rules implemented and tested. Action bundled (`dist/index.js`). Dogfood CI runs AgentGate on its own PRs. npm publish next.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Quickstart
|
|
18
|
+
|
|
19
|
+
### GitHub Action
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
# .github/workflows/agentgate.yml
|
|
23
|
+
name: AgentGate
|
|
24
|
+
on: [pull_request]
|
|
25
|
+
|
|
26
|
+
jobs:
|
|
27
|
+
agentgate:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
- uses: brett-buskirk/agent-gate@v1
|
|
32
|
+
with:
|
|
33
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Add a `.agentgate.yml` to your repo to configure it (or skip it — the defaults are sane).
|
|
37
|
+
|
|
38
|
+
### CLI
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx @brett.buskirk/agent-gate check --base main
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or install globally:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install -g @brett.buskirk/agent-gate
|
|
48
|
+
agent-gate check --base main --json
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
Place a `.agentgate.yml` in your repo root. Everything has a default — the file is optional.
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
version: 1
|
|
59
|
+
fail_on: error # error | warning | never
|
|
60
|
+
comment: true # post/update a PR comment
|
|
61
|
+
|
|
62
|
+
rules:
|
|
63
|
+
secrets:
|
|
64
|
+
enabled: true
|
|
65
|
+
severity: error
|
|
66
|
+
|
|
67
|
+
scope:
|
|
68
|
+
enabled: true
|
|
69
|
+
severity: error
|
|
70
|
+
allow: # if set, only these paths are permitted
|
|
71
|
+
- "src/**"
|
|
72
|
+
- "test/**"
|
|
73
|
+
- "docs/**"
|
|
74
|
+
deny: # always blocked regardless of allow
|
|
75
|
+
- ".github/workflows/**"
|
|
76
|
+
- "infra/**"
|
|
77
|
+
- "**/*.lock"
|
|
78
|
+
- "package-lock.json"
|
|
79
|
+
|
|
80
|
+
diff_size:
|
|
81
|
+
enabled: true
|
|
82
|
+
severity: warning
|
|
83
|
+
max_files: 30
|
|
84
|
+
max_lines: 800
|
|
85
|
+
|
|
86
|
+
tests_required:
|
|
87
|
+
enabled: true
|
|
88
|
+
severity: warning
|
|
89
|
+
src_globs: ["src/**"]
|
|
90
|
+
test_globs: ["**/*.test.*", "**/*.spec.*", "tests/**"]
|
|
91
|
+
|
|
92
|
+
dependencies:
|
|
93
|
+
enabled: true
|
|
94
|
+
severity: warning
|
|
95
|
+
manifests: ["package.json", "requirements.txt", "go.mod", "Gemfile", "Cargo.toml"]
|
|
96
|
+
|
|
97
|
+
dangerous_patterns:
|
|
98
|
+
enabled: true
|
|
99
|
+
severity: error
|
|
100
|
+
patterns:
|
|
101
|
+
- "eval\\("
|
|
102
|
+
- "--no-verify"
|
|
103
|
+
- "child_process\\.exec\\("
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### `fail_on`
|
|
107
|
+
|
|
108
|
+
| Value | Behavior |
|
|
109
|
+
|-------|----------|
|
|
110
|
+
| `error` | Only error-severity findings fail the check (default) |
|
|
111
|
+
| `warning` | Warnings also fail the check |
|
|
112
|
+
| `never` | Check always passes; findings are still reported |
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Rules
|
|
117
|
+
|
|
118
|
+
| Rule | Default severity | What it catches |
|
|
119
|
+
|------|-----------------|-----------------|
|
|
120
|
+
| `secrets` | error | AWS keys, GitHub tokens, private key blocks, high-entropy assignments |
|
|
121
|
+
| `scope` | error | Files outside the allow list or inside the deny list |
|
|
122
|
+
| `diff_size` | warning | PRs exceeding `max_files` (30) or `max_lines` (800) |
|
|
123
|
+
| `tests_required` | warning | Source changes with no corresponding test file changes |
|
|
124
|
+
| `dependencies` | warning | Modified dependency manifests (supply-chain risk) |
|
|
125
|
+
| `dangerous_patterns` | error | User-defined regex denylist applied to added lines |
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## PR Comment
|
|
130
|
+
|
|
131
|
+
AgentGate posts a single comment on the PR and updates it in place on re-runs — never spams. The comment shows the overall verdict, a rule-by-rule summary table, and expandable findings with file locations and actionable suggestions.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## How it works
|
|
136
|
+
|
|
137
|
+
1. On a `pull_request` event, the Action fetches the PR diff from the GitHub API
|
|
138
|
+
2. The diff is parsed into a structured model (files, chunks, added/removed lines)
|
|
139
|
+
3. Each enabled rule runs over the model and returns findings
|
|
140
|
+
4. The engine aggregates findings and computes a verdict based on `fail_on`
|
|
141
|
+
5. Reporters post the PR comment, set the check status, and write the Step Summary
|
|
142
|
+
6. The check fails if the verdict is `fail` — blocking merge until the agent's work is reviewed
|
|
143
|
+
|
|
144
|
+
The CLI (`agent-gate check`) uses `git diff` instead of the GitHub API, making it usable locally and in pre-commit hooks.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Project structure
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
agent-gate/
|
|
152
|
+
action.yml # GitHub Action metadata
|
|
153
|
+
src/
|
|
154
|
+
cli.ts # CLI entry (commander)
|
|
155
|
+
action.ts # Action entry
|
|
156
|
+
engine.ts # Aggregates rules → verdict
|
|
157
|
+
diff/ # Diff providers + parser
|
|
158
|
+
rules/ # Rule implementations
|
|
159
|
+
report/ # Reporters (comment, check, summary, CLI)
|
|
160
|
+
config/ # Schema (zod) + loader
|
|
161
|
+
utils/ # Glob matching
|
|
162
|
+
test/
|
|
163
|
+
fixtures/ # Sample diffs (clean + dirty per rule)
|
|
164
|
+
rules/ # Rule unit tests
|
|
165
|
+
engine.test.ts
|
|
166
|
+
docs/
|
|
167
|
+
DESIGN.md
|
|
168
|
+
SPRINTS.md
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Stack
|
|
174
|
+
|
|
175
|
+
| Layer | Technology |
|
|
176
|
+
|-------|-----------|
|
|
177
|
+
| Language | TypeScript 5, strict mode |
|
|
178
|
+
| Runtime | Node 20+ |
|
|
179
|
+
| Action bundler | @vercel/ncc |
|
|
180
|
+
| Config validation | zod |
|
|
181
|
+
| Config format | js-yaml |
|
|
182
|
+
| CLI | commander |
|
|
183
|
+
| GitHub API | @actions/github (Octokit) |
|
|
184
|
+
| Tests | Vitest |
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Contributing
|
|
189
|
+
|
|
190
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). New rules are the most welcome contribution — there's a dedicated issue template and a clear pattern to follow.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT — see [LICENSE](LICENSE).
|
package/action.yml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: 'AgentGate'
|
|
2
|
+
description: 'Guardrail checks for AI-agent-generated pull requests'
|
|
3
|
+
author: 'Brett Buskirk'
|
|
4
|
+
|
|
5
|
+
inputs:
|
|
6
|
+
github-token:
|
|
7
|
+
description: 'GitHub token for API access'
|
|
8
|
+
required: true
|
|
9
|
+
default: ${{ github.token }}
|
|
10
|
+
config-path:
|
|
11
|
+
description: 'Path to .agentgate.yml config file'
|
|
12
|
+
required: false
|
|
13
|
+
default: '.agentgate.yml'
|
|
14
|
+
fail-on:
|
|
15
|
+
description: 'Minimum severity that fails the check (error | warning | never). Overrides config file.'
|
|
16
|
+
required: false
|
|
17
|
+
|
|
18
|
+
outputs:
|
|
19
|
+
verdict:
|
|
20
|
+
description: 'Overall verdict: pass | warn | fail'
|
|
21
|
+
finding-count:
|
|
22
|
+
description: 'Total number of findings'
|
|
23
|
+
|
|
24
|
+
runs:
|
|
25
|
+
using: 'node20'
|
|
26
|
+
main: 'dist/index.js'
|
|
27
|
+
|
|
28
|
+
branding:
|
|
29
|
+
icon: 'shield'
|
|
30
|
+
color: 'blue'
|
package/lib/action.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":""}
|
package/lib/action.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const core = __importStar(require("@actions/core"));
|
|
37
|
+
const github = __importStar(require("@actions/github"));
|
|
38
|
+
const load_1 = require("./config/load");
|
|
39
|
+
const github_1 = require("./diff/github");
|
|
40
|
+
const engine_1 = require("./engine");
|
|
41
|
+
const comment_1 = require("./report/comment");
|
|
42
|
+
const checkRun_1 = require("./report/checkRun");
|
|
43
|
+
const summary_1 = require("./report/summary");
|
|
44
|
+
async function run() {
|
|
45
|
+
try {
|
|
46
|
+
const token = core.getInput('github-token', { required: true });
|
|
47
|
+
const configPath = core.getInput('config-path') || '.agentgate.yml';
|
|
48
|
+
const { pull_request } = github.context.payload;
|
|
49
|
+
if (!pull_request) {
|
|
50
|
+
core.warning('AgentGate only runs on pull_request events. Skipping.');
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
core.info(`Running AgentGate on PR #${pull_request.number}`);
|
|
54
|
+
const config = (0, load_1.loadConfig)(configPath);
|
|
55
|
+
const failOnOverride = core.getInput('fail-on');
|
|
56
|
+
if (failOnOverride && ['error', 'warning', 'never'].includes(failOnOverride)) {
|
|
57
|
+
config.fail_on = failOnOverride;
|
|
58
|
+
}
|
|
59
|
+
const { owner, repo } = github.context.repo;
|
|
60
|
+
const provider = new github_1.GitHubDiffProvider(token, owner, repo, pull_request.number);
|
|
61
|
+
const diff = await provider.getDiff();
|
|
62
|
+
const result = (0, engine_1.runEngine)(diff, config);
|
|
63
|
+
(0, checkRun_1.setCheckOutput)(result);
|
|
64
|
+
if (config.comment) {
|
|
65
|
+
await (0, comment_1.upsertComment)(token, owner, repo, pull_request.number, result, diff);
|
|
66
|
+
}
|
|
67
|
+
await (0, summary_1.writeSummary)(result, diff);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
core.setFailed(err instanceof Error ? err.message : String(err));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
run();
|
package/lib/cli.d.ts
ADDED
package/lib/cli.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/lib/cli.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const load_1 = require("./config/load");
|
|
6
|
+
const git_1 = require("./diff/git");
|
|
7
|
+
const engine_1 = require("./engine");
|
|
8
|
+
const json_1 = require("./report/json");
|
|
9
|
+
const program = new commander_1.Command();
|
|
10
|
+
program
|
|
11
|
+
.name('agent-gate')
|
|
12
|
+
.description('Guardrail checks for AI-agent-generated pull requests')
|
|
13
|
+
.version('0.1.0');
|
|
14
|
+
program
|
|
15
|
+
.command('check')
|
|
16
|
+
.description('Run guardrail checks against a diff')
|
|
17
|
+
.option('-b, --base <ref>', 'Base git ref to diff against', 'main')
|
|
18
|
+
.option('-c, --config <path>', 'Path to config file', '.agentgate.yml')
|
|
19
|
+
.option('--json', 'Output results as JSON')
|
|
20
|
+
.action(async (opts) => {
|
|
21
|
+
try {
|
|
22
|
+
const config = (0, load_1.loadConfig)(opts.config);
|
|
23
|
+
const provider = new git_1.GitDiffProvider(opts.base);
|
|
24
|
+
const diff = await provider.getDiff();
|
|
25
|
+
const result = (0, engine_1.runEngine)(diff, config);
|
|
26
|
+
(0, json_1.reportCli)(result, diff, opts.json);
|
|
27
|
+
if (result.verdict === 'fail') {
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
console.error('Error:', err instanceof Error ? err.message : String(err));
|
|
33
|
+
process.exit(2);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
program.parse();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/config/load.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAQrD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadConfig = loadConfig;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const js_yaml_1 = require("js-yaml");
|
|
6
|
+
const schema_1 = require("./schema");
|
|
7
|
+
function loadConfig(configPath) {
|
|
8
|
+
if (!(0, fs_1.existsSync)(configPath)) {
|
|
9
|
+
return schema_1.ConfigSchema.parse({ version: 1 });
|
|
10
|
+
}
|
|
11
|
+
const raw = (0, fs_1.readFileSync)(configPath, 'utf8');
|
|
12
|
+
const parsed = (0, js_yaml_1.load)(raw);
|
|
13
|
+
return schema_1.ConfigSchema.parse(parsed);
|
|
14
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ConfigSchema: z.ZodObject<{
|
|
3
|
+
version: z.ZodLiteral<1>;
|
|
4
|
+
fail_on: z.ZodDefault<z.ZodEnum<["error", "warning", "never"]>>;
|
|
5
|
+
comment: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
rules: z.ZodDefault<z.ZodObject<{
|
|
7
|
+
secrets: z.ZodDefault<z.ZodObject<{
|
|
8
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
severity: z.ZodDefault<z.ZodEnum<["error", "warning", "info"]>>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
severity: "error" | "warning" | "info";
|
|
13
|
+
}, {
|
|
14
|
+
enabled?: boolean | undefined;
|
|
15
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
16
|
+
}>>;
|
|
17
|
+
scope: z.ZodDefault<z.ZodObject<{
|
|
18
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
19
|
+
severity: z.ZodDefault<z.ZodEnum<["error", "warning", "info"]>>;
|
|
20
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
21
|
+
deny: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
severity: "error" | "warning" | "info";
|
|
25
|
+
deny: string[];
|
|
26
|
+
allow?: string[] | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
enabled?: boolean | undefined;
|
|
29
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
30
|
+
allow?: string[] | undefined;
|
|
31
|
+
deny?: string[] | undefined;
|
|
32
|
+
}>>;
|
|
33
|
+
diff_size: z.ZodDefault<z.ZodObject<{
|
|
34
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
35
|
+
severity: z.ZodDefault<z.ZodEnum<["error", "warning", "info"]>>;
|
|
36
|
+
max_files: z.ZodDefault<z.ZodNumber>;
|
|
37
|
+
max_lines: z.ZodDefault<z.ZodNumber>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
severity: "error" | "warning" | "info";
|
|
41
|
+
max_files: number;
|
|
42
|
+
max_lines: number;
|
|
43
|
+
}, {
|
|
44
|
+
enabled?: boolean | undefined;
|
|
45
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
46
|
+
max_files?: number | undefined;
|
|
47
|
+
max_lines?: number | undefined;
|
|
48
|
+
}>>;
|
|
49
|
+
tests_required: z.ZodDefault<z.ZodObject<{
|
|
50
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
51
|
+
severity: z.ZodDefault<z.ZodEnum<["error", "warning", "info"]>>;
|
|
52
|
+
src_globs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
53
|
+
test_globs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
severity: "error" | "warning" | "info";
|
|
57
|
+
src_globs: string[];
|
|
58
|
+
test_globs: string[];
|
|
59
|
+
}, {
|
|
60
|
+
enabled?: boolean | undefined;
|
|
61
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
62
|
+
src_globs?: string[] | undefined;
|
|
63
|
+
test_globs?: string[] | undefined;
|
|
64
|
+
}>>;
|
|
65
|
+
dependencies: z.ZodDefault<z.ZodObject<{
|
|
66
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
67
|
+
severity: z.ZodDefault<z.ZodEnum<["error", "warning", "info"]>>;
|
|
68
|
+
manifests: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
severity: "error" | "warning" | "info";
|
|
72
|
+
manifests: string[];
|
|
73
|
+
}, {
|
|
74
|
+
enabled?: boolean | undefined;
|
|
75
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
76
|
+
manifests?: string[] | undefined;
|
|
77
|
+
}>>;
|
|
78
|
+
dangerous_patterns: z.ZodDefault<z.ZodObject<{
|
|
79
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
80
|
+
severity: z.ZodDefault<z.ZodEnum<["error", "warning", "info"]>>;
|
|
81
|
+
patterns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
enabled: boolean;
|
|
84
|
+
severity: "error" | "warning" | "info";
|
|
85
|
+
patterns: string[];
|
|
86
|
+
}, {
|
|
87
|
+
enabled?: boolean | undefined;
|
|
88
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
89
|
+
patterns?: string[] | undefined;
|
|
90
|
+
}>>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
secrets: {
|
|
93
|
+
enabled: boolean;
|
|
94
|
+
severity: "error" | "warning" | "info";
|
|
95
|
+
};
|
|
96
|
+
scope: {
|
|
97
|
+
enabled: boolean;
|
|
98
|
+
severity: "error" | "warning" | "info";
|
|
99
|
+
deny: string[];
|
|
100
|
+
allow?: string[] | undefined;
|
|
101
|
+
};
|
|
102
|
+
diff_size: {
|
|
103
|
+
enabled: boolean;
|
|
104
|
+
severity: "error" | "warning" | "info";
|
|
105
|
+
max_files: number;
|
|
106
|
+
max_lines: number;
|
|
107
|
+
};
|
|
108
|
+
tests_required: {
|
|
109
|
+
enabled: boolean;
|
|
110
|
+
severity: "error" | "warning" | "info";
|
|
111
|
+
src_globs: string[];
|
|
112
|
+
test_globs: string[];
|
|
113
|
+
};
|
|
114
|
+
dependencies: {
|
|
115
|
+
enabled: boolean;
|
|
116
|
+
severity: "error" | "warning" | "info";
|
|
117
|
+
manifests: string[];
|
|
118
|
+
};
|
|
119
|
+
dangerous_patterns: {
|
|
120
|
+
enabled: boolean;
|
|
121
|
+
severity: "error" | "warning" | "info";
|
|
122
|
+
patterns: string[];
|
|
123
|
+
};
|
|
124
|
+
}, {
|
|
125
|
+
secrets?: {
|
|
126
|
+
enabled?: boolean | undefined;
|
|
127
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
128
|
+
} | undefined;
|
|
129
|
+
scope?: {
|
|
130
|
+
enabled?: boolean | undefined;
|
|
131
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
132
|
+
allow?: string[] | undefined;
|
|
133
|
+
deny?: string[] | undefined;
|
|
134
|
+
} | undefined;
|
|
135
|
+
diff_size?: {
|
|
136
|
+
enabled?: boolean | undefined;
|
|
137
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
138
|
+
max_files?: number | undefined;
|
|
139
|
+
max_lines?: number | undefined;
|
|
140
|
+
} | undefined;
|
|
141
|
+
tests_required?: {
|
|
142
|
+
enabled?: boolean | undefined;
|
|
143
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
144
|
+
src_globs?: string[] | undefined;
|
|
145
|
+
test_globs?: string[] | undefined;
|
|
146
|
+
} | undefined;
|
|
147
|
+
dependencies?: {
|
|
148
|
+
enabled?: boolean | undefined;
|
|
149
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
150
|
+
manifests?: string[] | undefined;
|
|
151
|
+
} | undefined;
|
|
152
|
+
dangerous_patterns?: {
|
|
153
|
+
enabled?: boolean | undefined;
|
|
154
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
155
|
+
patterns?: string[] | undefined;
|
|
156
|
+
} | undefined;
|
|
157
|
+
}>>;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
version: 1;
|
|
160
|
+
fail_on: "error" | "warning" | "never";
|
|
161
|
+
comment: boolean;
|
|
162
|
+
rules: {
|
|
163
|
+
secrets: {
|
|
164
|
+
enabled: boolean;
|
|
165
|
+
severity: "error" | "warning" | "info";
|
|
166
|
+
};
|
|
167
|
+
scope: {
|
|
168
|
+
enabled: boolean;
|
|
169
|
+
severity: "error" | "warning" | "info";
|
|
170
|
+
deny: string[];
|
|
171
|
+
allow?: string[] | undefined;
|
|
172
|
+
};
|
|
173
|
+
diff_size: {
|
|
174
|
+
enabled: boolean;
|
|
175
|
+
severity: "error" | "warning" | "info";
|
|
176
|
+
max_files: number;
|
|
177
|
+
max_lines: number;
|
|
178
|
+
};
|
|
179
|
+
tests_required: {
|
|
180
|
+
enabled: boolean;
|
|
181
|
+
severity: "error" | "warning" | "info";
|
|
182
|
+
src_globs: string[];
|
|
183
|
+
test_globs: string[];
|
|
184
|
+
};
|
|
185
|
+
dependencies: {
|
|
186
|
+
enabled: boolean;
|
|
187
|
+
severity: "error" | "warning" | "info";
|
|
188
|
+
manifests: string[];
|
|
189
|
+
};
|
|
190
|
+
dangerous_patterns: {
|
|
191
|
+
enabled: boolean;
|
|
192
|
+
severity: "error" | "warning" | "info";
|
|
193
|
+
patterns: string[];
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
}, {
|
|
197
|
+
version: 1;
|
|
198
|
+
fail_on?: "error" | "warning" | "never" | undefined;
|
|
199
|
+
comment?: boolean | undefined;
|
|
200
|
+
rules?: {
|
|
201
|
+
secrets?: {
|
|
202
|
+
enabled?: boolean | undefined;
|
|
203
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
204
|
+
} | undefined;
|
|
205
|
+
scope?: {
|
|
206
|
+
enabled?: boolean | undefined;
|
|
207
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
208
|
+
allow?: string[] | undefined;
|
|
209
|
+
deny?: string[] | undefined;
|
|
210
|
+
} | undefined;
|
|
211
|
+
diff_size?: {
|
|
212
|
+
enabled?: boolean | undefined;
|
|
213
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
214
|
+
max_files?: number | undefined;
|
|
215
|
+
max_lines?: number | undefined;
|
|
216
|
+
} | undefined;
|
|
217
|
+
tests_required?: {
|
|
218
|
+
enabled?: boolean | undefined;
|
|
219
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
220
|
+
src_globs?: string[] | undefined;
|
|
221
|
+
test_globs?: string[] | undefined;
|
|
222
|
+
} | undefined;
|
|
223
|
+
dependencies?: {
|
|
224
|
+
enabled?: boolean | undefined;
|
|
225
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
226
|
+
manifests?: string[] | undefined;
|
|
227
|
+
} | undefined;
|
|
228
|
+
dangerous_patterns?: {
|
|
229
|
+
enabled?: boolean | undefined;
|
|
230
|
+
severity?: "error" | "warning" | "info" | undefined;
|
|
231
|
+
patterns?: string[] | undefined;
|
|
232
|
+
} | undefined;
|
|
233
|
+
} | undefined;
|
|
234
|
+
}>;
|
|
235
|
+
export type Config = z.infer<typeof ConfigSchema>;
|
|
236
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4DvB,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|