Exemptions
Exemptions in x-fidelity provide a way to temporarily waive specific rules for a given repository. This feature is useful when you need to make exceptions to your standard rules due to specific project requirements or during a transition period.
How Exemptions Work
-
Definition: An exemption is defined for a specific rule and repository URL, with an expiration date and a reason.
-
Storage: Exemptions can be stored in two ways:
- Single JSON file:
[archetype]-exemptions.json
- Directory of JSON files:
[archetype]-exemptions/*.json
- Single JSON file:
-
Structure: Each exemption is an object with:
{
"repoUrl": "git@github.com:org/repo.git",
"rule": "outdatedFramework-global",
"expirationDate": "2024-12-31",
"reason": "Upgrade scheduled for Q4"
} -
Application: When x-fidelity runs, it checks if there's an active exemption for each rule violation before reporting it.
Managing Exemptions
Local Configuration
Create an exemptions file or directory:
# Single file approach
touch config/node-fullstack-exemptions.json
# Directory approach
mkdir -p config/node-fullstack-exemptions
touch config/node-fullstack-exemptions/team1-exemptions.json
Remote Configuration
Exemptions can be fetched from the config server:
xfidelity . --configServer https://config-server.example.com
The server endpoint /archetypes/:archetype/exemptions
provides the exemptions.
Example Exemption Files
Single file (node-fullstack-exemptions.json
):
[
{
"repoUrl": "git@github.com:org/repo.git",
"rule": "outdatedFramework-global",
"expirationDate": "2024-12-31",
"reason": "Upgrade scheduled for Q4"
},
{
"repoUrl": "git@github.com:org/repo.git",
"rule": "sensitiveLogging-iterative",
"expirationDate": "2024-09-30",
"reason": "Security audit planned for Q3"
}
]
Directory structure:
node-fullstack-exemptions/
├── team1-exemptions.json
└── team2-exemptions.json
Security Considerations
-
Access Control:
- Limit who can create/modify exemptions
- Use version control for exemption files
- Require approval for exemption changes
-
Expiration Dates:
- Set realistic but short-term dates
- Review exemptions regularly
- Plan for removing exemptions
-
Documentation:
- Require clear reasons for exemptions
- Document planned resolution dates
- Track exemption patterns
Best Practices
-
Limited Duration:
- Set short-term expiration dates
- Renew if necessary rather than setting far-future dates
- Plan for removing exemptions
-
Clear Documentation:
- Provide detailed reasons
- Include ticket/issue references
- Document resolution plans
-
Regular Review:
- Monitor active exemptions
- Track expiration dates
- Plan for remediation
-
Minimal Use:
- Use exemptions sparingly
- Address root causes
- Plan for permanent fixes
-
Team Communication:
- Notify teams of exemptions
- Share remediation plans
- Track progress
Telemetry
Exemption usage is tracked through telemetry:
- Exemption allowed events
- Expiration tracking
- Usage patterns
Next Steps
- Learn about GitHub Webhooks
- Configure CI/CD Integration
- Set up Remote Configuration