actenon-scan 0.1.0__tar.gz

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.
Files changed (41) hide show
  1. actenon_scan-0.1.0/LICENSE +190 -0
  2. actenon_scan-0.1.0/PKG-INFO +152 -0
  3. actenon_scan-0.1.0/README.md +127 -0
  4. actenon_scan-0.1.0/actenon_scan/__init__.py +3 -0
  5. actenon_scan-0.1.0/actenon_scan/__main__.py +7 -0
  6. actenon_scan-0.1.0/actenon_scan/baseline.py +29 -0
  7. actenon_scan-0.1.0/actenon_scan/cli.py +162 -0
  8. actenon_scan-0.1.0/actenon_scan/detectors/__init__.py +1 -0
  9. actenon_scan-0.1.0/actenon_scan/detectors/guards.py +107 -0
  10. actenon_scan-0.1.0/actenon_scan/detectors/reachability.py +196 -0
  11. actenon_scan-0.1.0/actenon_scan/detectors/sinks.py +159 -0
  12. actenon_scan-0.1.0/actenon_scan/engine.py +200 -0
  13. actenon_scan-0.1.0/actenon_scan/report/__init__.py +1 -0
  14. actenon_scan-0.1.0/actenon_scan/report/json_out.py +37 -0
  15. actenon_scan-0.1.0/actenon_scan/report/pretty.py +32 -0
  16. actenon_scan-0.1.0/actenon_scan/report/sarif.py +78 -0
  17. actenon_scan-0.1.0/actenon_scan/rules/__init__.py +1 -0
  18. actenon_scan-0.1.0/actenon_scan/rules/default_rules.json +79 -0
  19. actenon_scan-0.1.0/actenon_scan/rules/loader.py +101 -0
  20. actenon_scan-0.1.0/actenon_scan/suppress.py +42 -0
  21. actenon_scan-0.1.0/actenon_scan.egg-info/PKG-INFO +152 -0
  22. actenon_scan-0.1.0/actenon_scan.egg-info/SOURCES.txt +39 -0
  23. actenon_scan-0.1.0/actenon_scan.egg-info/dependency_links.txt +1 -0
  24. actenon_scan-0.1.0/actenon_scan.egg-info/entry_points.txt +2 -0
  25. actenon_scan-0.1.0/actenon_scan.egg-info/requires.txt +7 -0
  26. actenon_scan-0.1.0/actenon_scan.egg-info/top_level.txt +3 -0
  27. actenon_scan-0.1.0/pyproject.toml +40 -0
  28. actenon_scan-0.1.0/setup.cfg +4 -0
  29. actenon_scan-0.1.0/tests/fixtures/safe/not_an_agent.py +13 -0
  30. actenon_scan-0.1.0/tests/fixtures/safe/refund_tool_actenon.py +15 -0
  31. actenon_scan-0.1.0/tests/fixtures/safe/refund_tool_generic.py +13 -0
  32. actenon_scan-0.1.0/tests/fixtures/vulnerable/delete_tool.py +19 -0
  33. actenon_scan-0.1.0/tests/fixtures/vulnerable/deploy_tool.py +12 -0
  34. actenon_scan-0.1.0/tests/fixtures/vulnerable/refund_tool.py +11 -0
  35. actenon_scan-0.1.0/tests/fixtures/vulnerable/replit_incident.py +16 -0
  36. actenon_scan-0.1.0/tests/test_baseline_suppress.py +58 -0
  37. actenon_scan-0.1.0/tests/test_cli.py +89 -0
  38. actenon_scan-0.1.0/tests/test_guards.py +26 -0
  39. actenon_scan-0.1.0/tests/test_reachability.py +27 -0
  40. actenon_scan-0.1.0/tests/test_sarif.py +56 -0
  41. actenon_scan-0.1.0/tests/test_sinks.py +36 -0
