Skip to content

Add internal Roslyn analyzers for secret-handling and provider auth safety #133

@Aaronontheweb

Description

@Aaronontheweb

Problem

We keep re-discovering policy-level mistakes that compile and often pass tests:

  • Writing or parsing secret material outside approved secret handlers
  • Probing provider configs with only API keys, missing OAuth token fallback
  • Descriptor/auth metadata drift (feature advertised but not fully configured)

These are good candidates for static enforcement via internal analyzers (WASDN).

Proposal

Add an internal analyzer package/ruleset for Netclaw that enforces security/config invariants at compile time.

Candidate rules

  1. No direct secrets file writes

    • Disallow File.Write* to paths resolving to secrets.json
    • Require SecretsFileWriter / ConfigFileHelper.WriteSecretsFile / approved APIs
  2. No raw secret serialization paths

    • Flag direct serialization/writes of secret-bearing values (SensitiveString, provider secret nodes) outside approved handlers
  3. Encrypted secret parse must decrypt first

    • Flag parsing of secret JSON string fields when decryption helper/protector is not applied first
  4. Provider probe credential fallback

    • For ProviderEntry probe callsites, require credential expression equivalent to ApiKey ?? OAuthAccessToken
  5. OAuth capability metadata consistency

    • If descriptor supports AuthMethod.OAuthDevice, require non-null OAuth endpoint/client metadata (or explicit opt-out attribute for TBD providers)

Scope / non-goals

  • Not blocking current PRs immediately; can start as warning then ratchet to error
  • Keep false positives low with explicit allowlist/attributes for intentional exceptions

Deliverables

Acceptance criteria

  • New violations fail CI (after rollout gate)
  • Existing codebase either clean or baseline documented
  • At least one autofix or code-action where practical

Metadata

Metadata

Assignees

No one assigned

    Labels

    securitySecurity-related changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions