Skip to content

feat(detectors): add admin_event_missing detector (Detectors wave 3) - #863

Open
playmaker410 wants to merge 2 commits into
Centurylong:mainfrom
playmaker410:feat/detector-admin-event-missing
Open

feat(detectors): add admin_event_missing detector (Detectors wave 3)#863
playmaker410 wants to merge 2 commits into
Centurylong:mainfrom
playmaker410:feat/detector-admin-event-missing

Conversation

@playmaker410

Copy link
Copy Markdown

Summary

Closes #789

Adds the admin_event_missing static-analysis detector (finding code SANCT_ADMIN_EVENT_MISSING) as part of the Detectors wave 3 epic.

Privileged config changes that emit no event are invisible to monitors and audits. This detector makes them visible.

Acceptance Criteria

  • Flags admin/config mutations lacking an event emit
  • No false positive when an event is emitted (env.events().publish, emit, log)
  • Follows the rule pattern in tooling/sanctifier-core/src/rules/
  • Insta golden snapshot committed
  • All CI tests pass (258 tests, 0 failures)

Detection Logic

Flags any #[contractimpl] function whose name contains an admin/config-change keyword (set_, update_, change_, configure, pause, unpause, upgrade, transfer_admin, set_admin, set_owner, migrate) that:

  1. Contains a storage mutation (.set/.update/.remove on .persistent()/.instance()/.temporary())
  2. Does not contain an event emit (.events().publish(…) or publish/emit/log method call)

Suppression: // sanctifier:ignore[SANCT_ADMIN_EVENT_MISSING]

Files Changed

File Change
src/finding_codes.rs Add SANCT_ADMIN_EVENT_MISSING constant + FindingCode entry
src/rules/admin_event_missing.rs New rule implementation (syn visitor)
src/rules/mod.rs Register module + rule in with_default_rules()
tests/detector_snapshots.rs Wire snapshot_admin_event_missing test
tests/fixtures/detectors/admin_event_missing.rs Fixture: 3 violations, 3 clean, 1 suppressed, 1 test-excluded
tests/snapshots/detector_snapshots__admin_event_missing.snap Golden snapshot (3 violations)
tests/fixtures/corpus/differential-corpus.json Wire new rule into corpus map
tests/fixtures/gallery/upgrade_auth_fixed.rs Add event emit to fixed gallery fixture
tests/snapshots/gallery_snapshots__upgrade_auth_vulnerable.snap Update snapshot
docs/detectors/admin_event_missing.md Documentation page
docs/detectors/README.md Add catalog table row

Testing

cargo test -p sanctifier-core --no-default-features
# 258 passed, 0 failed

@github-actions github-actions Bot added rust Pull requests that update rust code area: core-engine sanctifier-core static analysis engine area: docs Documentation and guides area: testing Tests, benchmarks, fuzzing size/l labels Jul 27, 2026
@Gbangbolaoluwagbemiga

Copy link
Copy Markdown
Contributor

@playmaker410, resolve conflicts please

@playmaker410
playmaker410 force-pushed the feat/detector-admin-event-missing branch from 8c45d55 to 3850eb2 Compare July 27, 2026 14:32
@Gbangbolaoluwagbemiga

Copy link
Copy Markdown
Contributor

@playmaker410, please resolve conflicts

Adds SANCT_ADMIN_EVENT_MISSING static-analysis detector that flags
admin/config-change functions which mutate Soroban storage without
emitting a corresponding on-chain event.

Privileged config changes that emit no event are invisible to monitors
and audits. This detector makes them visible.

Acceptance criteria met:
- Flags admin/config mutations lacking an event emit
- No FP when an event is emitted (env.events().publish / emit / log)
- Follows the rule pattern in tooling/sanctifier-core/src/rules/
- Insta golden snapshot committed (3 violations from fixture)
- All CI tests pass (258 tests, 0 failures)

Files changed:
- src/finding_codes.rs: add SANCT_ADMIN_EVENT_MISSING constant + FindingCode entry
- src/rules/admin_event_missing.rs: full Rule implementation with syn visitor
- src/rules/mod.rs: register module and rule in with_default_rules()
- tests/detector_snapshots.rs: wire snapshot_admin_event_missing test
- tests/fixtures/detectors/admin_event_missing.rs: fixture with 3 violations, 3 clean cases, 1 suppressed, 1 test-module exclusion
- tests/snapshots/detector_snapshots__admin_event_missing.snap: golden snapshot
- tests/fixtures/corpus/differential-corpus.json: wire SANCT_ADMIN_EVENT_MISSING into rule-to-code map and update upgrade_auth observed_codes
- tests/fixtures/gallery/upgrade_auth_fixed.rs: add event emit to fixed gallery fixture
- tests/snapshots/gallery_snapshots__upgrade_auth_vulnerable.snap: update snapshot for new detector
- docs/detectors/admin_event_missing.md: documentation page
- docs/detectors/README.md: add table row

Suppression: sanctifier:ignore[SANCT_ADMIN_EVENT_MISSING]
@playmaker410
playmaker410 force-pushed the feat/detector-admin-event-missing branch from 3850eb2 to b9c84a2 Compare July 29, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core-engine sanctifier-core static analysis engine area: docs Documentation and guides area: testing Tests, benchmarks, fuzzing rust Pull requests that update rust code size/l

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detector: Admin/config change without a corresponding event

2 participants