pyattackforge 0.0.1__py3-none-any.whl

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.
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyattackforge
3
+ Version: 0.0.1
4
+ Summary: Python SDK for the AttackForge SSAPI
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: httpx>=0.27
9
+ Requires-Dist: h2>=4.1.0
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest>=8.0; extra == "dev"
12
+ Requires-Dist: python-dotenv>=1.0; extra == "dev"
13
+ Dynamic: license-file
14
+
15
+ # PyAttackForge
16
+
17
+ Next-generation Python SDK for the AttackForge SSAPI (Python 3.10+).
18
+
19
+ ## Install (local)
20
+
21
+ ```bash
22
+ pip install -e .
23
+ ```
24
+
25
+ ## Configuration
26
+
27
+ Environment variables:
28
+ - `ATTACKFORGE_BASE_URL`
29
+ - `ATTACKFORGE_API_KEY`
30
+ - `ATTACKFORGE_TEST_PROJECT_ID` (only needed for live integration tests)
31
+ - `ATTACKFORGE_FINDINGS_VISIBLE_DEFAULT` (optional, set to `true` to make new findings visible; default is pending/hidden)
32
+ - `ATTACKFORGE_FINDINGS_SUBSTATUS_KEY` (optional, default `substatus`)
33
+ - `ATTACKFORGE_FINDINGS_SUBSTATUS_VALUE` (optional, default `Observed`)
34
+ - `ATTACKFORGE_UI_BASE_URL` (optional, UI base URL for project testcase uploads/verification)
35
+ - `ATTACKFORGE_UI_TOKEN` (optional, UI authorization token for project testcase uploads/verification)
36
+
37
+ Example `.env`:
38
+
39
+ ```env
40
+ ATTACKFORGE_BASE_URL=https://demo.attackforge.com
41
+ ATTACKFORGE_API_KEY=replace-me
42
+ ATTACKFORGE_TEST_PROJECT_ID=replace-me
43
+ ATTACKFORGE_FINDINGS_VISIBLE_DEFAULT=false
44
+ ATTACKFORGE_FINDINGS_SUBSTATUS_KEY=substatus
45
+ ATTACKFORGE_FINDINGS_SUBSTATUS_VALUE=Observed
46
+ ATTACKFORGE_UI_BASE_URL=https://demo.attackforge.com
47
+ ATTACKFORGE_UI_TOKEN=replace-me
48
+ ```
49
+
50
+ ## Usage (sync)
51
+
52
+ ```python
53
+ from pyattackforge import AttackForgeClient
54
+
55
+ with AttackForgeClient() as client:
56
+ projects = client.projects.get_projects()
57
+ print(projects)
58
+ ```
59
+
60
+ Touch a testcase (updates `last_tested` and `testcase_type` in `project_testcase_custom_fields`):
61
+
62
+ ```python
63
+ from pyattackforge import AttackForgeClient
64
+
65
+ with AttackForgeClient() as client:
66
+ client.testcases.touch_testcase("project_id", "testcase_id")
67
+ ```
68
+
69
+ By default, the SDK merges `last_tested` and `testcase_type` into existing project testcase custom fields. Use `overwrite=True` to replace the list.
70
+ Default format for `last_tested` is `YYYY-MM-DD` (date picker friendly). Override by supplying `timestamp=`.
71
+ Default `testcase_type` is `Security Test Case`. Override by supplying `testcase_type=`.
72
+
73
+ Create a testcase note with optional deduplication (case-insensitive, trimmed):
74
+
75
+ ```python
76
+ from pyattackforge import AttackForgeClient
77
+
78
+ with AttackForgeClient() as client:
79
+ payload = {"note": "Observed weak password policy", "note_type": "PLAINTEXT"}
80
+ client.testcases.create_testcase_note("project_id", "testcase_id", payload, dedupe=True)
81
+ ```
82
+
83
+ When `dedupe=True`, the SDK compares against notes returned by the project testcase listing. If notes are not included in that response, the check is best-effort and the note will be created.
84
+ If a UI token is configured (`ATTACKFORGE_UI_TOKEN`), the SDK will also check the UI notes endpoint to avoid duplicates.
85
+
86
+ Upload vulnerability evidence with FIFO retention and dedupe:
87
+
88
+ ```python
89
+ from pyattackforge import AttackForgeClient
90
+
91
+ with AttackForgeClient() as client:
92
+ client.findings.upload_vulnerability_evidence("vuln_id", "evidence.png")
93
+ # keep_last defaults to 2 (FIFO, keep most recent). Set keep_last=None to disable.
94
+ client.findings.upload_vulnerability_evidence("vuln_id", "evidence.png", dedupe=True)
95
+ ```
96
+
97
+ For more reliable FIFO/dedupe, pass `project_id` so the SDK can use the project vulnerability listing (which contains evidence metadata):
98
+
99
+ ```python
100
+ client.findings.upload_vulnerability_evidence("vuln_id", "evidence.png", project_id="project_id")
101
+ ```
102
+
103
+ Upload project testcase evidence with FIFO retention and dedupe:
104
+
105
+ ```python
106
+ from pyattackforge import AttackForgeClient
107
+
108
+ with AttackForgeClient() as client:
109
+ client.testcases.upload_testcase_file("project_id", "testcase_id", "evidence.png")
110
+ # keep_last defaults to 2 (FIFO, keep most recent). Set keep_last=None to disable.
111
+ client.testcases.upload_testcase_file("project_id", "testcase_id", "evidence.png", dedupe=True)
112
+ ```
113
+
114
+ When a UI token is configured, FIFO cleanup for testcase evidence uses the UI delete endpoint:
115
+ `/api/projects/:projectId/meta/:fileId/delete` (UI expects GET/POST semantics).
116
+
117
+ Helper methods (examples):
118
+
119
+ ```python
120
+ with AttackForgeClient() as client:
121
+ project = client.projects.find_project_by_name("Tantalum Labs Fake Pentest")
122
+ suite = client.testsuites.find_testsuite_by_name("OWASP Web App Penetration Test")
123
+ if suite:
124
+ testcases = client.testsuites.get_testsuite_testcases(suite["id"])
125
+ client.link_vulnerability_to_testcases("project_id", "vuln_id", ["testcase_id"])
126
+ ```
127
+
128
+ ## Testing
129
+
130
+ Unit tests:
131
+
132
+ ```bash
133
+ python3 -m pytest
134
+ ```
135
+
136
+ Integration tests (require env vars):
137
+
138
+ ```bash
139
+ python3 -m pytest -m integration
140
+ ```
141
+
142
+ Integration tests create and modify data in the target tenant and will attempt cleanup. They read `ATTACKFORGE_BASE_URL`, `ATTACKFORGE_API_KEY`, and `ATTACKFORGE_TEST_PROJECT_ID`.
143
+
144
+ ## Status
145
+
146
+ This is a from-scratch rewrite. See `COVERAGE.md` for endpoint coverage and assumptions.
147
+
148
+ ## Scripts
149
+
150
+ Import writeups from a JSON export:
151
+
152
+ ```bash
153
+ python3 scripts/import_writeups.py --input writeups.json
154
+ ```
155
+
156
+ By default the script will ensure custom libraries exist. If the SSAPI returns an error for a custom library key, it will create a small bootstrap writeup in that library. Use `--no-ensure-library` to skip.
157
+
158
+ Add missing writeup custom fields (Settings -> Writeups) based on the import file:
159
+
160
+ ```bash
161
+ python3 scripts/import_writeups.py --input writeups.json --ensure-writeup-fields
162
+ ```
@@ -0,0 +1,20 @@
1
+ pyattackforge/__init__.py,sha256=ebRH36uyrbMl6C4H9JejeW0cA6S9xTTzScyD69I0Jso,97
2
+ pyattackforge/cache.py,sha256=zTGWzL4F6n4u6opCNCi0CYkkSWPx5ShZMVmDagMpPQ0,933
3
+ pyattackforge/client.py,sha256=E99KuD71q_geRiwMLdcJMUi_hdRJJUu8lPyC6Q-hVAk,5590
4
+ pyattackforge/config.py,sha256=U7kkUIDdC-ES8BC4jI-gM3dOyVNvvtRD644xPQKhOkQ,2240
5
+ pyattackforge/exceptions.py,sha256=YFzV7VQ3UkOGXKpHhXctuM7fZUtR4LgYuPR_po4pksA,592
6
+ pyattackforge/transport.py,sha256=5vUc4PASo_8PBdXPw54n7eAG0NiFTFDtmI5Zbn4SpmQ,4535
7
+ pyattackforge/resources/__init__.py,sha256=n0C-HZDqBHKfxM7utqKXkGtDES3i-7OzEHcRyUstXHY,589
8
+ pyattackforge/resources/assets.py,sha256=cVe4PrLp3Afxv52SBekQZaiDvQpV7zCKN6bLkUHl-uA,1420
9
+ pyattackforge/resources/base.py,sha256=x5C8SG2MfwCtOkcRi8plDTF6TkJqXz-b58KS4qkP0Zw,1286
10
+ pyattackforge/resources/findings.py,sha256=w1S8Ex-rFLcaVa7mE3MkexmgBW3Z09RilM-KFgG6hSI,27945
11
+ pyattackforge/resources/notes.py,sha256=r-TR3QuatrhGzwmoR7AQt7wiHXTrvmMvm7rYtkBCOkQ,5741
12
+ pyattackforge/resources/projects.py,sha256=6pDvOp7s81KvzNgONo04rqWzVXGggbdPXvOnEnBEz9A,7262
13
+ pyattackforge/resources/reports.py,sha256=43wDK8SB2qqz-tjerjFBOV4G9EcgLk5WL3O8H-On5b0,805
14
+ pyattackforge/resources/users.py,sha256=8SF_3QdNQalsyU-60V_oJtsJbo6nHkI3WPbCBebEkrk,2275
15
+ pyattackforge/resources/writeups.py,sha256=iBShGQFrwYie3Gx8F0ekSOW0rf_ZzziRDsRpdQYUsSg,3001
16
+ pyattackforge-0.0.1.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
17
+ pyattackforge-0.0.1.dist-info/METADATA,sha256=l_zP7DHeNoHoaHD-rNxikOzRWTn93d4f5r1raCk4m98,5586
18
+ pyattackforge-0.0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
19
+ pyattackforge-0.0.1.dist-info/top_level.txt,sha256=1rDeMkWvFWuX3MS8V65no7KuybYyvtfIgbYSt5m_uPU,14
20
+ pyattackforge-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+