Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement threat models as extension packs #14548

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dbartol
Copy link
Contributor

@dbartol dbartol commented Oct 19, 2023

This PR allows users to configure the threat models for their analysis by representing each threat model as an extension pack that can be added to the analysis. For example, if a user wanted to enable the "local flow sources" threat model, they would run codeql database analyze --extensionPack codeql/threat-local, or the Actions or VS Code equivalent. This avoids having to add a new configuration option in many different places.

Implementation notes

I moved the existing ExternalFlowConfiguration.qll file from Java into its own library pack, codeql/threat-models. This pack is language-agnostic. Any language that wants to consume threat models will depend on this pack, and every threat model extension pack will target this pack for extension.

For each of the high-level threat models currently supported, I added a new extension pack codeql/threat-<name>, where <name> is the name of the threat model. This extension pack just adds a single row to the supportedThreatModels predicate from codeql/threat-models, specifying the name of the threat model.

The threat model system in QL supports a hierarchy of threat models (for example, "files" and "environment" are both sub-threat-models of "local"). I haven't added extension packs for the low-level threat models yet, but we can add those later easily enough.

@github-actions github-actions bot added the Java label Oct 19, 2023
@dbartol dbartol added the no-change-note-required This PR does not need a change note label Oct 19, 2023
@dbartol dbartol marked this pull request as ready for review October 20, 2023 18:05
@dbartol dbartol requested a review from a team as a code owner October 20, 2023 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Java no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant