@shomra/agent 0.2.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/LICENSE +201 -0
- package/NOTICE +10 -0
- package/README.md +220 -0
- package/code-sast.mjs +763 -0
- package/discovery.mjs +812 -0
- package/guard-signals.mjs +747 -0
- package/model-refs.mjs +130 -0
- package/package.json +51 -0
- package/shomra.mjs +4193 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Shomra
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Shomra Agent (@shomra/agent)
|
|
2
|
+
Copyright 2026 Shomra
|
|
3
|
+
|
|
4
|
+
This product includes software developed at Shomra (https://shomra.dev).
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0. See the LICENSE file for the
|
|
7
|
+
full terms.
|
|
8
|
+
|
|
9
|
+
The detection rules, signatures, and analyzers in this package are intended for
|
|
10
|
+
authorized security use — scanning your own AI artifacts, code, and machines.
|
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# @shomra/agent
|
|
2
|
+
|
|
3
|
+
The Shomra AI-security CLI. Discovers the AI tooling on a machine, vets AI
|
|
4
|
+
artifacts (MCP configs, Skills, slash commands, hooks, rules files) before they
|
|
5
|
+
install, and enforces a runtime firewall around coding agents and LLM traffic.
|
|
6
|
+
|
|
7
|
+
Zero dependencies — Node ≥ 18 built-ins only.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i -g @shomra/agent # global `shomra`
|
|
13
|
+
# or run without installing:
|
|
14
|
+
npx @shomra/agent gate .mcp.json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Auth (optional)
|
|
18
|
+
|
|
19
|
+
Shomra is **local-first** — there is no built-in backend and no telemetry. `gate`,
|
|
20
|
+
`check`, `models`, `secrets`, and the runtime firewall all run fully on your
|
|
21
|
+
machine with no key and no network. You only connect to a Shomra org to layer on
|
|
22
|
+
your **org policy**, cloud/deep scans, AI fixes, and the Model Security Index.
|
|
23
|
+
|
|
24
|
+
- **Dev machine:** `shomra init --key shm_live_… --url https://shomra.your-co.com` (writes `~/.shomra/config.json`).
|
|
25
|
+
- **CI / headless:** set env vars instead — no `init` needed:
|
|
26
|
+
- `SHOMRA_API_KEY` — your org key
|
|
27
|
+
- `SHOMRA_URL` — your backend URL
|
|
28
|
+
|
|
29
|
+
Without either, every backend-only feature degrades cleanly to the on-machine result.
|
|
30
|
+
|
|
31
|
+
## Quickstart
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
shomra check # "is my repo safe?" — gate every AI artifact at once
|
|
35
|
+
shomra check --staged # only what's git-staged (pre-commit / editor-on-save)
|
|
36
|
+
shomra check --fix # gate, then remediate what isn't clean, in place
|
|
37
|
+
shomra fix .mcp.json --apply # AI-fix one artifact and write it back
|
|
38
|
+
shomra why .mcp.json # why each finding matters + is-it-a-false-positive
|
|
39
|
+
shomra install-precommit # block risky staged AI artifacts on git commit
|
|
40
|
+
shomra install-hook --agent claude # wire the runtime firewall into Claude Code
|
|
41
|
+
shomra scan # discover AI tooling on this machine
|
|
42
|
+
shomra status # config + firewall health
|
|
43
|
+
shomra help # full command list
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`check`, `fix` and `why` are the verbs a developer lives in — everything below is
|
|
47
|
+
CI, governance, or one-time setup. Findings carry a **file:line**, so `check --json`
|
|
48
|
+
drives precise editor squiggles and `why`/`fix` point at the exact offending line.
|
|
49
|
+
|
|
50
|
+
- **`check`** is the developer front door: it finds every AI artifact in the tree
|
|
51
|
+
(MCP configs, Skills, slash commands, hooks, rules files) and gates them in one
|
|
52
|
+
shot, **local-first** — a real on-machine verdict with no backend or key, org
|
|
53
|
+
policy layered on when enrolled. It's `gate --all` with dev ergonomics
|
|
54
|
+
(`--staged` / `--changed` scoping, `--fix`, clean `--json` for an IDE extension).
|
|
55
|
+
- **`fix`** generates a minimal fix for what the gate flags and (with `--apply`)
|
|
56
|
+
writes it back to your working tree — the fix is produced on the platform with
|
|
57
|
+
your org's AI key, so no provider key sits on the dev machine. Nothing is
|
|
58
|
+
committed or pushed. Without AI on the server it prints deterministic guidance.
|
|
59
|
+
|
|
60
|
+
### The install-time verbs (still here)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
shomra gate my-skill/SKILL.md # vet ONE artifact (auto-classified from the path)
|
|
64
|
+
shomra gate --all . # vet every AI artifact in the repo (the CI form)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## `gate` in CI
|
|
68
|
+
|
|
69
|
+
`gate`/`gate --all` are **local-first**: real static analysis (dangerous shell,
|
|
70
|
+
prompt injection, secrets, exfil sinks, over-permissioned tool grants,
|
|
71
|
+
install-lure prose) runs on-machine, so you get a genuine verdict even if the
|
|
72
|
+
backend is unreachable. When enrolled + reachable, your **org policy** is layered
|
|
73
|
+
on top.
|
|
74
|
+
|
|
75
|
+
**Exit codes:** `0` = allowed · `1` = blocked (or `--strict` + backend outage) · `2` = flagged with `--strict`.
|
|
76
|
+
|
|
77
|
+
**Backend outage:** by default it falls back to the on-machine verdict (org
|
|
78
|
+
policy not applied). `--strict` fails closed (exit 1) because org policy can't be
|
|
79
|
+
verified. Every backend call is bounded by `SHOMRA_API_TIMEOUT_MS` (default 30s),
|
|
80
|
+
so a job never hangs.
|
|
81
|
+
|
|
82
|
+
### GitHub Actions
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
name: Shomra AI-artifact gate
|
|
86
|
+
on: [pull_request]
|
|
87
|
+
jobs:
|
|
88
|
+
gate:
|
|
89
|
+
runs-on: ubuntu-latest
|
|
90
|
+
steps:
|
|
91
|
+
- uses: actions/checkout@v4
|
|
92
|
+
- uses: actions/setup-node@v4
|
|
93
|
+
with: { node-version: 20 }
|
|
94
|
+
- name: Vet AI artifacts
|
|
95
|
+
env:
|
|
96
|
+
SHOMRA_API_KEY: ${{ secrets.SHOMRA_API_KEY }}
|
|
97
|
+
SHOMRA_URL: ${{ secrets.SHOMRA_URL }}
|
|
98
|
+
run: npx @shomra/agent gate --all . --strict
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
CI provider, repo, branch and commit are auto-detected and recorded, so security
|
|
102
|
+
sees local-vs-CI gate activity in the dashboard.
|
|
103
|
+
|
|
104
|
+
### GitHub PR reviewer — inline annotations (`shomra pr`)
|
|
105
|
+
|
|
106
|
+
`shomra pr` is a richer PR-native path: on a `pull_request` it gates only the AI
|
|
107
|
+
artifacts **changed vs the base branch** and posts a **GitHub Check Run with
|
|
108
|
+
inline annotations** on the offending lines — no GitHub App or extra backend
|
|
109
|
+
required, just the workflow's `GITHUB_TOKEN`. Scaffold it in one shot:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npx @shomra/agent pr --init # writes .github/workflows/shomra.yml (--force to overwrite)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The generated workflow:
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
name: Shomra AI Security
|
|
119
|
+
on: pull_request
|
|
120
|
+
permissions:
|
|
121
|
+
contents: read
|
|
122
|
+
checks: write # required to post the check-run
|
|
123
|
+
jobs:
|
|
124
|
+
shomra:
|
|
125
|
+
runs-on: ubuntu-latest
|
|
126
|
+
steps:
|
|
127
|
+
- uses: actions/checkout@v4
|
|
128
|
+
with: { fetch-depth: 0 } # need the base ref to diff changed artifacts
|
|
129
|
+
- uses: actions/setup-node@v4
|
|
130
|
+
with: { node-version: 20 }
|
|
131
|
+
- run: npx @shomra/agent pr
|
|
132
|
+
env:
|
|
133
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
134
|
+
SHOMRA_API_KEY: ${{ secrets.SHOMRA_API_KEY }} # optional — applies org policy
|
|
135
|
+
SHOMRA_URL: ${{ secrets.SHOMRA_URL }} # optional — your backend
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The check-run **conclusion** mirrors the gate: `failure` on any BLOCK, `neutral`
|
|
139
|
+
on FLAG (or `failure` with `--strict`), `success` when clean. `--dry-run`/`--json`
|
|
140
|
+
print the computed check-run without posting. Without `SHOMRA_API_KEY` it still
|
|
141
|
+
runs local-first; with a key, your **org policy** (below) drives the verdict.
|
|
142
|
+
|
|
143
|
+
### SARIF — native code-scanning annotations
|
|
144
|
+
|
|
145
|
+
`gate`/`gate --all`/`check` accept `--sarif` to emit SARIF 2.1.0, which GitHub
|
|
146
|
+
(and GitLab) render as inline code-scanning annotations without a custom parser:
|
|
147
|
+
|
|
148
|
+
```yaml
|
|
149
|
+
- run: npx @shomra/agent check . --sarif > shomra.sarif
|
|
150
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
151
|
+
with: { sarif_file: shomra.sarif }
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Org policy + triage on top of CI
|
|
155
|
+
|
|
156
|
+
When enrolled, the same **org policy** that governs the dashboard decides the CI
|
|
157
|
+
verdict (worst-wins across your org + project rules), so a build blocks on the
|
|
158
|
+
policies you defined — not just a fixed severity threshold. Two things follow:
|
|
159
|
+
|
|
160
|
+
- **Findings you've triaged away don't re-block the build.** If a security owner
|
|
161
|
+
has **accepted the risk** or **ignored** a finding in the platform, the gate
|
|
162
|
+
records the policy hit for transparency but no longer counts it toward
|
|
163
|
+
BLOCK/FLAG. Matching is per file+line and survives across scan sources, and an
|
|
164
|
+
accepted-risk that has **expired** re-blocks automatically.
|
|
165
|
+
- **Mandatory guardrails are exempt** — a finding that trips a policy marked
|
|
166
|
+
*mandatory* still blocks even if someone accepted the risk. Use a policy
|
|
167
|
+
exception for those.
|
|
168
|
+
|
|
169
|
+
### GitLab CI
|
|
170
|
+
|
|
171
|
+
```yaml
|
|
172
|
+
shomra-gate:
|
|
173
|
+
image: node:20
|
|
174
|
+
script:
|
|
175
|
+
- npx @shomra/agent gate --all . --strict
|
|
176
|
+
variables:
|
|
177
|
+
SHOMRA_API_KEY: $SHOMRA_API_KEY
|
|
178
|
+
SHOMRA_URL: $SHOMRA_URL
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### pre-commit (local, blocks risky artifacts before they land)
|
|
182
|
+
|
|
183
|
+
`.git/hooks/pre-commit` (or a [pre-commit](https://pre-commit.com) `local` hook):
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
#!/usr/bin/env bash
|
|
187
|
+
# Gate only the AI artifacts that changed in this commit.
|
|
188
|
+
git diff --cached --name-only --diff-filter=ACM \
|
|
189
|
+
| grep -Ei '(\.mcp\.json|SKILL\.md|CLAUDE\.md|AGENTS\.md|\.cursorrules|/\.claude/(commands|agents)/.*\.md|/\.claude/settings(\.local)?\.json)$' \
|
|
190
|
+
| while read -r f; do
|
|
191
|
+
npx @shomra/agent gate "$f" || exit 1
|
|
192
|
+
done
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Add `--json` anywhere to get machine-readable output for custom reporting.
|
|
196
|
+
|
|
197
|
+
## Runtime firewall
|
|
198
|
+
|
|
199
|
+
`shomra install-hook [--agent claude|cursor|windsurf|gemini|codex|copilot|cline|aider|all]`
|
|
200
|
+
wires Shomra into a coding agent's own hooks. It is **tiered**: catastrophic tool
|
|
201
|
+
calls (`curl|sh`, reverse shells, base64 RCE, live secrets, injection) are
|
|
202
|
+
blocked on-machine with zero network; only policy-relevant calls escalate to the
|
|
203
|
+
backend, behind a short timeout + circuit breaker — so a slow or down backend
|
|
204
|
+
never freezes the agent. Fail-open by default; `SHOMRA_GUARD_STRICT=1` fails
|
|
205
|
+
closed on the server tier.
|
|
206
|
+
|
|
207
|
+
## Environment variables
|
|
208
|
+
|
|
209
|
+
| Var | Purpose |
|
|
210
|
+
|-----|---------|
|
|
211
|
+
| `SHOMRA_API_KEY` | Org API key (overrides config) |
|
|
212
|
+
| `SHOMRA_URL` | Backend URL (overrides config) |
|
|
213
|
+
| `SHOMRA_API_TIMEOUT_MS` | Per-request backend timeout (default 30000) |
|
|
214
|
+
| `SHOMRA_AGENT` | Agent-identity handle presented to `llm-proxy` + firewall |
|
|
215
|
+
| `SHOMRA_GUARD_STRICT` | `1` = firewall fails closed on the server tier |
|
|
216
|
+
| `SHOMRA_GUARD_LOCAL` | `0` = disable the on-machine Tier-0 guard |
|
|
217
|
+
| `SHOMRA_GUARD_TIMEOUT_MS` | Firewall per-call server timeout (default 2000) |
|
|
218
|
+
| `SHOMRA_GUARD_BREAKER_MS` | Skip the server this long after a failure (default 30000; `0` disables) |
|
|
219
|
+
|
|
220
|
+
Run `shomra help` for the full command reference.
|