dawnfix 0.3.0__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.
- dawnfix-0.3.0.dist-info/METADATA +198 -0
- dawnfix-0.3.0.dist-info/RECORD +84 -0
- dawnfix-0.3.0.dist-info/WHEEL +5 -0
- dawnfix-0.3.0.dist-info/entry_points.txt +8 -0
- dawnfix-0.3.0.dist-info/licenses/LICENSE +105 -0
- dawnfix-0.3.0.dist-info/top_level.txt +7 -0
- dawnfix_core/__init__.py +8 -0
- dawnfix_core/__main__.py +5 -0
- dawnfix_core/awsguard.py +91 -0
- dawnfix_core/cli.py +110 -0
- dawnfix_core/config.py +262 -0
- dawnfix_core/findings.py +118 -0
- dawnfix_core/normalize.py +222 -0
- dawnfix_core/redact.py +61 -0
- dawnfix_core/rules.py +147 -0
- dawnfix_core/sources/__init__.py +23 -0
- dawnfix_core/sources/aws.py +205 -0
- dawnfix_core/sources/gcp.py +81 -0
- dawnfix_core/state.py +69 -0
- dawnfix_core/tick.py +129 -0
- dawnfix_fleet/__init__.py +4 -0
- dawnfix_fleet/__main__.py +3 -0
- dawnfix_fleet/checks.py +287 -0
- dawnfix_fleet/cli.py +86 -0
- dawnfix_fleet/collect.py +74 -0
- dawnfix_fleet/config.py +157 -0
- dawnfix_fleet/guard.py +40 -0
- dawnfix_fleet/summary.py +166 -0
- dawnfix_leastpriv/__init__.py +1 -0
- dawnfix_leastpriv/__main__.py +3 -0
- dawnfix_leastpriv/cli.py +111 -0
- dawnfix_leastpriv/collect.py +168 -0
- dawnfix_leastpriv/constants.py +17 -0
- dawnfix_leastpriv/guard.py +40 -0
- dawnfix_leastpriv/render.py +169 -0
- dawnfix_leastpriv/trim.py +208 -0
- dawnfix_parity/__init__.py +2 -0
- dawnfix_parity/__main__.py +3 -0
- dawnfix_parity/aws.py +105 -0
- dawnfix_parity/brand.py +22 -0
- dawnfix_parity/cli.py +210 -0
- dawnfix_parity/cloudtrail.py +133 -0
- dawnfix_parity/collect.py +234 -0
- dawnfix_parity/config.py +214 -0
- dawnfix_parity/diff.py +186 -0
- dawnfix_parity/ingest.py +60 -0
- dawnfix_parity/inventory.py +113 -0
- dawnfix_parity/model.py +97 -0
- dawnfix_parity/refs.py +208 -0
- dawnfix_parity/report.py +142 -0
- dawnfix_parity/resolve.py +152 -0
- dawnfix_receipt/__init__.py +1 -0
- dawnfix_receipt/__main__.py +3 -0
- dawnfix_receipt/cli.py +124 -0
- dawnfix_receipt/constants.py +13 -0
- dawnfix_receipt/costs.py +91 -0
- dawnfix_receipt/github.py +67 -0
- dawnfix_receipt/guard.py +29 -0
- dawnfix_receipt/ingest.py +127 -0
- dawnfix_receipt/receipt.py +237 -0
- dawnfix_sweeper/__init__.py +1 -0
- dawnfix_sweeper/__main__.py +3 -0
- dawnfix_sweeper/cli.py +75 -0
- dawnfix_sweeper/constants.py +27 -0
- dawnfix_sweeper/guard.py +52 -0
- dawnfix_sweeper/plan.py +133 -0
- dawnfix_sweeper/prices.json +159 -0
- dawnfix_sweeper/pricing.py +134 -0
- dawnfix_sweeper/scan.py +847 -0
- logbill/__init__.py +2 -0
- logbill/__main__.py +5 -0
- logbill/awsread.py +131 -0
- logbill/brand.py +24 -0
- logbill/cli.py +212 -0
- logbill/doc_style.css +127 -0
- logbill/fix.py +67 -0
- logbill/insights.py +165 -0
- logbill/locate.py +127 -0
- logbill/model.py +108 -0
- logbill/prices.json +751 -0
- logbill/prices.py +80 -0
- logbill/report.py +198 -0
- logbill/scan.py +150 -0
- logbill/suggest.py +163 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dawnfix
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Dawnfix, the AI SRE that runs in your own GitHub Actions: the read-only prod log tick (dawnfix) and the free tools logbill, parity, sweeper, leastpriv, receipt and fleet. Logs stay in your accounts.
|
|
5
|
+
Author: Dawnfix
|
|
6
|
+
License-Expression: FSL-1.1-ALv2
|
|
7
|
+
Project-URL: Homepage, https://dawnfix.dev
|
|
8
|
+
Project-URL: Source, https://github.com/dawnfix/dawnfix
|
|
9
|
+
Keywords: ai-sre,sre,aws,gcp,cloudwatch,github-actions,finops,iam
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: System :: Monitoring
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: PyYAML>=6.0
|
|
17
|
+
Requires-Dist: boto3>=1.34
|
|
18
|
+
Provides-Extra: gcp
|
|
19
|
+
Requires-Dist: google-cloud-logging>=3.5; extra == "gcp"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# Dawnfix
|
|
23
|
+
|
|
24
|
+
An AI SRE (AI Site Reliability Engineer) for AWS and GCP that runs in your own GitHub
|
|
25
|
+
Actions. A deterministic, read-only job reads CloudWatch Logs, alarms, load balancer 5xx or
|
|
26
|
+
Cloud Logging every hour, fingerprints and redacts the errors, and remembers which ones it
|
|
27
|
+
has seen. When one is new, an agent with your own Anthropic key either files a GitHub issue
|
|
28
|
+
with the cause, the impact and a severity, or writes a failing test and the fix and opens a
|
|
29
|
+
draft PR for you to review. It never merges or deploys. Your logs never leave your accounts.
|
|
30
|
+
|
|
31
|
+
Free and source available. No key and no plan is needed for anything in this repo.
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
In the repo whose production Dawnfix should watch (Node 20+, and `gh` signed in):
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npx dawnfix init
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
It asks where your logs are (AWS or GCP) and how far the agent may go (`autonomy`, start
|
|
42
|
+
with `diagnose`), shows the two files it will write, and writes them when you say yes:
|
|
43
|
+
|
|
44
|
+
- `.dawnfix.yml`: the log sources, `autonomy`, `test.command` (every key:
|
|
45
|
+
[templates/dawnfix.yml](templates/dawnfix.yml));
|
|
46
|
+
- `.github/workflows/dawnfix.yml`: about 15 lines that call the reusable workflow, with your
|
|
47
|
+
schedule and permissions:
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
name: dawnfix
|
|
51
|
+
on:
|
|
52
|
+
schedule: [{ cron: "17 * * * *" }] # the `schedule` of .dawnfix.yml
|
|
53
|
+
workflow_dispatch: { inputs: { baseline: { type: boolean }, dry_run: { type: boolean } } }
|
|
54
|
+
permissions: { contents: write, pull-requests: write, issues: write, id-token: write }
|
|
55
|
+
jobs:
|
|
56
|
+
dawnfix:
|
|
57
|
+
uses: dawnfix/dawnfix/.github/workflows/dawnfix.yml@v0
|
|
58
|
+
with:
|
|
59
|
+
aws-role-arn: ${{ vars.DAWNFIX_AWS_ROLE_ARN }}
|
|
60
|
+
secrets:
|
|
61
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
62
|
+
DAWNFIX_ENTERPRISE_KEY: ${{ secrets.DAWNFIX_ENTERPRISE_KEY }} # optional
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
It never asks for a secret and never writes one. It prints what you run next:
|
|
66
|
+
|
|
67
|
+
1. **Read-only cloud role.** AWS: `infra/aws/dawnfix-read-role.yaml` with CloudFormation
|
|
68
|
+
(it trusts GitHub OIDC for your repo's default branch only; check it with
|
|
69
|
+
`infra/aws/verify_readonly.py`). GCP: `infra/gcp/setup-wif.sh` (Workload Identity
|
|
70
|
+
Federation, `roles/logging.viewer` only).
|
|
71
|
+
2. **Secrets**, typed by you: `gh secret set ANTHROPIC_API_KEY`.
|
|
72
|
+
3. **Review and run.** Open a PR with the two files and merge it. Then
|
|
73
|
+
`gh workflow run dawnfix.yml -f dry_run=true` shows exactly what would leave your account,
|
|
74
|
+
and `gh workflow run dawnfix.yml -f baseline=true` records the errors you already have, so
|
|
75
|
+
only new ones are reported.
|
|
76
|
+
4. `npx dawnfix doctor` checks the config, the pinned workflow, the secret and variable
|
|
77
|
+
names, and says whether you run Free or Enterprise.
|
|
78
|
+
|
|
79
|
+
Later, switch `autonomy` to `plan` or `draft-pr` through a PR (and give `install-command`).
|
|
80
|
+
For draft PRs that trigger your CI, set a GitHub App (`pr-app-id`,
|
|
81
|
+
`DAWNFIX_PR_APP_PRIVATE_KEY`) or a fine-grained token (`DAWNFIX_PR_TOKEN`) as the PR author.
|
|
82
|
+
|
|
83
|
+
### The workflows
|
|
84
|
+
|
|
85
|
+
| Reusable workflow (`uses: dawnfix/dawnfix/.github/workflows/<file>@v0`) | Copy-it-yourself template |
|
|
86
|
+
|---|---|
|
|
87
|
+
| [dawnfix.yml](.github/workflows/dawnfix.yml): the read job and the diagnose or fix agent | [templates/github/workflows/dawnfix.yml](templates/github/workflows/dawnfix.yml) |
|
|
88
|
+
| [parity.yml](.github/workflows/parity.yml): config drift between two AWS environments | [dawnfix-parity.yml](templates/github/workflows/dawnfix-parity.yml) |
|
|
89
|
+
| [flare.yml](.github/workflows/flare.yml): the daily Cloudflare audit | [dawnfix-flare.yml](templates/github/workflows/dawnfix-flare.yml) |
|
|
90
|
+
| [receipt.yml](.github/workflows/receipt.yml): a cost comment on every production deploy | [dawnfix-receipt.yml](templates/github/workflows/dawnfix-receipt.yml) |
|
|
91
|
+
|
|
92
|
+
Each reusable workflow's header shows its caller and lists its inputs and secrets. The
|
|
93
|
+
permissions in your caller are a ceiling: every job asks for less (only the read job gets
|
|
94
|
+
`id-token`, only the publish job can push, on a fresh runner after the agent's job has
|
|
95
|
+
ended, and it only opens draft PRs). `@v0` follows the
|
|
96
|
+
latest 0.x release; pin `@v0.3.0` or a commit SHA to freeze it. Each release installs the
|
|
97
|
+
same version of the PyPI package `dawnfix` and loads the agent's instructions from
|
|
98
|
+
`prompts/ci/` at its own tag. Fallback, without PyPI: the `core-ref` input (a tag or commit
|
|
99
|
+
SHA of this repo) installs from git at that ref and loads the instructions from it.
|
|
100
|
+
|
|
101
|
+
The templates are the same jobs and steps, reading repository variables
|
|
102
|
+
(`DAWNFIX_AWS_ROLE_ARN`, `DAWNFIX_INSTALL_COMMAND`, ...) instead of inputs, for those who
|
|
103
|
+
would rather keep the whole file in their repo. Copy one, copy the `schedule` of
|
|
104
|
+
`.dawnfix.yml` into its cron, and set the variables its header lists.
|
|
105
|
+
|
|
106
|
+
### The CLIs
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
pipx install dawnfix # PyPI: dawnfix (the tick), logbill, parity, sweeper, leastpriv, receipt, fleet
|
|
110
|
+
dawnfix validate --config .dawnfix.yml
|
|
111
|
+
npx dawnfix flare --help # npm: the Cloudflare audit (also node flare/dist/cli.js)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## What it costs you
|
|
115
|
+
|
|
116
|
+
Dawnfix itself is free, with no key. It runs on accounts you already pay for, and those
|
|
117
|
+
bills go to you, not to us:
|
|
118
|
+
|
|
119
|
+
- **Anthropic tokens**, on your own `ANTHROPIC_API_KEY`. Only the diagnose or fix job uses
|
|
120
|
+
them, and only on a run that found a new error. A quiet hour spends no tokens.
|
|
121
|
+
`limits.fix_prs_per_day` and the agent's `max_turns` cap a busy day.
|
|
122
|
+
- **GitHub Actions minutes.** The read job runs every hour, about a minute each, so roughly
|
|
123
|
+
750 minutes a month on the default schedule, plus the agent jobs when they run. Free on
|
|
124
|
+
public repos; on private repos they count against your plan's included minutes.
|
|
125
|
+
- **AWS API calls** in your account: the tick reads with `FilterLogEvents` and
|
|
126
|
+
`DescribeAlarms`, and load balancer 5xx with `GetMetricData` ($0.01 per 1,000 metrics).
|
|
127
|
+
Logbill's Logs Insights queries are billed per GB scanned; it prints the estimate and
|
|
128
|
+
stops at its budget.
|
|
129
|
+
- **AWS Cost Explorer, for Receipt only**: $0.01 per request, one per deploy (two with
|
|
130
|
+
`--tag-key`).
|
|
131
|
+
|
|
132
|
+
| `autonomy` | What happens when a new error shows up |
|
|
133
|
+
|---|---|
|
|
134
|
+
| `diagnose` | An issue: cause with `file:line`, impact, severity. The agent has no shell and the job cannot push |
|
|
135
|
+
| `plan` | An issue with the planned test and fix |
|
|
136
|
+
| `draft-pr` | A failing test, then the fix, as two commits on `dawnfix/<fingerprint>`, opened as a draft PR. An issue when no cause or failing test can be shown |
|
|
137
|
+
|
|
138
|
+
## Use it from your coding agent
|
|
139
|
+
|
|
140
|
+
[prompts/](prompts/README.md) holds copy-paste prompts for any coding agent (Claude Code,
|
|
141
|
+
Codex, Cursor and others): set up Dawnfix in a repo, diagnose or fix a findings file, check
|
|
142
|
+
status, and run each tool below. Paste one, or ask your agent to save it as a skill or a
|
|
143
|
+
command. [prompts/ci/](prompts/ci/) holds the instructions the workflow gives its agent.
|
|
144
|
+
|
|
145
|
+
## What is here
|
|
146
|
+
|
|
147
|
+
| Folder | |
|
|
148
|
+
|---|---|
|
|
149
|
+
| [core/](core/README.md) | `dawnfix-core`: the deterministic tick (query, fingerprint, dedupe, redact), the findings and ingest schemas |
|
|
150
|
+
| [.github/workflows/](.github/workflows/) | the reusable workflows `dawnfix.yml`, `parity.yml`, `flare.yml`, `receipt.yml`, and `release.yml` |
|
|
151
|
+
| [templates/](templates/) | `.dawnfix.yml` and the copy-it-yourself workflows: `dawnfix.yml`, and the optional `dawnfix-parity.yml`, `dawnfix-flare.yml`, `dawnfix-receipt.yml` |
|
|
152
|
+
| [infra/](infra/aws/README.md) | the read-only AWS role (CloudFormation), its verifier, the GCP Workload Identity script |
|
|
153
|
+
| [prompts/](prompts/README.md) | copy-paste prompts for coding agents, and the CI agent's instructions |
|
|
154
|
+
| [logbill/](logbill/README.md) | Dawnfix Logbill: read-only CloudWatch Logs bill X-ray that runs on your machine |
|
|
155
|
+
| [parity/](parity/README.md) | Dawnfix Parity: read-only config drift between AWS environments and a secret inventory; names and metadata only |
|
|
156
|
+
| [flare/](flare/README.md) | Dawnfix Flare: read-only audit of Cloudflare accounts and Workers and your wrangler files; one bundled file, `node flare/dist/cli.js` |
|
|
157
|
+
| [sweeper/](sweeper/README.md) | Dawnfix Sweeper: what an AWS migration left behind, priced per month, with a teardown plan; never deletes |
|
|
158
|
+
| [leastpriv/](leastpriv/README.md) | Dawnfix Leastpriv: least-privilege trim of one IAM role from last-accessed data, as a PR body and diffs; never changes IAM |
|
|
159
|
+
| [receipt/](receipt/README.md) | Dawnfix Receipt: a comment on every production deploy with what it did to the AWS bill |
|
|
160
|
+
| [fleet/](fleet/README.md) | Dawnfix Fleet: a read-only collector for agencies that look after many client accounts |
|
|
161
|
+
| [hosted/](hosted/README.md) | a helper for Dawnfix Enterprise, the hosted part (below) |
|
|
162
|
+
|
|
163
|
+
Also [cli/](cli/README.md), the npm package `dawnfix` (`init`, `doctor`, `flare`), and
|
|
164
|
+
`pyproject.toml`, the PyPI package `dawnfix` (core and the Python tools in one). How a
|
|
165
|
+
release is published: [RELEASING.md](RELEASING.md).
|
|
166
|
+
|
|
167
|
+
Tests: `cd core && make install && make test`; `core/.venv/bin/pytest -q infra/tests`;
|
|
168
|
+
`cd <logbill|parity|sweeper|leastpriv|receipt> && make install test`;
|
|
169
|
+
`cd fleet/collector && make install && make test`;
|
|
170
|
+
`cd flare && npm ci && npm test && npm run build:check`;
|
|
171
|
+
`cd cli && npm ci && npm test && npm run build:check`.
|
|
172
|
+
|
|
173
|
+
## Enterprise (hosted, optional)
|
|
174
|
+
|
|
175
|
+
Everything above runs in your own accounts with no key. Dawnfix Enterprise is our hosted
|
|
176
|
+
part: a status page, digest and alert emails, the Fleet board, and support.
|
|
177
|
+
Dawnfix Enterprise is sold by contact: [dawnfix@sivakoza.ai](mailto:dawnfix@sivakoza.ai). It is a monthly
|
|
178
|
+
subscription, priced per organization (https://dawnfix.dev/pricing). With an Enterprise key
|
|
179
|
+
in the `DAWNFIX_ENTERPRISE_KEY` secret (passed to the reusable workflow; the templates also
|
|
180
|
+
read the older name `DAWNFIX_LICENSE`), the workflows also send counts (never log text, names or
|
|
181
|
+
values) to the hosted service. Field by field: `core/schema/ingest.schema.json` and
|
|
182
|
+
https://dawnfix.dev/security. Without the key, each of those steps prints one line, such as
|
|
183
|
+
"Hosted reporting (status page and digest) needs an Enterprise key.", sends nothing, and the
|
|
184
|
+
run goes on.
|
|
185
|
+
|
|
186
|
+
## Licence
|
|
187
|
+
|
|
188
|
+
Dawnfix is under the [Functional Source License, Version 1.1, ALv2 Future License](LICENSE)
|
|
189
|
+
(FSL-1.1-ALv2). In plain words, and the licence text is what counts:
|
|
190
|
+
|
|
191
|
+
- You may use, copy, modify and run it, including in your company and for your clients'
|
|
192
|
+
systems.
|
|
193
|
+
- You may not sell it or offer it, or a substitute for it, as a competing product or service.
|
|
194
|
+
- Every release becomes Apache-2.0 two years after it is published.
|
|
195
|
+
- Contributions are welcome.
|
|
196
|
+
|
|
197
|
+
Versions released before 27 Nov 2026 were MIT-licensed; from v0.2.0 on the code is under
|
|
198
|
+
FSL-1.1-ALv2.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
dawnfix-0.3.0.dist-info/licenses/LICENSE,sha256=0h_J933bnIMrtBRNlzFR5LLkSEGO5wh3Rp9WiVzt1SA,3748
|
|
2
|
+
dawnfix_core/__init__.py,sha256=JC1H6ocz6zide_vraw2ypr04kpnHTJifIaGV7BvbkLA,325
|
|
3
|
+
dawnfix_core/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
|
|
4
|
+
dawnfix_core/awsguard.py,sha256=P-bs1Ljb9mog0He3ZaKMBNbAjTfg96mPnOzGjcj_A5g,3863
|
|
5
|
+
dawnfix_core/cli.py,sha256=xQ11Y66bsFRgYwnaRFe0KHX1h7RgG239V5tDj7wrV3E,4232
|
|
6
|
+
dawnfix_core/config.py,sha256=-yr4HWaKMU82gkdjBLhvVDam9Qq5hB2KVFy1lCrmcrU,10024
|
|
7
|
+
dawnfix_core/findings.py,sha256=WjTf5XmRHEOsNWAPoBXhLymd8YaBEsvIiEyhjX6gABk,4417
|
|
8
|
+
dawnfix_core/normalize.py,sha256=A1RrHazGQtgCAs_lGFW102qVRIHiTFJElxfVRr-oCSc,7387
|
|
9
|
+
dawnfix_core/redact.py,sha256=VMmhBJF-CmOn1Q8uYiP0XXKOH-7nDosoJ6CDqu9iwZA,2257
|
|
10
|
+
dawnfix_core/rules.py,sha256=vSULeHQSIUvDQEDdxzA9wge-JDrD1ht7Su5YL8xQ9kE,5495
|
|
11
|
+
dawnfix_core/state.py,sha256=4vqSaLwlUNOP1OiTW5jXsBDZyM8jKOVE0vG8SIhSsAM,2271
|
|
12
|
+
dawnfix_core/tick.py,sha256=wz2vFoZupxFqRe70o4npHivTtFlP0V-CKG-d9xOMHkE,4731
|
|
13
|
+
dawnfix_core/sources/__init__.py,sha256=1EVTQi2XalXItZnSXUxblu1Oab0tuMYXFE2VnSSUZvA,655
|
|
14
|
+
dawnfix_core/sources/aws.py,sha256=fZ9D9gybTvrGJyAWvR3AdIXArqSzckBmag6qW79b2wI,8496
|
|
15
|
+
dawnfix_core/sources/gcp.py,sha256=re0g8CbteW14mPWg6OFLSx1CpDmte7LxKQqNJf-MS6I,3432
|
|
16
|
+
dawnfix_fleet/__init__.py,sha256=cLZURDpEF9grOpuCncyWrVixomcAOFcoE3eoBInLUNM,138
|
|
17
|
+
dawnfix_fleet/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
|
|
18
|
+
dawnfix_fleet/checks.py,sha256=QJDpMkTBJXaUMmFo_mRfbY-KG0xQIi_Y6yZLx97xkLM,10804
|
|
19
|
+
dawnfix_fleet/cli.py,sha256=tmcrclPhhM6bSqplfwrqQTOmbe4nnTEPfJ4N8LoJaeA,3297
|
|
20
|
+
dawnfix_fleet/collect.py,sha256=8nCsekwz9gawbROfgq6F5D7C_4bGIoFIq8-fzCc_OxY,2935
|
|
21
|
+
dawnfix_fleet/config.py,sha256=3xHCpyynprZL2fH-8Nci0g3rwQ7wgMqvzuh65yds7nM,6233
|
|
22
|
+
dawnfix_fleet/guard.py,sha256=y4NnrTQC0qb3YfPuF_r7UOXV2MMJDUKqgSHe89DR5LE,2050
|
|
23
|
+
dawnfix_fleet/summary.py,sha256=vJZ0kih1FPAFxatrP8xmGJJHBZin56JUBu_Ns9W20v8,6575
|
|
24
|
+
dawnfix_leastpriv/__init__.py,sha256=VrXpHDu3erkzwl_WXrqINBm9xWkcyUy53IQOj042dOs,22
|
|
25
|
+
dawnfix_leastpriv/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
|
|
26
|
+
dawnfix_leastpriv/cli.py,sha256=nW79qO4_NnLpiG0sXTTO_jWXndQq38hZx_BRA8lCZPI,5006
|
|
27
|
+
dawnfix_leastpriv/collect.py,sha256=7i9JUldWkFuwFkGohmisdcsSrmgArqPq741p7VlcYEI,6735
|
|
28
|
+
dawnfix_leastpriv/constants.py,sha256=3_DehJGRm7Xldq9eBv42GlK5PE_1wmZ67GZ7InRdu10,795
|
|
29
|
+
dawnfix_leastpriv/guard.py,sha256=kXX3hYvOnmB_Rz0zC-AIfDod2qT4pmXDbXh0Le5Mw8A,2101
|
|
30
|
+
dawnfix_leastpriv/render.py,sha256=vqLApFpjYsDud5wPpvMFdpMW5IVFap66N8c3PDj6bCY,7506
|
|
31
|
+
dawnfix_leastpriv/trim.py,sha256=esJCdzUuLwPwtDlPtBGCb9gKudBm2ZFsIMkI5z9C3VA,9626
|
|
32
|
+
dawnfix_parity/__init__.py,sha256=XF_M7Dp7LphuWvzAvREcw62_ezr-NlD3isQp-O9EQcU,113
|
|
33
|
+
dawnfix_parity/__main__.py,sha256=bYt9eEaoRQWdejEHFD8REx9jxVEdZptECFsV7F49Ink,30
|
|
34
|
+
dawnfix_parity/aws.py,sha256=ixnMAt9b-HZN8XKdkk9Ix3oA2J72HogQxOArMaJE_bM,5001
|
|
35
|
+
dawnfix_parity/brand.py,sha256=bO_15DNTxFP8rzMjF-SzyN1xMydQaLV2EDK_kgmL9V4,1099
|
|
36
|
+
dawnfix_parity/cli.py,sha256=oyCsW92wF8J1FJCSzA2cBWpQVWHf9ieez-nbzRH16Jc,10464
|
|
37
|
+
dawnfix_parity/cloudtrail.py,sha256=7xB43Ne6SsnLQ2bPsmHlNiFd6a7EXMNiIx5C-zlDaaA,5332
|
|
38
|
+
dawnfix_parity/collect.py,sha256=vGz2Uy9qp_MNdOSrdmPpCmSEV5ggguzxdZOVkcjaGjs,10595
|
|
39
|
+
dawnfix_parity/config.py,sha256=pitwusj5Lb30IqUegwFWJJFITXc92jpS58qFVVf4WyE,8507
|
|
40
|
+
dawnfix_parity/diff.py,sha256=eXghwYp78UKUyCgsKYSr3EVdEuQPU5FCDEiTnj56gGk,7987
|
|
41
|
+
dawnfix_parity/ingest.py,sha256=zMByuJHNGqzb1e3La_RD0UCEZEiais7tejQl0BWtCy4,2321
|
|
42
|
+
dawnfix_parity/inventory.py,sha256=syqFRZ-V_3oazakxALFPJ5CecmGibKx0Gl_jU4JNjQM,4748
|
|
43
|
+
dawnfix_parity/model.py,sha256=F4uMTsmkrWoXAZtlTGZ1qHYnx6-cQQbxvuCKexKgxUs,3356
|
|
44
|
+
dawnfix_parity/refs.py,sha256=_RrpoZ9B-EvI_W0PJIqOLXvZX7DKewKLo78orgdBOSw,9454
|
|
45
|
+
dawnfix_parity/report.py,sha256=UAjJ8abSOANbP4HjXxhwdR3EKz33KkedoVWFuV4sJeE,6439
|
|
46
|
+
dawnfix_parity/resolve.py,sha256=v1TzTeaaKq_t3kjHEaeMXzoKYU7H_MY5QqldZfOu0-k,6638
|
|
47
|
+
dawnfix_receipt/__init__.py,sha256=VrXpHDu3erkzwl_WXrqINBm9xWkcyUy53IQOj042dOs,22
|
|
48
|
+
dawnfix_receipt/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
|
|
49
|
+
dawnfix_receipt/cli.py,sha256=P9YHiJ5vT4JxEUlK0V4FT5Q4-azIQVTUFQIT-Qdial8,5914
|
|
50
|
+
dawnfix_receipt/constants.py,sha256=dFpPiz_RwwoMlFcLSxavvBQwLJHq5pQ9Occq1IAu3aU,627
|
|
51
|
+
dawnfix_receipt/costs.py,sha256=Tz0W447yVgjUfA81aw3dlSp8MrwlzHjH_c5l62DLRoI,3454
|
|
52
|
+
dawnfix_receipt/github.py,sha256=LsT9QUfrtAmIBXJLyg_N23-HOMJakNvsoJRi7X3Pqcg,2821
|
|
53
|
+
dawnfix_receipt/guard.py,sha256=26okr2X3KIrz5O8hq_XhFQpuA5eUBnJHePBvUouSOfQ,1356
|
|
54
|
+
dawnfix_receipt/ingest.py,sha256=_gciY15kWqaif9Nwk6rS6XHYT0Wttv5vDpQ4ZKdiY7Q,5415
|
|
55
|
+
dawnfix_receipt/receipt.py,sha256=LLKeBwyyAPURpvOX1DTt5qc5yJdqPgjrMQxPjECTThk,10011
|
|
56
|
+
dawnfix_sweeper/__init__.py,sha256=VrXpHDu3erkzwl_WXrqINBm9xWkcyUy53IQOj042dOs,22
|
|
57
|
+
dawnfix_sweeper/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
|
|
58
|
+
dawnfix_sweeper/cli.py,sha256=XbEBRkxcUL09K_wEqjsVK8cJHdXRnSnJZr93Oj8nbLY,3429
|
|
59
|
+
dawnfix_sweeper/constants.py,sha256=jEmN9WzdC2jWmhLCy7eh-psgDRrMYgjsHBAIjUI-rTc,1274
|
|
60
|
+
dawnfix_sweeper/guard.py,sha256=U4KwOHAlHk0U6R0-_epfT-o6R-g8XLcwCx99HYuYtWg,2965
|
|
61
|
+
dawnfix_sweeper/plan.py,sha256=pPoBPgOcV8fjZ3FLsWcBytMHGA2_zM4ifK8X1RIsAf0,6139
|
|
62
|
+
dawnfix_sweeper/prices.json,sha256=8D8pX-PiPWnRsAWu0uYECz2tGJQp6UxpvHThzb5FMcs,54433
|
|
63
|
+
dawnfix_sweeper/pricing.py,sha256=3_tAudLOtwb0cf5IwXjLig60TGbU46Ay9gDL2rejTkc,5355
|
|
64
|
+
dawnfix_sweeper/scan.py,sha256=C-RAldWCXx258_6BBxth87AND621lP3XXRmhM_P9jBU,45164
|
|
65
|
+
logbill/__init__.py,sha256=Le8YuOnXHKl9FI9W_-gjX74Jw59ULPIf8Zsp-fpjOew,117
|
|
66
|
+
logbill/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
|
|
67
|
+
logbill/awsread.py,sha256=BoTJ-8Yh1yAfbAbUj4AB6qJWdcppvuDuZtbs6SnL6Dc,4953
|
|
68
|
+
logbill/brand.py,sha256=OyMZRem6abORnYOM1f0pMrHVrmHrkReieFLAe6g56Xw,1327
|
|
69
|
+
logbill/cli.py,sha256=0L13BDzi9uoPrEHPRlv1LfPI1yi0XtS_L5SvICzve6k,8839
|
|
70
|
+
logbill/doc_style.css,sha256=fIMD1xP7_41kufn_WY8K2ssJybunHCvXcs1RjyFnXB4,11275
|
|
71
|
+
logbill/fix.py,sha256=Yq11QSoVXAi5YqHEEchWx6tpbHAPKn0GEbSzbViasJI,3027
|
|
72
|
+
logbill/insights.py,sha256=onF1KFTnSH7yiyfQnpnp7goCK1xrm47U35wJsMq6crQ,6381
|
|
73
|
+
logbill/locate.py,sha256=qiYTaeJBggEW1nj2h9fAOb59d3Il6Cq_H9xghijwnYs,5055
|
|
74
|
+
logbill/model.py,sha256=ehAe9bbL1-EldkaiO3GiBSS-EZG-WKvL2X8AEaZ9mZA,3940
|
|
75
|
+
logbill/prices.json,sha256=KR52kszSOjOAtqM7lUWXhF580hrxd9UssN4BymkGRF4,14344
|
|
76
|
+
logbill/prices.py,sha256=OnCPiFRU5Hi19l77mlQXvpekZJmp_Gtg9-vXE5hDtzg,2611
|
|
77
|
+
logbill/report.py,sha256=QEb1yi54cwiIetDFB0Mf7qkRd-_f4K4fnIdD-Qn86gc,9762
|
|
78
|
+
logbill/scan.py,sha256=t6bpopgYvr84Fj8kcy8NKnSaGDI2pDxfbJ87EbUDVas,7096
|
|
79
|
+
logbill/suggest.py,sha256=3O413AA_dewzdF7OpmbJAsICTaPJPqo7zr7EDoDQLkY,7838
|
|
80
|
+
dawnfix-0.3.0.dist-info/METADATA,sha256=Ss_fqhz8xNxaTvVyh-1ZE5MyYxpm2W7nDpK42Mo294w,11357
|
|
81
|
+
dawnfix-0.3.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
82
|
+
dawnfix-0.3.0.dist-info/entry_points.txt,sha256=RwEOfE8e3GA7DFMEv_REkzlZxdclItsBvU87qQPoMi8,250
|
|
83
|
+
dawnfix-0.3.0.dist-info/top_level.txt,sha256=rnKLw4K73CSVbjIpSo4W1e6Y2AAZHW24BZe7zA51gAU,100
|
|
84
|
+
dawnfix-0.3.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-ALv2
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 Siva Koza d.o.o.
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
dawnfix_core/__init__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""dawnfix-core: deterministic, read-only tick over prod logs (no LLM)."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.3.0"
|
|
4
|
+
|
|
5
|
+
# The read-only AWS guard is public API (other Dawnfix tools build their clients with it).
|
|
6
|
+
from .awsguard import ReadOnlyViolation, make_client # noqa: E402,F401
|
|
7
|
+
|
|
8
|
+
__all__ = ["ReadOnlyViolation", "__version__", "make_client"]
|
dawnfix_core/__main__.py
ADDED
dawnfix_core/awsguard.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""boto3 clients that can only make the calls they were built for.
|
|
2
|
+
|
|
3
|
+
Public API (also re-exported from ``dawnfix_core.sources.aws``)::
|
|
4
|
+
|
|
5
|
+
from dawnfix_core.awsguard import ReadOnlyViolation, make_client
|
|
6
|
+
|
|
7
|
+
logs = make_client(session, "logs", "eu-central-1") # per-service default
|
|
8
|
+
sts = make_client(session, "sts", None, allowed={"GetCallerIdentity"})
|
|
9
|
+
|
|
10
|
+
Every client gets one guard, registered first on two botocore events:
|
|
11
|
+
|
|
12
|
+
- ``provide-client-params``: the first event of every API call, before botocore's own
|
|
13
|
+
handlers and before a ``Stubber`` answers, so a refused call never reaches the
|
|
14
|
+
parameter builder, the signer or the network.
|
|
15
|
+
- ``before-parameter-build``: the event the guard used before; kept so a handler
|
|
16
|
+
chain that skips the first event still meets the guard.
|
|
17
|
+
|
|
18
|
+
An operation outside the client's allowlist raises ``ReadOnlyViolation``. A service with
|
|
19
|
+
no default allowlist and no ``allowed`` refuses every call: nothing is allowed by
|
|
20
|
+
omission.
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
from collections.abc import Iterable
|
|
25
|
+
|
|
26
|
+
GUARD_EVENTS = ("provide-client-params", "before-parameter-build")
|
|
27
|
+
|
|
28
|
+
# What dawnfix-core's own AWS source calls, per boto3 service name.
|
|
29
|
+
DEFAULT_ALLOWED: dict[str, frozenset[str]] = {
|
|
30
|
+
"logs": frozenset({"FilterLogEvents"}),
|
|
31
|
+
"cloudwatch": frozenset({"DescribeAlarms", "GetMetricData"}),
|
|
32
|
+
"elbv2": frozenset({"DescribeLoadBalancers", "DescribeTargetGroups"}),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# The union, kept for callers of the earlier single allowlist.
|
|
36
|
+
READ_ONLY_OPERATIONS: frozenset[str] = frozenset().union(*DEFAULT_ALLOWED.values())
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ReadOnlyViolation(RuntimeError):
|
|
40
|
+
"""An AWS call outside the client's allowlist was refused before it was built.
|
|
41
|
+
|
|
42
|
+
``service`` and ``operation`` name the refused call (``ssm``, ``PutParameter``) so a
|
|
43
|
+
caller can word its own message; both are ``None`` when raised by other code.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
def __init__(self, message: str = "", *, service: str | None = None, operation: str | None = None):
|
|
47
|
+
super().__init__(message)
|
|
48
|
+
self.service = service
|
|
49
|
+
self.operation = operation
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def allowed_for(service: str, allowed: Iterable[str] | None = None) -> frozenset[str]:
|
|
53
|
+
"""The allowlist a client for ``service`` gets: ``allowed`` if given, else the default."""
|
|
54
|
+
if allowed is not None:
|
|
55
|
+
if isinstance(allowed, str):
|
|
56
|
+
raise TypeError("allowed must be a collection of operation names, not a string")
|
|
57
|
+
return frozenset(allowed)
|
|
58
|
+
return DEFAULT_ALLOWED.get(service, frozenset())
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def guard_for(service: str, allowed: frozenset[str]):
|
|
62
|
+
def guard(model=None, **_):
|
|
63
|
+
if model is not None and model.name not in allowed:
|
|
64
|
+
raise ReadOnlyViolation(
|
|
65
|
+
f"dawnfix is read-only; refused AWS call {service}:{model.name} "
|
|
66
|
+
"(not in this client's allowlist)",
|
|
67
|
+
service=service,
|
|
68
|
+
operation=model.name,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return guard
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def make_client(session, service: str, region: str | None, allowed: Iterable[str] | None = None,
|
|
75
|
+
*, config=None):
|
|
76
|
+
"""A boto3 client from ``session`` that refuses any operation outside its allowlist.
|
|
77
|
+
|
|
78
|
+
``allowed`` is a set of operation names as AWS spells them (``FilterLogEvents``), not
|
|
79
|
+
boto3 method names. ``None`` takes ``DEFAULT_ALLOWED[service]`` (empty for others).
|
|
80
|
+
``config`` is an optional ``botocore.config.Config`` (user agent, retries), passed to
|
|
81
|
+
``session.client`` unchanged; it cannot affect the guard.
|
|
82
|
+
"""
|
|
83
|
+
ops = allowed_for(service, allowed)
|
|
84
|
+
kwargs = {"region_name": region}
|
|
85
|
+
if config is not None:
|
|
86
|
+
kwargs["config"] = config
|
|
87
|
+
client = session.client(service, **kwargs)
|
|
88
|
+
guard = guard_for(service, ops)
|
|
89
|
+
for event in GUARD_EVENTS:
|
|
90
|
+
client.meta.events.register_first(event, guard, unique_id=f"dawnfix-readonly-{event}")
|
|
91
|
+
return client
|
dawnfix_core/cli.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""dawnfix tick | validate | config."""
|
|
2
|
+
import argparse
|
|
3
|
+
import json
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from . import __version__
|
|
8
|
+
from . import config as cfg
|
|
9
|
+
from . import state as st
|
|
10
|
+
from . import tick as tk
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _write_json(path: str, doc: dict) -> None:
|
|
14
|
+
p = Path(path)
|
|
15
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
16
|
+
p.write_text(json.dumps(doc, indent=2) + "\n")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def cmd_tick(args, sources=None) -> int:
|
|
20
|
+
config = cfg.load(args.config)
|
|
21
|
+
state = st.load(args.state)
|
|
22
|
+
result = tk.run(config, state, window_minutes=args.window_minutes, sources=sources,
|
|
23
|
+
baseline_only=args.baseline)
|
|
24
|
+
s = result.findings["summary"]
|
|
25
|
+
failed = [r["id"] + "=" + r["error_code"] for r in result.findings["sources"] if not r["ok"]]
|
|
26
|
+
line = (f"dawnfix: {s['events']} events, {s['fingerprints']} fingerprints, "
|
|
27
|
+
f"{s['new']} new, {s['spike']} spike, {s['known']} known, {s['ignored']} ignored")
|
|
28
|
+
if failed:
|
|
29
|
+
line += f"; failed sources: {', '.join(failed)}"
|
|
30
|
+
if args.dry_run:
|
|
31
|
+
# Exactly what would be sent to the hosted service; nothing is written.
|
|
32
|
+
print(json.dumps(result.ingest, indent=2))
|
|
33
|
+
print(line + " (dry run: state and findings not written)", file=sys.stderr)
|
|
34
|
+
return result.exit_code
|
|
35
|
+
_write_json(args.out, result.findings)
|
|
36
|
+
if args.ingest_out:
|
|
37
|
+
_write_json(args.ingest_out, result.ingest)
|
|
38
|
+
if result.exit_code != tk.EXIT_ERROR:
|
|
39
|
+
st.save(args.state, result.state)
|
|
40
|
+
print(line, file=sys.stderr)
|
|
41
|
+
return result.exit_code
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def cmd_validate(args) -> int:
|
|
45
|
+
config = cfg.load(args.config)
|
|
46
|
+
kinds = ", ".join(s.id for s in config.sources)
|
|
47
|
+
print(f"{args.config}: ok ({kinds}; {len(config.rules)} rules; autonomy {config.autonomy})")
|
|
48
|
+
return 0
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def cmd_config(args) -> int:
|
|
52
|
+
config = cfg.load(args.config)
|
|
53
|
+
doc = config.resolved()
|
|
54
|
+
if args.json:
|
|
55
|
+
print(json.dumps(doc, indent=2))
|
|
56
|
+
return 0
|
|
57
|
+
for k, v in doc.items():
|
|
58
|
+
if isinstance(v, dict):
|
|
59
|
+
for k2, v2 in v.items():
|
|
60
|
+
print(f"{k}.{k2}: {v2}")
|
|
61
|
+
else:
|
|
62
|
+
print(f"{k}: {v}")
|
|
63
|
+
return 0
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def parser() -> argparse.ArgumentParser:
|
|
67
|
+
p = argparse.ArgumentParser(prog="dawnfix", description="Deterministic, read-only prod log tick.")
|
|
68
|
+
p.add_argument("--version", action="version", version=f"dawnfix-core {__version__}")
|
|
69
|
+
sub = p.add_subparsers(dest="command", required=True)
|
|
70
|
+
|
|
71
|
+
t = sub.add_parser("tick", help="query sources, dedupe, write findings.json")
|
|
72
|
+
t.add_argument("--config", default=".dawnfix.yml")
|
|
73
|
+
t.add_argument("--state", required=True, help="JSON state file (created if missing)")
|
|
74
|
+
t.add_argument("--out", default="findings.json")
|
|
75
|
+
t.add_argument("--ingest-out", help="also write the ingest payload here")
|
|
76
|
+
t.add_argument("--window-minutes", type=int, default=60)
|
|
77
|
+
t.add_argument("--dry-run", action="store_true", help="print the ingest payload; write nothing")
|
|
78
|
+
t.add_argument("--baseline", action="store_true",
|
|
79
|
+
help="record everything seen as known (first run on a noisy prod); exit 0")
|
|
80
|
+
|
|
81
|
+
v = sub.add_parser("validate", help="check .dawnfix.yml")
|
|
82
|
+
v.add_argument("--config", default=".dawnfix.yml")
|
|
83
|
+
|
|
84
|
+
c = sub.add_parser("config", help="print the resolved config (defaults filled in)")
|
|
85
|
+
c.add_argument("--config", default=".dawnfix.yml")
|
|
86
|
+
c.add_argument("--json", action="store_true", help="as JSON, for the workflow")
|
|
87
|
+
return p
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def main(argv=None, sources=None) -> int:
|
|
91
|
+
args = parser().parse_args(argv)
|
|
92
|
+
if args.command == "tick" and not (1 <= args.window_minutes <= 7 * 24 * 60):
|
|
93
|
+
print("dawnfix: --window-minutes must be between 1 and 10080", file=sys.stderr)
|
|
94
|
+
return tk.EXIT_USAGE
|
|
95
|
+
try:
|
|
96
|
+
if args.command == "tick":
|
|
97
|
+
return cmd_tick(args, sources=sources)
|
|
98
|
+
if args.command == "config":
|
|
99
|
+
return cmd_config(args)
|
|
100
|
+
return cmd_validate(args)
|
|
101
|
+
except cfg.ConfigError as e:
|
|
102
|
+
print(f"dawnfix: config error: {e}", file=sys.stderr)
|
|
103
|
+
return tk.EXIT_USAGE
|
|
104
|
+
except st.StateError as e:
|
|
105
|
+
print(f"dawnfix: state error: {e}", file=sys.stderr)
|
|
106
|
+
return tk.EXIT_USAGE
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if __name__ == "__main__":
|
|
110
|
+
sys.exit(main())
|