karnak-scan 0.2.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.
- karnak_scan-0.2.0/LICENSE +202 -0
- karnak_scan-0.2.0/NOTICE +4 -0
- karnak_scan-0.2.0/PKG-INFO +356 -0
- karnak_scan-0.2.0/README.md +328 -0
- karnak_scan-0.2.0/karnak_scan/__init__.py +19 -0
- karnak_scan-0.2.0/karnak_scan/__main__.py +7 -0
- karnak_scan-0.2.0/karnak_scan/app.py +48 -0
- karnak_scan-0.2.0/karnak_scan/cli.py +1055 -0
- karnak_scan-0.2.0/karnak_scan/core/__init__.py +3 -0
- karnak_scan-0.2.0/karnak_scan/core/cache.py +584 -0
- karnak_scan-0.2.0/karnak_scan/core/context.py +247 -0
- karnak_scan-0.2.0/karnak_scan/core/engine.py +319 -0
- karnak_scan-0.2.0/karnak_scan/core/finding.py +200 -0
- karnak_scan-0.2.0/karnak_scan/core/git.py +186 -0
- karnak_scan-0.2.0/karnak_scan/core/heuristics.py +299 -0
- karnak_scan-0.2.0/karnak_scan/core/http.py +868 -0
- karnak_scan-0.2.0/karnak_scan/core/redact.py +120 -0
- karnak_scan-0.2.0/karnak_scan/core/rules.py +275 -0
- karnak_scan-0.2.0/karnak_scan/core/suppress.py +393 -0
- karnak_scan-0.2.0/karnak_scan/core/textutil.py +39 -0
- karnak_scan-0.2.0/karnak_scan/core/walker.py +453 -0
- karnak_scan-0.2.0/karnak_scan/modules/__init__.py +17 -0
- karnak_scan-0.2.0/karnak_scan/modules/artifacts.py +407 -0
- karnak_scan-0.2.0/karnak_scan/modules/cicd.py +461 -0
- karnak_scan-0.2.0/karnak_scan/modules/deps.py +1840 -0
- karnak_scan-0.2.0/karnak_scan/modules/githist.py +259 -0
- karnak_scan-0.2.0/karnak_scan/modules/patterns.py +1824 -0
- karnak_scan-0.2.0/karnak_scan/modules/secrets.py +254 -0
- karnak_scan-0.2.0/karnak_scan/report/__init__.py +45 -0
- karnak_scan-0.2.0/karnak_scan/report/html.py +386 -0
- karnak_scan-0.2.0/karnak_scan/report/json_out.py +151 -0
- karnak_scan-0.2.0/karnak_scan/report/payload.py +497 -0
- karnak_scan-0.2.0/karnak_scan/report/sarif.py +426 -0
- karnak_scan-0.2.0/karnak_scan/report/terminal.py +586 -0
- karnak_scan-0.2.0/karnak_scan/rules/patterns_compiled.json +308 -0
- karnak_scan-0.2.0/karnak_scan/rules/patterns_generic.json +182 -0
- karnak_scan-0.2.0/karnak_scan/rules/patterns_iac.json +240 -0
- karnak_scan-0.2.0/karnak_scan/rules/patterns_javascript.json +314 -0
- karnak_scan-0.2.0/karnak_scan/rules/patterns_scripting.json +319 -0
- karnak_scan-0.2.0/karnak_scan/rules/secrets.json +567 -0
- karnak_scan-0.2.0/karnak_scan/ui.py +674 -0
- karnak_scan-0.2.0/karnak_scan/web/__init__.py +1 -0
- karnak_scan-0.2.0/karnak_scan/web/brand.py +273 -0
- karnak_scan-0.2.0/karnak_scan/web/server.py +661 -0
- karnak_scan-0.2.0/karnak_scan.egg-info/PKG-INFO +356 -0
- karnak_scan-0.2.0/karnak_scan.egg-info/SOURCES.txt +50 -0
- karnak_scan-0.2.0/karnak_scan.egg-info/dependency_links.txt +1 -0
- karnak_scan-0.2.0/karnak_scan.egg-info/entry_points.txt +3 -0
- karnak_scan-0.2.0/karnak_scan.egg-info/requires.txt +9 -0
- karnak_scan-0.2.0/karnak_scan.egg-info/top_level.txt +1 -0
- karnak_scan-0.2.0/pyproject.toml +51 -0
- karnak_scan-0.2.0/setup.cfg +4 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
karnak_scan-0.2.0/NOTICE
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: karnak-scan
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Security reconnaissance for codebases: secrets, dangerous patterns, supply chain, attack surface, and gated live probing
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/celestial-zenny/Karnak
|
|
7
|
+
Project-URL: Source, https://github.com/celestial-zenny/Karnak
|
|
8
|
+
Project-URL: Issues, https://github.com/celestial-zenny/Karnak/issues
|
|
9
|
+
Project-URL: Releases, https://github.com/celestial-zenny/Karnak/releases
|
|
10
|
+
Keywords: security,sast,secrets,recon,karnak,sarif,supply-chain
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Information Technology
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Security
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
License-File: NOTICE
|
|
21
|
+
Provides-Extra: pretty
|
|
22
|
+
Requires-Dist: rich>=13.0; extra == "pretty"
|
|
23
|
+
Provides-Extra: yaml
|
|
24
|
+
Requires-Dist: pyyaml>=6.0; extra == "yaml"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# Karnak
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Security reconnaissance for codebases. Finds hardcoded credentials, dangerous code
|
|
33
|
+
patterns, known-vulnerable dependencies, files that should never have been committed,
|
|
34
|
+
secrets deleted from the code but still in git history, and risky CI/CD setups. It
|
|
35
|
+
reports them to your terminal, to JSON, to SARIF for GitHub code scanning, or to a
|
|
36
|
+
plain-English HTML report you can hand to a client. Prefer not to use a terminal?
|
|
37
|
+
`karnak ui` runs it as a page in your browser.
|
|
38
|
+
|
|
39
|
+
Runs on the Python standard library alone. No install of anything else required.
|
|
40
|
+
|
|
41
|
+
> **Status: alpha (0.2.0), and honest about it.** The codebase scanner works end to end
|
|
42
|
+
> and is what you should try. The live-probing phase is gated, refuses to run, and has
|
|
43
|
+
> no modules behind it yet. See [What works today](#what-works-today) and the
|
|
44
|
+
> [roadmap](#roadmap) before you judge it.
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
$ karnak code .
|
|
48
|
+
|
|
49
|
+
high high pattern.python.os-system patterns · via ast (parsed code)
|
|
50
|
+
Command executed through a shell
|
|
51
|
+
deploy.py:14:5
|
|
52
|
+
os.system("rsync -a " + target)
|
|
53
|
+
fix: Use `subprocess.run([...])` with an argument list and no shell.
|
|
54
|
+
|
|
55
|
+
high high secret.aws.access-key-id secrets · via regex (heuristic)
|
|
56
|
+
AWS access key ID
|
|
57
|
+
config/settings.py:8:22
|
|
58
|
+
AWS_KEY = "AKIA...LE (20 chars)"
|
|
59
|
+
fix: Deactivate the key in IAM immediately, then remove it from the file and from
|
|
60
|
+
git history. Use IAM roles or a credential provider chain instead of static keys.
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
Python 3.9 or newer.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install karnak-scan
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
That gives you the `karnak` command. To install from source instead:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git clone https://github.com/celestial-zenny/karnak.git
|
|
75
|
+
cd karnak
|
|
76
|
+
pip install .
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or run it straight from a clone without installing:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
python3 -m karnak_scan.cli code /path/to/project
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Two optional extras, both with working fallbacks:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install 'karnak-scan[pretty]' # rich tables instead of the plain ANSI renderer
|
|
89
|
+
pip install 'karnak-scan[yaml]' # load YAML-authored custom rule packs (bundled packs are JSON)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## No terminal? Use the app
|
|
93
|
+
|
|
94
|
+
**Download it.** Each [release](https://github.com/celestial-zenny/Karnak/releases) has a
|
|
95
|
+
ready-to-run app; nothing else to install, not even Python. The latest is
|
|
96
|
+
[v0.2.0](https://github.com/celestial-zenny/Karnak/releases/tag/v0.2.0).
|
|
97
|
+
|
|
98
|
+
| System | Download | First launch |
|
|
99
|
+
|--------|----------|--------------|
|
|
100
|
+
| Windows | `Karnak-windows.exe` | Windows SmartScreen may warn about an unrecognised app: **More info → Run anyway**. A small window shows the link; closing it stops Karnak. |
|
|
101
|
+
| macOS | `Karnak-macos.zip` | Unzip, then **right-click Karnak → Open → Open** the first time (macOS blocks apps from unidentified developers on a plain double-click). |
|
|
102
|
+
| Linux | `Karnak-linux.tar.gz` | `tar xzf Karnak-linux.tar.gz && ./Karnak` |
|
|
103
|
+
|
|
104
|
+
The warnings appear because the app is not yet code-signed, which needs a paid Apple
|
|
105
|
+
Developer account and a Windows signing certificate. The builds are made in public by
|
|
106
|
+
`.github/workflows/app.yml` from this repository's source.
|
|
107
|
+
|
|
108
|
+
Double-click it and it opens in your browser at your home folder. **Quit** in the page
|
|
109
|
+
stops it, and it also stops by itself 15 minutes after the page is closed. Given
|
|
110
|
+
arguments, the same file is the full command line: `Karnak-windows.exe code . --html report.html`.
|
|
111
|
+
|
|
112
|
+
**Or, with Python installed:**
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
karnak ui
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This opens Karnak in your web browser. Pick a project folder, press **Scan**, and
|
|
119
|
+
read the results as plain-English cards, each with how to fix it. **Download report**
|
|
120
|
+
saves the same page as a single HTML file you can email or print to PDF.
|
|
121
|
+
|
|
122
|
+
Everything runs on your computer: the app only accepts connections from this machine,
|
|
123
|
+
and your code is never uploaded. The one thing sent anywhere is the optional dependency
|
|
124
|
+
check, which sends package names and versions (not code) to OSV.dev; untick it to skip.
|
|
125
|
+
|
|
126
|
+
## Online scanner (`karnak web`)
|
|
127
|
+
|
|
128
|
+
A website where anyone can paste a **public** GitHub repository and get the same report
|
|
129
|
+
in the browser, with downloads. It is not hosted anywhere yet; you can run it yourself.
|
|
130
|
+
It is built for strangers to use:
|
|
131
|
+
|
|
132
|
+
- Only `github.com/owner/repo` is accepted; the clone URL is rebuilt from those two
|
|
133
|
+
names and git is restricted to https, so no input can reach another host or the disk.
|
|
134
|
+
- Per-client hourly quota, a worker pool and queue limit, a clone timeout and size cap.
|
|
135
|
+
- The clone is deleted as soon as the scan ends; reports live in memory for an hour.
|
|
136
|
+
- No cookies or accounts; strict CSP with per-response script nonces.
|
|
137
|
+
|
|
138
|
+
Run it locally with `karnak web`, or deploy the included container:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
fly launch --copy-config --no-deploy # once: pick a unique app name in fly.toml
|
|
142
|
+
fly deploy
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Settings are environment variables: `KARNAK_WORKERS`, `KARNAK_SCANS_PER_HOUR`,
|
|
146
|
+
`KARNAK_MAX_REPO_MB`, `KARNAK_CLONE_DEPTH`, `KARNAK_CLIENT_IP_HEADER` (set to the header
|
|
147
|
+
your proxy puts the real client address in, e.g. `Fly-Client-IP`; never trust it
|
|
148
|
+
otherwise), `KARNAK_HSTS=1` behind TLS.
|
|
149
|
+
|
|
150
|
+
## Usage
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
karnak code . # scan the current directory
|
|
154
|
+
karnak code . --json report.json # machine-readable report
|
|
155
|
+
karnak code . --sarif recon.sarif # upload to GitHub code scanning
|
|
156
|
+
karnak code . --html report.html # a self-contained report for a client or a manager
|
|
157
|
+
karnak code . -v # show every finding, not just a summary
|
|
158
|
+
karnak rules --search sql # what does it actually look for?
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Exit codes are built for CI:
|
|
162
|
+
|
|
163
|
+
| Code | Meaning |
|
|
164
|
+
|------|---------|
|
|
165
|
+
| `0` | clean, or nothing at or above `--fail-on` |
|
|
166
|
+
| `1` | a finding at or above `--fail-on` survived (default: `high`) |
|
|
167
|
+
| `2` | the tool itself errored, or a module failed |
|
|
168
|
+
|
|
169
|
+
`2` outranks `1` on purpose. An incomplete scan must never report "found things" as if
|
|
170
|
+
the scan were whole.
|
|
171
|
+
|
|
172
|
+
### Proxies: Burp, client networks, corporate CI
|
|
173
|
+
|
|
174
|
+
Network traffic (today, only OSV.dev lookups for `deps`) goes direct unless you name a
|
|
175
|
+
proxy. An ambient `HTTPS_PROXY` is deliberately ignored, so a scan never sends data
|
|
176
|
+
somewhere you did not choose.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
karnak code . --proxy http://127.0.0.1:8080 --ca-bundle burp-ca.pem # through Burp
|
|
180
|
+
karnak code . --proxy "$HTTPS_PROXY" # corporate CI
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`--ca-bundle` *adds* a CA to the system trust store, for an intercepting proxy.
|
|
184
|
+
Certificate verification is never switched off. Proxy passwords are masked in every
|
|
185
|
+
report and error.
|
|
186
|
+
|
|
187
|
+
### Tests, fixtures, docs and examples
|
|
188
|
+
|
|
189
|
+
Code patterns and generic secrets (`password = "..."`, JWTs, `user:pass@` URLs) found in
|
|
190
|
+
test, fixture, doc and example paths are **hidden by default and always counted**: the
|
|
191
|
+
report says how many, and `--include-tests` shows them. Vendor-format credentials
|
|
192
|
+
(`AKIA...`, `ghp_...`, `xoxb-...`) and private keys are reported wherever they are,
|
|
193
|
+
because real ones leak through test files constantly.
|
|
194
|
+
|
|
195
|
+
Test paths are recognised by name (`tests/`, `spec/`, `fixtures/`, `docs/`, `examples/`,
|
|
196
|
+
`test_*.py`, `*.spec.ts`, ...). A production file that happens to be named like a test is
|
|
197
|
+
hidden too; on an assessment where that matters, pass `--include-tests`.
|
|
198
|
+
|
|
199
|
+
### Adopting it on a codebase that already has findings
|
|
200
|
+
|
|
201
|
+
Record what's there today, then fail the build only on what's new:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
karnak baseline -o karnak-baseline.json .
|
|
205
|
+
karnak code . --baseline karnak-baseline.json
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Baselines omit code snippets by design, so a committed baseline can never carry a
|
|
209
|
+
credential.
|
|
210
|
+
|
|
211
|
+
To silence one finding in place, on its line or the line above:
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
password = get_from_vault() # karnak:ignore[secret.generic.password]
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Suppression fails closed. If a file can't be re-read, or a finding has no line, it is
|
|
218
|
+
**kept** with a note rather than dropped.
|
|
219
|
+
|
|
220
|
+
### CI example
|
|
221
|
+
|
|
222
|
+
```yaml
|
|
223
|
+
- run: pip install git+https://github.com/celestial-zenny/karnak.git
|
|
224
|
+
- run: karnak code . --sarif recon.sarif --baseline karnak-baseline.json
|
|
225
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
226
|
+
if: always()
|
|
227
|
+
with:
|
|
228
|
+
sarif_file: recon.sarif
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## What works today
|
|
232
|
+
|
|
233
|
+
**Working, and dogfooded on this repo:**
|
|
234
|
+
|
|
235
|
+
- **`secrets`** — hardcoded credentials, API tokens, private key material.
|
|
236
|
+
- **`patterns`** — 183 checks total: **26 real AST checks** for Python and **157 regex
|
|
237
|
+
rules** across generic, JavaScript, IaC, scripting, and compiled-language packs.
|
|
238
|
+
- **`deps`** — dependency manifests resolved against [OSV.dev](https://osv.dev)
|
|
239
|
+
advisories, with an on-disk cache. `--offline` skips it *with a recorded reason*
|
|
240
|
+
rather than silently passing. `--proxy` routes it through Burp or a corporate proxy.
|
|
241
|
+
- **Reporting** — terminal, JSON, SARIF 2.1.0 (with `security-severity`,
|
|
242
|
+
`partialFingerprints`, and `executionSuccessful`, which is what GitHub actually reads),
|
|
243
|
+
and HTML: one self-contained file with a plain-English verdict, repeated findings
|
|
244
|
+
grouped into one issue, and the fix beside each. It makes no network requests and
|
|
245
|
+
forbids scripts, so it is safe to open on an air-gapped machine or send to a client.
|
|
246
|
+
- **`karnak ui`** — the same scan and report in a local browser page, for people who do
|
|
247
|
+
not use a terminal. Loopback only, token-protected, nothing uploaded.
|
|
248
|
+
- **Double-click app** — `karnak ui` packaged for Windows, macOS and Linux, built and
|
|
249
|
+
smoke-tested in CI. No Python needed.
|
|
250
|
+
- **`karnak web`** — a self-hostable scanner site for public GitHub repositories.
|
|
251
|
+
- **Baselines and inline suppression.**
|
|
252
|
+
- **`artifacts`** — files that should never be committed: `.env`, private keys and
|
|
253
|
+
keystores, Terraform state, `.npmrc`/`.pypirc`/`.netrc`/`.git-credentials` with
|
|
254
|
+
credentials, shell histories, database dumps, backups. Uses `git ls-files`, so files
|
|
255
|
+
force-added past `.gitignore` are caught, and warns about sensitive files that are not
|
|
256
|
+
committed yet but not ignored either. `.env` findings name the variables, never values.
|
|
257
|
+
- **`githist`** — secrets that were deleted from the code but are still in git history.
|
|
258
|
+
They look fixed, are in every clone, and are rarely rotated. The added lines of the
|
|
259
|
+
last `--history-depth` commits on every branch go through the same secret rules;
|
|
260
|
+
anything still in the code is left to `secrets`, so each key is reported once, at the
|
|
261
|
+
commit that introduced it.
|
|
262
|
+
- **`cicd`** — GitHub Actions workflows: untrusted event text (issue titles, PR
|
|
263
|
+
branch names, comment bodies) pasted into `run:` or `script:` bodies, critical on
|
|
264
|
+
privileged triggers; `pull_request_target` workflows that check out the PR's code;
|
|
265
|
+
third-party actions on a tag or branch instead of a commit (one finding per action);
|
|
266
|
+
`write-all` tokens; re-enabled unsafe commands. Dockerfiles: final stage running as
|
|
267
|
+
root, unpinned base images, secrets in `ENV`/`ARG` (masked), `ADD` of a URL without a
|
|
268
|
+
checksum.
|
|
269
|
+
|
|
270
|
+
`artifacts` and `githist` run git with the repository's own hooks, diff drivers,
|
|
271
|
+
textconv filters and fsmonitor disabled, so scanning an untrusted repository cannot
|
|
272
|
+
execute code from its `.git/config`.
|
|
273
|
+
|
|
274
|
+
**Not built yet:**
|
|
275
|
+
|
|
276
|
+
- `surface` (route extraction, unauthenticated state-changing endpoints)
|
|
277
|
+
- `live/` (DNS, certificate transparency, TCP connect, TLS, HTTP headers). The CLI
|
|
278
|
+
surface exists and the authorization gate is implemented and tested, but there are no
|
|
279
|
+
probe modules behind it. `karnak live` will refuse to do anything useful.
|
|
280
|
+
- A committed clean-code fixture. Noise is measured instead by `dev/corpus.py` (below);
|
|
281
|
+
**expect some noise** while it comes down. Current smoke coverage: 12 suites, all passing.
|
|
282
|
+
|
|
283
|
+
## Roadmap
|
|
284
|
+
|
|
285
|
+
Karnak is aimed at pentesters and security consultants first; a paid scan service for
|
|
286
|
+
AI-built apps comes later.
|
|
287
|
+
|
|
288
|
+
| Phase | What | State |
|
|
289
|
+
|-------|------|-------|
|
|
290
|
+
| 1. Trust | Noise brought down on real code (`dev/corpus.py`), missed secrets fixed, `--proxy` / `--ca-bundle` | **Done** |
|
|
291
|
+
| 2. Checks and deliverables | `artifacts`, `githist`, `cicd`; HTML report; `karnak ui`; double-click app; `karnak web` | **Mostly done.** Left: the `surface` module |
|
|
292
|
+
| 3. Free release | Publish v0.2.0 with the apps (**done**); a GitHub Action; a PyPI package | **In progress** |
|
|
293
|
+
| 4. Paid product | Hosted scanning service | Later |
|
|
294
|
+
|
|
295
|
+
The gated `live/` probes (DNS, certificate transparency, TCP connect, TLS, HTTP headers)
|
|
296
|
+
are planned too. The bundled stdlib DNS resolver is the largest single piece left.
|
|
297
|
+
|
|
298
|
+
## Design invariants
|
|
299
|
+
|
|
300
|
+
These are the rules the code holds itself to. If you find a violation, that's a bug
|
|
301
|
+
worth reporting.
|
|
302
|
+
|
|
303
|
+
- **Zero required dependencies.** stdlib only, so it can be dropped onto a host where
|
|
304
|
+
you can't install anything. This is why DNS will be a bundled resolver rather than
|
|
305
|
+
dnspython.
|
|
306
|
+
- **Severity and confidence stay separate.** Collapsing them into one number is what
|
|
307
|
+
gets scanners muted.
|
|
308
|
+
- **No credential is ever printed in full** — not to the terminal, JSON, SARIF, or logs.
|
|
309
|
+
Everything is `AKIA...LE (20 chars)`.
|
|
310
|
+
- **No network validation of secrets by default.** Validating a key means transmitting
|
|
311
|
+
it to a third party. `--verify-secrets` is opt-in and says so.
|
|
312
|
+
- **Regex rules are labeled heuristic.** Python gets a real AST; other languages get
|
|
313
|
+
regex, and every finding declares which one found it. Honesty over apparent
|
|
314
|
+
capability.
|
|
315
|
+
- **Skips are always reported with a reason.** A scanner that silently does nothing is
|
|
316
|
+
worse than one that errors, because it reports success.
|
|
317
|
+
|
|
318
|
+
## Live probing, and why it's gated
|
|
319
|
+
|
|
320
|
+
`karnak live` requires `--authorized` and a non-empty `--scope`, refuses out-of-scope
|
|
321
|
+
hosts, and refuses reserved and cloud-metadata IP ranges *before any socket opens* —
|
|
322
|
+
including when a metadata IP is passed in `--scope` explicitly. Every host and port
|
|
323
|
+
touched can be appended to an `--audit-log`.
|
|
324
|
+
|
|
325
|
+
Only scan things you own or have written permission to test.
|
|
326
|
+
|
|
327
|
+
## Measuring noise
|
|
328
|
+
|
|
329
|
+
`dev/corpus.py` scans 17 pinned public repositories, ten ordinary projects (Django, Flask,
|
|
330
|
+
Express, Gin, ...) and seven deliberately vulnerable training apps (Juice Shop, WebGoat,
|
|
331
|
+
DVWA, ...), and diffs per-rule counts against `dev/corpus_baseline.json`. Findings on the
|
|
332
|
+
ordinary projects are nearly all noise, so a rise there fails the run; a fall on a
|
|
333
|
+
training app is flagged for explanation as possible lost recall.
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
python3 dev/corpus.py --top 15 # first run fetches each repo at its pinned commit
|
|
337
|
+
python3 dev/corpus.py --rule mark-safe # every hit for one rule, to judge it by eye
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## Feedback
|
|
341
|
+
|
|
342
|
+
Alpha software, and the noise floor is the thing I most need data on. Useful reports:
|
|
343
|
+
|
|
344
|
+
- **False positives.** The rule id, and the line it fired on. This is the most valuable
|
|
345
|
+
thing you can send.
|
|
346
|
+
- **False negatives.** Something real it walked straight past.
|
|
347
|
+
- **Crashes.** The command, and the traceback.
|
|
348
|
+
|
|
349
|
+
The scanner on this repo currently reports findings against its own rule-definition
|
|
350
|
+
JSON and its deliberately-vulnerable smoke fixtures in `dev/`. That's expected: those
|
|
351
|
+
files contain planted, non-live example credentials (`AKIAIOSFODNN7EXAMPLE` and
|
|
352
|
+
friends) so the detectors have something to catch.
|
|
353
|
+
|
|
354
|
+
## License
|
|
355
|
+
|
|
356
|
+
Apache 2.0. See [LICENSE](https://github.com/celestial-zenny/Karnak/blob/main/LICENSE) and [NOTICE](https://github.com/celestial-zenny/Karnak/blob/main/NOTICE).
|