badass-runner 0.3.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 (40) hide show
  1. badass_runner-0.3.0/LICENSE +187 -0
  2. badass_runner-0.3.0/PKG-INFO +12 -0
  3. badass_runner-0.3.0/README.md +219 -0
  4. badass_runner-0.3.0/badass_runner/__init__.py +1 -0
  5. badass_runner-0.3.0/badass_runner/classifier/__init__.py +15 -0
  6. badass_runner-0.3.0/badass_runner/classifier/classifier.py +344 -0
  7. badass_runner-0.3.0/badass_runner/cli.py +506 -0
  8. badass_runner-0.3.0/badass_runner/client.py +243 -0
  9. badass_runner-0.3.0/badass_runner/config.py +68 -0
  10. badass_runner-0.3.0/badass_runner/harness/__init__.py +10 -0
  11. badass_runner-0.3.0/badass_runner/harness/executor.py +441 -0
  12. badass_runner-0.3.0/badass_runner/harness/job_poller.py +248 -0
  13. badass_runner-0.3.0/badass_runner/harness/sanitize.py +116 -0
  14. badass_runner-0.3.0/badass_runner/heartbeat.py +82 -0
  15. badass_runner-0.3.0/badass_runner/logs.py +38 -0
  16. badass_runner-0.3.0/badass_runner/recorder/__init__.py +1 -0
  17. badass_runner-0.3.0/badass_runner/recorder/proxy.py +220 -0
  18. badass_runner-0.3.0/badass_runner/recorder/redact.py +151 -0
  19. badass_runner-0.3.0/badass_runner/recorder/session.py +89 -0
  20. badass_runner-0.3.0/badass_runner/recorder/storage.py +76 -0
  21. badass_runner-0.3.0/badass_runner/recorder_cli.py +427 -0
  22. badass_runner-0.3.0/badass_runner/status_server.py +59 -0
  23. badass_runner-0.3.0/badass_runner/target/__init__.py +16 -0
  24. badass_runner-0.3.0/badass_runner/target/builder.py +245 -0
  25. badass_runner-0.3.0/badass_runner/target/validator.py +344 -0
  26. badass_runner-0.3.0/badass_runner.egg-info/PKG-INFO +12 -0
  27. badass_runner-0.3.0/badass_runner.egg-info/SOURCES.txt +38 -0
  28. badass_runner-0.3.0/badass_runner.egg-info/dependency_links.txt +1 -0
  29. badass_runner-0.3.0/badass_runner.egg-info/entry_points.txt +2 -0
  30. badass_runner-0.3.0/badass_runner.egg-info/requires.txt +6 -0
  31. badass_runner-0.3.0/badass_runner.egg-info/top_level.txt +1 -0
  32. badass_runner-0.3.0/pyproject.toml +30 -0
  33. badass_runner-0.3.0/setup.cfg +4 -0
  34. badass_runner-0.3.0/tests/test_classifier.py +503 -0
  35. badass_runner-0.3.0/tests/test_harness.py +778 -0
  36. badass_runner-0.3.0/tests/test_login.py +425 -0
  37. badass_runner-0.3.0/tests/test_recorder.py +616 -0
  38. badass_runner-0.3.0/tests/test_runner.py +741 -0
  39. badass_runner-0.3.0/tests/test_smoke_secrets.py +446 -0
  40. badass_runner-0.3.0/tests/test_target_builder.py +792 -0