@@ -0,0 +1,190 @@
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 describing the origin of the Work and
141
+ 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
+ Copyright 2026 Actenon
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: actenon-scan
3
+ Version: 0.1.0
4
+ Summary: Defensive static-analysis scanner for the AI-agent execution gap.
5
+ Author: Actenon
6
+ License-Expression: Apache-2.0
7
+ Keywords: security,static-analysis,ai-agents,execution-gap,sast
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Security
15
+ Classifier: Topic :: Software Development :: Quality Assurance
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Provides-Extra: yaml
20
+ Requires-Dist: pyyaml>=6.0; extra == "yaml"
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=8.0; extra == "dev"
23
+ Requires-Dist: pyyaml>=6.0; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # actenon-scan
27
+
28
+ **Stop AI agents from taking consequential actions they were never authorised to take.**
29
+
30
+ `actenon-scan` is a defensive static-analysis scanner that finds the **execution gap**: places where a consequential, irreversible action (payment, deletion, deployment, access grant) is reachable from an AI-agent tool boundary **without** a preceding authority or proof check on that code path.
31
+
32
+ Think of it as Bandit or Semgrep — but scoped to one problem: **the Replit incident, where an agent took a destructive action it should not have.**
33
+
34
+ > Works on **any** Python repo. Does not require the repo to have adopted Actenon.
35
+
36
+ ## Quick start
37
+
38
+ ```bash
39
+ pip install actenon-scan
40
+ actenon-scan scan .
41
+ ```
42
+
43
+ Sample output:
44
+
45
+ ```
46
+ actenon-scan: 3 finding(s) in 3 file(s) (scanned 47 file(s))
47
+
48
+ refund_tool.py
49
+ 8:4 [HIGH] PAY-STRIPE-REFUND (payments)
50
+ stripe.Refund.create(payment_intent=payment_id, amount=amount)
51
+ confidence: high
52
+ Guard this payment call with actenon proof verification. See: https://github.com/Actenon/actenon-permit
53
+
54
+ delete_tool.py
55
+ 14:4 [HIGH] DATA-DELETE-SQL (data_destruction)
56
+ 'DELETE FROM {table_name}'
57
+ confidence: high
58
+ Guard this destructive call with actenon proof verification. See: https://github.com/Actenon/actenon-permit
59
+ ```
60
+
61
+ ## GitHub Action (SARIF + inline PR annotations)
62
+
63
+ ```yaml
64
+ name: actenon-scan
65
+ on: [pull_request]
66
+ jobs:
67
+ scan:
68
+ runs-on: ubuntu-latest
69
+ steps:
70
+ - uses: actions/checkout@v4
71
+ - uses: Actenon/actenon-scan@main
72
+ with:
73
+ path: .
74
+ fail-on: medium
75
+ # SARIF is automatically uploaded to GitHub code scanning
76
+ # — inline PR annotations appear automatically
77
+ ```
78
+
79
+ ## How it decides
80
+
81
+ A **finding** is raised when a **SINK** is (a) **AGENT-REACHABLE** and (b) **UNGUARDED**.
82
+
83
+ | Signal | What it means | Detection |
84
+ |---|---|---|
85
+ | **SINK** | A call to a consequential/irreversible operation (payment refund, DELETE FROM, kubectl apply, IAM grant) | AST pattern matching on call names + SQL string literals |
86
+ | **AGENT-REACHABLE** | The sink lives inside a registered agent tool (`@tool`, `@mcp.tool`, `@server.tool`, tool wrapper, or a class subclassing `BaseTool`) | AST decorator/wrapper/class detection |
87
+ | **UNGUARDED** | No preceding authority/proof check on the path to the sink within the same function | Lexical precedence check for guard calls (`verify_proof`, `authorize`, `check_permission`) or guard decorators |
88
+
89
+ If the sink is not agent-reachable (e.g., it's in a plain script with no agent framework imports), no finding is raised. This keeps false positives low.
90
+
91
+ If the sink is guarded (an `authorize()` or `verify_proof()` call appears before it in the same function, or the function has a guard decorator), no finding is raised.
92
+
93
+ ## Fix it
94
+
95
+ When `actenon-scan` flags a finding, the fix is to add a **proof-bound authority check** before the consequential call:
96
+
97
+ ```python
98
+ # BEFORE (flagged)
99
+ @tool
100
+ def process_refund(payment_id: str, amount: int):
101
+ stripe.Refund.create(payment_intent=payment_id, amount=amount)
102
+
103
+ # AFTER (clean)
104
+ @tool
105
+ def process_refund(payment_id: str, amount: int):
106
+ from actenon import verify_proof
107
+ verify_proof(action="refund", target=payment_id, amount=amount)
108
+ stripe.Refund.create(payment_intent=payment_id, amount=amount)
109
+ ```
110
+
111
+ The scanner recognises both **Actenon guards** (`verify_proof`, `require_proof`, `actenon.*`) and **generic guards** (`authorize`, `check_permission`, `require_approval`). So even if you don't adopt Actenon, adding a guard silences the finding — the tool is honestly useful to non-adopters.
112
+
113
+ - **[actenon-kernel](https://github.com/Actenon/actenon-kernel)** — the open proof gate
114
+ - **[actenon-permit](https://github.com/Actenon/actenon-permit)** — the developer-first issuer + PDP + broker
115
+
116
+ ## Suppression
117
+
118
+ If a finding is a false positive, suppress it inline:
119
+
120
+ ```python
121
+ # actenon-scan: ignore[PAY-STRIPE-REFUND]
122
+ stripe.Refund.create(...)
123
+ ```
124
+
125
+ Or use a baseline to suppress already-known findings:
126
+
127
+ ```bash
128
+ actenon-scan scan . --format json > baseline.json
129
+ # Future runs suppress these:
130
+ actenon-scan scan . --baseline baseline.json
131
+ ```
132
+
133
+ ## CLI
134
+
135
+ ```
136
+ actenon-scan scan <path> [--format pretty|json|sarif] [--fail-on none|low|medium|high]
137
+ [--config config.json] [--baseline baseline.json]
138
+ [--include GLOB]... [--exclude GLOB]...
139
+ actenon-scan rules # list active rules
140
+ actenon-scan init # write a default config
141
+ ```
142
+
143
+ ## Exit codes
144
+
145
+ - `0` — no findings at or above the `--fail-on` threshold (default: `medium`)
146
+ - `1` — findings present at or above the threshold
147
+
148
+ This makes the tool CI-gating.
149
+
150
+ ## License
151
+
152
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,127 @@
1
+ # actenon-scan
2
+
3
+ **Stop AI agents from taking consequential actions they were never authorised to take.**
4
+
5
+ `actenon-scan` is a defensive static-analysis scanner that finds the **execution gap**: places where a consequential, irreversible action (payment, deletion, deployment, access grant) is reachable from an AI-agent tool boundary **without** a preceding authority or proof check on that code path.
6
+
7
+ Think of it as Bandit or Semgrep — but scoped to one problem: **the Replit incident, where an agent took a destructive action it should not have.**
8
+
9
+ > Works on **any** Python repo. Does not require the repo to have adopted Actenon.
10
+
11
+ ## Quick start
12
+
13
+ ```bash
14
+ pip install actenon-scan
15
+ actenon-scan scan .
16
+ ```
17
+
18
+ Sample output:
19
+
20
+ ```
21
+ actenon-scan: 3 finding(s) in 3 file(s) (scanned 47 file(s))
22
+
23
+ refund_tool.py
24
+ 8:4 [HIGH] PAY-STRIPE-REFUND (payments)
25
+ stripe.Refund.create(payment_intent=payment_id, amount=amount)
26
+ confidence: high
27
+ Guard this payment call with actenon proof verification. See: https://github.com/Actenon/actenon-permit
28
+
29
+ delete_tool.py
30
+ 14:4 [HIGH] DATA-DELETE-SQL (data_destruction)
31
+ 'DELETE FROM {table_name}'
32
+ confidence: high
33
+ Guard this destructive call with actenon proof verification. See: https://github.com/Actenon/actenon-permit
34
+ ```
35
+
36
+ ## GitHub Action (SARIF + inline PR annotations)
37
+
38
+ ```yaml
39
+ name: actenon-scan
40
+ on: [pull_request]
41
+ jobs:
42
+ scan:
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - uses: actions/checkout@v4
46
+ - uses: Actenon/actenon-scan@main
47
+ with:
48
+ path: .
49
+ fail-on: medium
50
+ # SARIF is automatically uploaded to GitHub code scanning
51
+ # — inline PR annotations appear automatically
52
+ ```
53
+
54
+ ## How it decides
55
+
56
+ A **finding** is raised when a **SINK** is (a) **AGENT-REACHABLE** and (b) **UNGUARDED**.
57
+
58
+ | Signal | What it means | Detection |
59
+ |---|---|---|
60
+ | **SINK** | A call to a consequential/irreversible operation (payment refund, DELETE FROM, kubectl apply, IAM grant) | AST pattern matching on call names + SQL string literals |
61
+ | **AGENT-REACHABLE** | The sink lives inside a registered agent tool (`@tool`, `@mcp.tool`, `@server.tool`, tool wrapper, or a class subclassing `BaseTool`) | AST decorator/wrapper/class detection |
62
+ | **UNGUARDED** | No preceding authority/proof check on the path to the sink within the same function | Lexical precedence check for guard calls (`verify_proof`, `authorize`, `check_permission`) or guard decorators |
63
+
64
+ If the sink is not agent-reachable (e.g., it's in a plain script with no agent framework imports), no finding is raised. This keeps false positives low.
65
+
66
+ If the sink is guarded (an `authorize()` or `verify_proof()` call appears before it in the same function, or the function has a guard decorator), no finding is raised.
67
+
68
+ ## Fix it
69
+
70
+ When `actenon-scan` flags a finding, the fix is to add a **proof-bound authority check** before the consequential call:
71
+
72
+ ```python
73
+ # BEFORE (flagged)
74
+ @tool
75
+ def process_refund(payment_id: str, amount: int):
76
+ stripe.Refund.create(payment_intent=payment_id, amount=amount)
77
+
78
+ # AFTER (clean)
79
+ @tool
80
+ def process_refund(payment_id: str, amount: int):
81
+ from actenon import verify_proof
82
+ verify_proof(action="refund", target=payment_id, amount=amount)
83
+ stripe.Refund.create(payment_intent=payment_id, amount=amount)
84
+ ```
85
+
86
+ The scanner recognises both **Actenon guards** (`verify_proof`, `require_proof`, `actenon.*`) and **generic guards** (`authorize`, `check_permission`, `require_approval`). So even if you don't adopt Actenon, adding a guard silences the finding — the tool is honestly useful to non-adopters.
87
+
88
+ - **[actenon-kernel](https://github.com/Actenon/actenon-kernel)** — the open proof gate
89
+ - **[actenon-permit](https://github.com/Actenon/actenon-permit)** — the developer-first issuer + PDP + broker
90
+
91
+ ## Suppression
92
+
93
+ If a finding is a false positive, suppress it inline:
94
+
95
+ ```python
96
+ # actenon-scan: ignore[PAY-STRIPE-REFUND]
97
+ stripe.Refund.create(...)
98
+ ```
99
+
100
+ Or use a baseline to suppress already-known findings:
101
+
102
+ ```bash
103
+ actenon-scan scan . --format json > baseline.json
104
+ # Future runs suppress these:
105
+ actenon-scan scan . --baseline baseline.json
106
+ ```
107
+
108
+ ## CLI
109
+
110
+ ```
111
+ actenon-scan scan <path> [--format pretty|json|sarif] [--fail-on none|low|medium|high]
112
+ [--config config.json] [--baseline baseline.json]
113
+ [--include GLOB]... [--exclude GLOB]...
114
+ actenon-scan rules # list active rules
115
+ actenon-scan init # write a default config
116
+ ```
117
+
118
+ ## Exit codes
119
+
120
+ - `0` — no findings at or above the `--fail-on` threshold (default: `medium`)
121
+ - `1` — findings present at or above the threshold
122
+
123
+ This makes the tool CI-gating.
124
+
125
+ ## License
126
+
127
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,3 @@
1
+ """actenon-scan: defensive static-analysis scanner for the AI-agent execution gap."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,7 @@
1
+ """actenon-scan entry point for python -m actenon_scan."""
2
+ import sys
3
+
4
+ from actenon_scan.cli import main
5
+
6
+ if __name__ == "__main__":
7
+ sys.exit(main())
@@ -0,0 +1,29 @@
1
+ """Baseline — load, compare, and suppress known findings."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ from pathlib import Path
7
+ from typing import Any
8
+
9
+
10
+ def write_baseline(findings: list[dict[str, Any]], output_path: str | Path) -> None:
11
+ """Write findings to a baseline JSON file."""
12
+ baseline: dict[str, Any] = {"version": "1", "findings": findings}
13
+ Path(output_path).write_text(json.dumps(baseline, indent=2) + "\n", encoding="utf-8")
14
+
15
+
16
+ def load_baseline(baseline_path: str | Path) -> dict[str, set[str]]:
17
+ """Load a baseline file and return a dict mapping filename -> set of snippet hashes.
18
+
19
+ The baseline is matched on (file, rule_id, snippet_hash) — resilient to
20
+ line-number drift.
21
+ """
22
+ data = json.loads(Path(baseline_path).read_text(encoding="utf-8"))
23
+ result: dict[str, set[str]] = {}
24
+ for finding in data.get("findings", []):
25
+ filename = finding.get("file", "")
26
+ snippet_hash = finding.get("snippet_hash", "")
27
+ if filename and snippet_hash:
28
+ result.setdefault(filename, set()).add(snippet_hash)
29
+ return result
@@ -0,0 +1,162 @@
1
+ """actenon-scan CLI — argparse-based command-line interface."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import sys
8
+ from pathlib import Path
9
+
10
+ from actenon_scan.engine import ScanResult, SEVERITY_ORDER, scan_path
11
+ from actenon_scan.report.json_out import format_json
12
+ from actenon_scan.report.pretty import format_pretty
13
+ from actenon_scan.report.sarif import format_sarif
14
+ from actenon_scan.suppress import collect_suppressions_from_file
15
+
16
+
17
+ def main(argv: list[str] | None = None) -> int:
18
+ parser = argparse.ArgumentParser(
19
+ prog="actenon-scan",
20
+ description="Defensive static-analysis scanner for the AI-agent execution gap.",
21
+ )
22
+ subparsers = parser.add_subparsers(dest="command")
23
+
24
+ # scan
25
+ scan_parser = subparsers.add_parser("scan", help="Scan a path for the execution gap.")
26
+ scan_parser.add_argument("path", help="File or directory to scan.")
27
+ scan_parser.add_argument("--format", choices=["pretty", "json", "sarif"], default="pretty")
28
+ scan_parser.add_argument("--fail-on", choices=["none", "low", "medium", "high"], default="medium")
29
+ scan_parser.add_argument("--config", help="Path to config file (JSON or YAML).")
30
+ scan_parser.add_argument("--baseline", help="Path to baseline.json for known-findings suppression.")
31
+ scan_parser.add_argument("--include", action="append", default=None, help="Glob pattern to include (repeatable).")
32
+ scan_parser.add_argument("--exclude", action="append", default=None, help="Glob pattern to exclude (repeatable).")
33
+ scan_parser.add_argument("--output", "-o", default=None, help="Write output to file instead of stdout.")
34
+
35
+ # rules
36
+ rules_parser = subparsers.add_parser("rules", help="List active rules.")
37
+
38
+ # init
39
+ init_parser = subparsers.add_parser("init", help="Write a default config file.")
40
+ init_parser.add_argument("--format", choices=["json", "yaml", "yml"], default="json")
41
+
42
+ args = parser.parse_args(argv)
43
+
44
+ if args.command == "scan":
45
+ return _cmd_scan(args)
46
+ elif args.command == "rules":
47
+ return _cmd_rules(args)
48
+ elif args.command == "init":
49
+ return _cmd_init(args)
50
+ else:
51
+ parser.print_help()
52
+ return 0
53
+
54
+
55
+ def _cmd_scan(args: argparse.Namespace) -> int:
56
+ target = Path(args.path)
57
+ if not target.exists():
58
+ print(f"Error: path not found: {target}", file=sys.stderr)
59
+ return 2
60
+
61
+ # Load baseline
62
+ baseline = None
63
+ if args.baseline:
64
+ from actenon_scan.baseline import load_baseline
65
+ baseline = load_baseline(args.baseline)
66
+
67
+ # Collect suppressions
68
+ suppressions: set[tuple[str, str]] = set()
69
+ if target.is_file():
70
+ suppressions = collect_suppressions_from_file(target)
71
+ else:
72
+ import fnmatch
73
+ for filepath in target.rglob("*.py"):
74
+ suppressions.update(collect_suppressions_from_file(filepath))
75
+
76
+ result = scan_path(
77
+ target,
78
+ config=args.config,
79
+ include_globs=args.include,
80
+ exclude_globs=args.exclude,
81
+ suppressions=suppressions,
82
+ baseline_findings=baseline,
83
+ )
84
+
85
+ # Format output
86
+ if args.format == "json":
87
+ output = format_json(result)
88
+ elif args.format == "sarif":
89
+ output = format_sarif(result)
90
+ else:
91
+ output = format_pretty(result)
92
+
93
+ if args.output:
94
+ Path(args.output).write_text(output)
95
+ else:
96
+ print(output, end="")
97
+
98
+ # Exit code
99
+ if args.fail_on == "none":
100
+ return 0
101
+ if result.has_findings_at_or_above(args.fail_on):
102
+ return 1
103
+ return 0
104
+
105
+
106
+ def _cmd_rules(args: argparse.Namespace) -> int:
107
+ from actenon_scan.rules.loader import load_default_rules
108
+ rules = load_default_rules()
109
+ print(f"actenon-scan rules (version {rules.version})")
110
+ print(f" {len(rules.sinks)} sink rule(s), {len(rules.guard_patterns)} guard pattern(s)")
111
+ print("")
112
+ for sink in rules.sinks:
113
+ print(f" [{sink.severity.upper():6s}] {sink.id:30s} {sink.category}")
114
+ print(f" {sink.description}")
115
+ print("")
116
+ print(" Guard patterns:")
117
+ for g in rules.guard_patterns:
118
+ print(f" - {g}")
119
+ return 0
120
+
121
+
122
+ def _cmd_init(args: argparse.Namespace) -> int:
123
+ config = {
124
+ "version": "1",
125
+ "sinks": [],
126
+ "guards": [
127
+ {"patterns": ["my_custom_authorize", "my_org_verify_permission"]}
128
+ ],
129
+ "reachability": {
130
+ "tool_decorators": [],
131
+ "tool_wrappers": [],
132
+ "tool_base_classes": [],
133
+ "tool_methods": [],
134
+ "agent_frameworks": []
135
+ }
136
+ }
137
+ if args.format == "json":
138
+ path = "actenon-scan.json"
139
+ content = json.dumps(config, indent=2) + "\n"
140
+ else:
141
+ path = "actenon-scan.yml"
142
+ lines = ["# actenon-scan configuration", ""]
143
+ lines.append("# Add your custom guard patterns here:")
144
+ lines.append("guards:")
145
+ lines.append(" - patterns:")
146
+ lines.append(" - my_custom_authorize")
147
+ lines.append(" - my_org_verify_permission")
148
+ lines.append("")
149
+ lines.append("# Add your custom sink rules here:")
150
+ lines.append("# sinks:")
151
+ lines.append("# - id: CUSTOM-SINK")
152
+ lines.append("# category: custom")
153
+ lines.append("# severity: high")
154
+ lines.append("# description: Custom sink")
155
+ lines.append("# match:")
156
+ lines.append("# type: name_call")
157
+ lines.append("# func_patterns: [\"my_dangerous_function\"]")
158
+ content = "\n".join(lines) + "\n"
159
+
160
+ Path(path).write_text(content)
161
+ print(f"Wrote default config to {path}")
162
+ return 0
@@ -0,0 +1 @@
1
+ """Detectors subpackage."""