Skip to content

fix: validate YYYY-MM-DD date options on exception/miss/accept commands - #7

Merged
vsn411 merged 1 commit into
secfoo-com:mainfrom
Varunpoojari:fix/cli-date-validation
Sep 16, 2026
Merged

vsn411 merged 1 commit into
secfoo-com:mainfrom
Varunpoojari:fix/cli-date-validation

Conversation

@Varunpoojari

@Varunpoojari Varunpoojari commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

What does this change, and why?

secfoo exception create/update, miss create, and accept create/update all take --expires-at / --discovered-at options documented as YYYY-MM-DD, but never validated the value. A typo like --expires-at not-a-date was silently accepted and stored as-is.

This doesn't crash anything, which is exactly the problem: both storage/repository.py's expiry-aging-bucket calculation and web/top_findings.py's past-due detector parse this field with datetime.fromisoformat() wrapped in a bare except ValueError: continue. So a malformed date is just silently skipped forever -- the record still looks normal in list/show, but its expiry can never be tracked, flagged past-due, or surfaced on the dashboard again. For a risk-acceptance/exception tracking feature, that's a silent correctness bug, not a cosmetic one.

Found while installing and exercising the CLI end-to-end (including a real secfoo run --skill sast --agent claude scan against a sample vulnerable app, which worked correctly) as part of onboarding onto this repo.

Fix

Adds a shared _validate_date() Typer callback and wires it into the five affected options, so a bad date is rejected immediately with a clear Invalid value for '--expires-at': '...' is not a valid date -- expected YYYY-MM-DD. error instead of being stored silently. Existing valid-date behavior is unchanged.

Testing

  • pytest tests passes (637 passed, including 5 new tests for this change)
  • ruff check . -- no new findings beyond the project's existing pre-CI-gate backlog
  • Added tests for the behavior change (test_cli_exception.py, test_cli_miss.py, test_cli_accept.py)

secfoo exception create/update, miss create, and accept create/update
all accept --expires-at / --discovered-at options documented as
YYYY-MM-DD, but never validated the value -- a typo like "not-a-date"
was silently accepted and stored as-is.

That silently disables the feature rather than crashing: both
storage/repository.py's expiry-aging-bucket calculation and
web/top_findings.py's past-due detector parse this field with
datetime.fromisoformat() wrapped in a bare `except ValueError: continue`,
so a malformed date just gets skipped forever -- the record looks normal
in `list`/`show`, but its expiry can never be tracked, flagged past-due,
or surfaced on the dashboard again.

Adds a shared _validate_date() Typer callback and wires it into the five
affected options so a bad date is rejected immediately with a clear
error instead of stored silently. Covered by 5 new tests (existing valid-
date behavior is unchanged).
@vsn411
vsn411 merged commit 0cb3596 into secfoo-com:main Sep 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants