mirror of
https://github.com/beenuar/AiSOC.git
synced 2026-11-24 08:35:46 +08:00
* test(detections): gate DRL-1.1 author attribution, failing on the current corpus Florian Roth (SigmaHQ) reports in #1680 that rules imported from SigmaHQ strip the upstream author, which DRL-1.1 does not permit: author identification has to travel with a shared copy, including a modified one, and has to appear in messages produced by a match. This commit is the gate alone, so the failure is on the record before the fix. Against the current tree it exits 1 and names: vendored YAML 3,132 DRL-1.1 rules, 3,132 with no author compiled ruleset (fusion) 1,770, all 1,770 with no author compiled ruleset (api mirror) 1,770, all 1,770 with no author marketplace index x3 3,132, no provenance author, and all 3,132 carrying author: AiSOC The last line is the part the report did not reach. The console does not merely omit the upstream author, it names this project in their place. The gate checks presence, not a list of expected names: a gate holding its own copy of 749 author strings would be a second source of truth that drifts at the next import. * fix(detections): carry the upstream Sigma author onto every rule and alert Closes #1680, reported by Florian Roth (SigmaHQ). DRL-1.1 permits redistribution in modified form on condition that author identification travels with the copy and appears in messages produced by a match. Three layers dropped it independently, so fixing any one would have left the obligation unmet: tools/detection_import/sigma_importer.py built provenance from source, id, commit, licence and path, never reading the author: field sitting in the same dict. This is the one that produced the 3,132 vendored rules. services/api/.../sigma_import.py same omission on the runtime import path. scripts/build_marketplace.py projected provenance without the author AND defaulted the item-level author to AiSOC, so the console did not merely omit the upstream author, it named this project instead. scripts/sync_sigma_authors.py restores and — the durable half — verifies the attribution against SigmaHQ/sigma at df5c6a6ecc149e05cb4dea306012668fb2ae5a12, the commit the importer already pins, so the credit is reproducible rather than whatever master holds today. Rules are matched on the Sigma UUID, not the path: 3,132 of 3,132 resolve. Two measurement traps found while building it, both of which would have shipped a wrong answer while reporting success. Reading the upstream id with a regex anchored on end-of-line lost ten rules whose id carries a trailing YAML comment. Reading the written value back by stripping quotes with str.strip() truncated 90 authors such as Mark Morowczynski '@markmorow' and reported disagreements that did not exist. Both sides are parsed now; only the write-back is line-based, so the vendored files keep their formatting. Multi-author rules keep upstream's own comma-separated spelling (1,098 of them) rather than a shape this project invented. A rule upstream credits to nobody records (no author recorded upstream) — never empty, which is indistinguishable from the defect, and never SigmaHQ, which is the substitution the licence does not accept. No rule needs it at this commit. Measured after: 1,770 of 1,770 compiled rules, 3,132 of 3,132 vendored rules and all three marketplace mirrors name their author. Executable count is unchanged at 1,770. * test(detections): run the attribution negative control, and credit the author in the console Three parts, all of which the fix needs to be believable. The negative control is executed rather than asserted: the test copies the compiled ruleset aside, blanks every author, requires the gate to exit 1 naming the surface, then restores the original and checks it byte-identical. A gate that has never been observed to fail is indistinguishable from one that cannot. The alert assertion drives the real DetectionEngine.build_alert() rather than the rendering helper, because DRL-1.1's clause is about what an operator reads. A match on the rule from #1680 now produces: Detection rule sigmahq-sigma-002bdb95-… (endpoint) fired on ingested telemetry. Translated from SigmaHQ/sigma by Tim Shelton (rules/windows/ file/file_event/file_event_win_cscript_wscript_dropper.yml), licensed under DRL-1.1 <https://github.com/SigmaHQ/Detection-Rule-License>. The console renders the credit on the card itself, not in a detail panel: the licence asks attribution to travel with the copy, and the card is the copy most readers ever see. The item type had no author field at all, which is how 3,132 rules came to display author: AiSOC with no mention of the person who wrote them. The link points at the pinned commit rather than master, because a link to a moving target does not identify what we shipped. Also: the claim matrix gains a row for the new gate, and the two prose sites that publish its tally are brought back into agreement with the table. That drift (383/374 against a table holding 384/375) was already on main and reds every open pull request, so it is corrected here rather than worked around. * test(web): assert the catalogue card credits the upstream author The issue was filed against apps/web, so the console surface gets its own assertions rather than relying on the data being right underneath it. Both directions, because a view that printed a credit unconditionally would pass a one-sided suite while inventing an author for content that has none: an imported rule names Tim Shelton, names DRL-1.1 and links to the rule at the pinned commit; first-party content gains no credit line at all; and a rule whose upstream recorded no author reads 'No upstream author recorded' with the licence still travelling and no name fabricated in the gap. Negative control observed: deleting the credit render fails 5 of the 7, and the 2 that keep passing are exactly the two asserting a credit is *not* printed — the asymmetry that shows the suite tests both directions. The fixtures keep their real tier ('imported') and the test clicks through the view's default stable-tier filter to reach them, rather than relabelling a Sigma import as 'stable' to make it render. * test(api): pin author capture on the runtime Sigma import path The service-side importer had the same omission as the vendoring one, and its own suite asserted every other provenance field. Covers the three cases that matter: a single author, upstream's comma-separated multi-author string preserved verbatim, and a rule upstream credits to nobody recorded as absent rather than as an empty string or as the publisher's name. * chore(security): count the new urlopen call site in the semgrep ratchet scripts/sync_sigma_authors.py fetches SigmaHQ/sigma at the pinned commit, so it adds a sixth dynamic-urllib-use-detected WARNING — the same shape as the five this repository already counts. Attributed before the ceiling moved, which is the condition the allowlist places on raising one: the branch adds exactly one urlopen call site and error is unchanged at 44, which distinguishes a new WARNING of a known shape from the scanner's documented +/-1, since that drift moves error and total together. The call is hardened the way the precedent describes rather than suppressed: the root is a module-level literal, the commit is refused unless it matches ^[0-9a-f]{40}$, and the fetch refuses any URL not starting with that root. A ceiling counts a finding; a suppression hides it. * test(detections): drive the alert probe out of process services/api, services/connectors and services/fusion all name their top-level package app, so importing fusion inside the shared pytest session put it in sys.modules for everything after it — and the next test doing 'from app.playbook import ...' got fusion's package and a ModuleNotFoundError. The attribution test took 21 tests in test_playbook_schema_parity_gate down with it, none of which have anything to do with attribution. Measured: mine + the parity gate was 25 passed / 21 errors, and is now 46 passed. The assertion is unchanged — a subprocess still drives the real engine and the real build_alert(), it just keeps the collision out of the session. * style: formatter pass on the attribution test