@@ -0,0 +1,187 @@
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 made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other transformations
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as defined by the copyright owner,
48
+ any work of authorship, including the original version of the Work and
49
+ any modifications or additions to that Work or Derivative Works of the
50
+ Work, that is intentionally submitted to the Licensor for inclusion
51
+ in the Work by the copyright owner or by an individual or Legal Entity
52
+ authorized to submit on behalf of the copyright owner. For the purposes
53
+ of this definition, "submitted" means any form of electronic, verbal,
54
+ or written communication sent to the Licensor or its representatives,
55
+ including but not limited to communication on electronic mailing lists,
56
+ source code control systems, and issue tracking systems that are managed
57
+ by, or on behalf of, the Licensor for the purpose of discussing and
58
+ improving the Work, but excluding communication that is conspicuously
59
+ marked or designated in writing by the copyright owner as "Not a
60
+ Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
63
+ whom a Contribution has been received by the Licensor and included
64
+ 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 the 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 cross-claim
83
+ or counterclaim in a lawsuit) alleging that the Work or any
84
+ Contribution embodied within the Work constitutes direct or contributory
85
+ patent infringement, then any patent licenses granted to You under
86
+ this License for that Work shall terminate as of the date such
87
+ 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 Derivative
95
+ 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, You must include a readable copy of the
108
+ attribution notices contained within such NOTICE file, in
109
+ at least one of the following places: within a NOTICE text
110
+ file distributed as part of the Derivative Works; within
111
+ the Source form or documentation, if provided along with the
112
+ Derivative Works; or, within a display generated by the
113
+ Derivative Works, if and wherever such third-party notices
114
+ normally appear. The contents of the NOTICE file are for
115
+ informational purposes only and do not modify the License.
116
+ You may add Your own attribution notices within Derivative
117
+ Works that You distribute, alongside or in addition to the
118
+ NOTICE text from the Work, provided that such additional
119
+ attribution notices cannot be construed as modifying the
120
+ License.
121
+
122
+ You may add Your own license statement for Your modifications and
123
+ may provide additional grant of rights to use, modify, or distribute
124
+ Your modifications, or for such Derivative Works as a whole, under
125
+ the terms of this License, if Your distribution includes the Work in
126
+ Source or Object form.
127
+
128
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
129
+ any Contribution intentionally submitted for inclusion in the Work
130
+ by You to the Licensor shall be under the terms and conditions of
131
+ this License, without any additional terms or conditions.
132
+ Notwithstanding the above, nothing herein shall supersede or modify
133
+ the terms of any separate license agreement you may have executed
134
+ with Licensor regarding such Contributions.
135
+
136
+ 6. Trademarks. This License does not grant permission to use the trade
137
+ names, trademarks, service marks, or product names of the Licensor,
138
+ except as required for reasonable and customary use in describing the
139
+ origin of the Work and reproducing the content of the NOTICE file.
140
+
141
+ 7. Disclaimer of Warranty. Unless required by applicable law or
142
+ agreed to in writing, Licensor provides the Work (and each
143
+ Contributor provides its Contributions) on an "AS IS" BASIS,
144
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
145
+ implied, including, without limitation, any warranties or conditions
146
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
147
+ PARTICULAR PURPOSE. You are solely responsible for determining the
148
+ appropriateness of using or reproducing the Work and assume any
149
+ risks associated with Your exercise of permissions under this License.
150
+
151
+ 8. Limitation of Liability. In no event and under no legal theory,
152
+ whether in tort (including negligence), contract, or otherwise,
153
+ unless required by applicable law (such as deliberate and grossly
154
+ negligent acts) or agreed to in writing, shall any Contributor be
155
+ liable to You for damages, including any direct, indirect, special,
156
+ incidental, or exemplary damages of any character arising as a
157
+ result of this License or out of the use or inability to use the
158
+ Work (including but not limited to damages for loss of goodwill,
159
+ work stoppage, computer failure or malfunction, or all other
160
+ commercial damages or losses), even if such Contributor has been
161
+ advised of the possibility of such damages.
162
+
163
+ 9. Accepting Warranty or Additional Liability. While redistributing
164
+ the Work or Derivative Works thereof, You may choose to offer,
165
+ and charge a fee for, acceptance of support, warranty, indemnity,
166
+ or other liability obligations and/or rights consistent with this
167
+ License. However, in accepting such obligations, You may offer only
168
+ conditions that are consistent with this License and for which you
169
+ can fully compensate each other Contributor for any damages,
170
+ incurred by such Contributor as a result of warranty, indemnity,
171
+ or other liability obligations you accept.
172
+
173
+ END OF TERMS AND CONDITIONS
174
+
175
+ Copyright 2026 BADASS Security
176
+
177
+ Licensed under the Apache License, Version 2.0 (the "License");
178
+ you may not use this file except in compliance with the License.
179
+ You may obtain a copy of the License at
180
+
181
+ http://www.apache.org/licenses/LICENSE-2.0
182
+
183
+ Unless required by applicable law or agreed to in writing, software
184
+ distributed under the License is distributed on an "AS IS" BASIS,
185
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
186
+ See the License for the specific language governing permissions and
187
+ limitations under the License.
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: badass-runner
3
+ Version: 0.3.0
4
+ Summary: BADASS Local Runner — connects local AI endpoints to BADASS Cloud
5
+ Requires-Python: >=3.11
6
+ License-File: LICENSE
7
+ Requires-Dist: click>=8.0
8
+ Requires-Dist: httpx>=0.28.0
9
+ Requires-Dist: pytest>=8.0
10
+ Provides-Extra: test
11
+ Requires-Dist: pytest>=8.0; extra == "test"
12
+ Dynamic: license-file
@@ -0,0 +1,219 @@
1
+ # BADASS Connector
2
+
3
+ > **Connect your local or private AI endpoints to BADASS Cloud for adversarial security testing.**
4
+
5
+ ---
6
+
7
+ ## What it is
8
+
9
+ The BADASS Connector (`badass-runner`) is a lightweight Python agent you run on your own machine or server. It creates a secure, outbound-only channel between a local AI endpoint and the BADASS Cloud testing platform.
10
+
11
+ Once connected, BADASS Cloud can dispatch adversarial harness tests against your endpoint, collect sanitized results, and surface findings — all without your endpoint ever being exposed to the public internet.
12
+
13
+ ## Why it exists
14
+
15
+ Many AI systems under test run behind:
16
+
17
+ - corporate VPNs
18
+ - private cloud networks
19
+ - localhost development environments
20
+ - firewalls that block inbound connections
21
+
22
+ BADASS Cloud cannot reach these endpoints directly. The connector solves this by running **inside** your network and pulling jobs from the cloud rather than receiving inbound traffic.
23
+
24
+ Your endpoint never needs a public IP address. Your credentials never leave your machine.
25
+
26
+ ---
27
+
28
+ ## Requirements
29
+
30
+ - Python **3.11** or later
31
+ - Network access to `https://badass-sec.com` (outbound HTTPS only)
32
+ - The AI endpoint you want to test (reachable from the machine running the connector)
33
+
34
+ ---
35
+
36
+ ## Installation
37
+
38
+ ### From PyPI (recommended)
39
+
40
+ ```bash
41
+ pip install badass-runner
42
+ ```
43
+
44
+ ### From source
45
+
46
+ ```bash
47
+ git clone https://github.com/DKB8man/badass-connector
48
+ cd badass-connector
49
+ pip install .
50
+ ```
51
+
52
+ ### Verify
53
+
54
+ ```bash
55
+ badass-runner --version
56
+ ```
57
+
58
+ See [docs/install.md](docs/install.md) for detailed install options, virtual environment setup, and environment variable reference.
59
+
60
+ ---
61
+
62
+ ## Quick start
63
+
64
+ ### 1. Pair this machine with BADASS Cloud
65
+
66
+ ```bash
67
+ badass-runner login --server-url https://badass-sec.com
68
+ ```
69
+
70
+ This opens a browser window showing a short pairing code. Approve it in the BADASS Cloud dashboard. No token or password is required on the command line — the credential is negotiated during the pairing handshake and saved locally.
71
+
72
+ You only need to run `login` once per machine.
73
+
74
+ ### 2. Start the connector
75
+
76
+ ```bash
77
+ badass-runner start
78
+ ```
79
+
80
+ The connector runs in the foreground, sends a heartbeat to the cloud every 30 seconds, and polls for harness jobs assigned to it. When a job arrives it executes the test sequence locally against your endpoint, strips credentials from the results, and uploads the sanitized transcript.
81
+
82
+ Press **Ctrl-C** or run `badass-runner stop` (from another terminal) to shut it down.
83
+
84
+ ### 3. Check status
85
+
86
+ ```bash
87
+ badass-runner status
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Testing private and local AI apps
93
+
94
+ The connector targets any HTTP endpoint that accepts a text message and returns a text reply — the same interface used by most chat-completion, agent, and RAG APIs.
95
+
96
+ **Typical configuration in the BADASS Cloud dashboard:**
97
+
98
+ | Field | Example |
99
+ |---|---|
100
+ | Base URL | `http://localhost:8000` |
101
+ | Message path | `/api/chat` |
102
+ | Method | `POST` |
103
+ | Request field | `message` |
104
+ | Response field | `reply` |
105
+ | Auth type | `bearer` / `api_key` / `none` |
106
+
107
+ Credentials (API keys, Bearer tokens) are stored in the connector's **local auth store** on your machine and looked up at runtime. They are never sent to the cloud. See [Where credentials live](#where-credentials-live) below.
108
+
109
+ ---
110
+
111
+ ## Alternative: token-based registration
112
+
113
+ If your workflow does not support a browser (CI pipelines, headless servers), you can generate a one-time registration token in the BADASS Cloud dashboard and pass it directly:
114
+
115
+ ```bash
116
+ badass-runner start \
117
+ --server-url https://badass-sec.com \
118
+ --token badass_reg_YOURTOKEN \
119
+ --name my-ci-runner
120
+ ```
121
+
122
+ The token is consumed on first use and replaced with a long-lived runner credential stored in the local config file.
123
+
124
+ ---
125
+
126
+ ## Where credentials live
127
+
128
+ All connector state is stored in `~/.badass-runner/` (overridable with `$BADASS_RUNNER_HOME`):
129
+
130
+ ```
131
+ ~/.badass-runner/
132
+ config.json # runner_id, runner_token, server_url, runner_name
133
+ runner.pid # PID of the running connector process
134
+ ```
135
+
136
+ `config.json` is written with permissions **0600** (owner read/write only). It contains:
137
+
138
+ - `server_url` — the BADASS Cloud base URL
139
+ - `runner_name` — a human-readable label you chose
140
+ - `runner_id` — your runner's UUID assigned by the cloud
141
+ - `runner_token` — the long-lived bearer token used to authenticate job polls and result uploads
142
+
143
+ **Your API keys and endpoint credentials are never written to `config.json`.** They are managed separately through the BADASS Cloud dashboard and resolved by the connector at job execution time from your local auth store.
144
+
145
+ ---
146
+
147
+ ## What data is uploaded
148
+
149
+ When the connector completes a harness test, it uploads to BADASS Cloud:
150
+
151
+ | Data | Description |
152
+ |---|---|
153
+ | Run status | `DONE`, `FAILED`, or `CANCELLED` |
154
+ | Per-test turn sequences | The messages sent to and received from your endpoint, with auth headers stripped |
155
+ | Endpoint metadata | Base URL, method, path, auth type (not auth values) |
156
+ | Validation evidence | Pattern-match results used to determine PASS/FAIL |
157
+ | Error messages | Failure reasons, passed through credential redaction before upload |
158
+
159
+ ## What is never uploaded
160
+
161
+ The connector is designed so the following data **never leaves your machine**:
162
+
163
+ | Data | Handling |
164
+ |---|---|
165
+ | API keys | Stored locally; injected into requests at runtime; never included in uploaded results |
166
+ | Bearer tokens | Stripped from all request/response transcripts before upload |
167
+ | Cookies | Stripped from all transcripts; cookie values are replaced with `[REDACTED]` |
168
+ | Raw `Authorization` headers | Removed from all uploaded turn data |
169
+ | `X-Api-Key`, `X-Auth-Token` headers | Removed from all uploaded turn data |
170
+ | Proxy or VPN credentials | Never read or transmitted by the connector |
171
+ | Quoted-assignment secrets in log lines | Caught and redacted by the text-level redactor before error strings are uploaded |
172
+
173
+ See [docs/security-model.md](docs/security-model.md) for the full technical description of the redaction layer.
174
+
175
+ ---
176
+
177
+ ## Commands
178
+
179
+ | Command | Description |
180
+ |---|---|
181
+ | `badass-runner login` | Pair this machine with BADASS Cloud via browser |
182
+ | `badass-runner start` | Start the connector (foreground) |
183
+ | `badass-runner status` | Show whether a connector process is running locally |
184
+ | `badass-runner stop` | Send SIGTERM to the running connector |
185
+ | `badass-runner recorder` | HTTP traffic recorder for endpoint discovery |
186
+ | `badass-runner --version` | Print connector version |
187
+ | `badass-runner --help` | Show all commands and options |
188
+
189
+ ---
190
+
191
+ ## Environment variables
192
+
193
+ | Variable | Default | Description |
194
+ |---|---|---|
195
+ | `BADASS_SERVER_URL` | — | Cloud base URL (replaces `--server-url`) |
196
+ | `BADASS_REG_TOKEN` | — | One-time registration token (replaces `--token`) |
197
+ | `BADASS_RUNNER_NAME` | — | Runner label (replaces `--name`) |
198
+ | `BADASS_RUNNER_HOME` | `~/.badass-runner` | Override config directory |
199
+ | `BADASS_STATUS_PORT` | `7890` | Local status server port |
200
+
201
+ ---
202
+
203
+ ## Local status server
204
+
205
+ While running, the connector exposes a read-only HTTP status endpoint on localhost at port 7890 (configurable via `--port` or `BADASS_STATUS_PORT`). This is **not** accessible from outside the machine. It is intended for local monitoring integrations.
206
+
207
+ ---
208
+
209
+ ## Security
210
+
211
+ See [SECURITY.md](SECURITY.md) for how to report vulnerabilities and our data handling commitments.
212
+
213
+ See [docs/security-model.md](docs/security-model.md) for a full description of what data the connector handles, what it redacts, and what it uploads.
214
+
215
+ ---
216
+
217
+ ## License
218
+
219
+ See `LICENSE` file.
@@ -0,0 +1 @@
1
+ __version__ = "0.2.0"
@@ -0,0 +1,15 @@
1
+ from .classifier import (
2
+ AI_CONFIDENCE_THRESHOLD,
3
+ ClassificationResult,
4
+ SessionClassification,
5
+ classify_capture,
6
+ classify_session,
7
+ )
8
+
9
+ __all__ = [
10
+ "AI_CONFIDENCE_THRESHOLD",
11
+ "ClassificationResult",
12
+ "SessionClassification",
13
+ "classify_capture",
14
+ "classify_session",
15
+ ]