Repository navigation
Unified: Add a unified Swift sensitive data library and use it in unified/swift/cleartext-logging #23131
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
Open
geoffw0
wants to merge
11
commits into
github:main
Choose a base branch
from
geoffw0:unifiedsensitive
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Unified: Add a unified Swift sensitive data library and use it in unified/swift/cleartext-logging #23131
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
871e115
Unified: Port the full test for cleartext-logging from original Swift.
geoffw0 ce00358
Unified: Add test cases for globals, enum values, member functions.
geoffw0 ed3b1a9
Unified: Clean up unified/swift/cleartext-logging a little.
geoffw0 33817d1
Unified: Add Swift-specific sensitive data library layer.
geoffw0 e676316
Unified: Use the standard alert message for this query.
geoffw0 c9dfbee
Unified: Add function call targets as potential sensitive data sources.
geoffw0 941120a
Unified: Add full receiver chains as potential sensitive data.
geoffw0 8ad7588
Unified: Swap alert location from the sink to the source (as requeste…
geoffw0 87ee517
Unified: Update the alert message now that the source is the alert lo…
geoffw0 7a33cb8
Unified: Autoformat.
geoffw0 55579a8
Update unified/ql/lib/codeql/unified/security/SensitiveData.qll
geoffw0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,77 @@ | ||||||
| /** | ||||||
| * Provides classes and predicates for identifying sensitive data. | ||||||
| * | ||||||
| * 'Sensitive' data is anything that should not be sent in unencrypted form. This library tries to | ||||||
| * guess where sensitive data may either be stored in a variable or produced by a method. | ||||||
| */ | ||||||
|
|
||||||
| import unified | ||||||
| import codeql.concepts.internal.SensitiveDataHeuristics | ||||||
| private import codeql.unified.internal.typeinference.TypeInference as TypeInference | ||||||
|
|
||||||
| /** | ||||||
| * A data flow node that might contain sensitive data. | ||||||
| */ | ||||||
| cached | ||||||
| abstract class SensitiveData extends DataFlow::Node { | ||||||
| /** | ||||||
| * Gets the classification of sensitive data this expression might contain. | ||||||
| */ | ||||||
| cached | ||||||
| abstract SensitiveDataClassification getClassification(); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * An identifier that might contain sensitive data. | ||||||
| */ | ||||||
| private class SensitiveDataIdentifier extends SensitiveData { | ||||||
| SensitiveDataClassification classification; | ||||||
|
|
||||||
| SensitiveDataIdentifier() { | ||||||
| exists(IdentifierExpr e | e = this.asExpr() | | ||||||
| HeuristicNames::nameIndicatesSensitiveData(e.getValue(), classification) | ||||||
| ) | ||||||
| } | ||||||
|
|
||||||
| override SensitiveDataClassification getClassification() { result = classification } | ||||||
| } | ||||||
|
|
||||||
| private Expr memberAccessParent(MemberAccessExpr e) { result = e.getParent() } | ||||||
|
|
||||||
| /** | ||||||
| * A member access that might contain sensitive data. This includes a member itself and | ||||||
| * components of a receiver chain, for example: | ||||||
| * ``` | ||||||
| * object.password | ||||||
| * password.value | ||||||
| * password.getValue() | ||||||
| * ``` | ||||||
| */ | ||||||
| private class SensitiveDataMemberAccess extends SensitiveData { | ||||||
| SensitiveDataClassification classification; | ||||||
|
|
||||||
| SensitiveDataMemberAccess() { | ||||||
| exists(MemberAccessExpr e | memberAccessParent*(e) = this.asExpr() | | ||||||
| HeuristicNames::nameIndicatesSensitiveData(e.getMemberName(), classification) | ||||||
| ) | ||||||
| } | ||||||
|
|
||||||
| override SensitiveDataClassification getClassification() { result = classification } | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * A function call that might produce sensitive data. | ||||||
| */ | ||||||
| private class SensitiveDataCall extends SensitiveData { | ||||||
| SensitiveDataClassification classification; | ||||||
|
|
||||||
| SensitiveDataCall() { | ||||||
| exists(CallExpr call, string name | | ||||||
| call = this.asExpr() and | ||||||
| name = [call.getCallee().(Identifier).getValue(), call.getCallee().(MemberAccessExpr).getMemberName()] | ||||||
|
geoffw0 marked this conversation as resolved.
Dismissed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Looks like my previous suggestion was missing the trailing |
||||||
| HeuristicNames::nameIndicatesSensitiveData(name, classification) | ||||||
|
geoffw0 marked this conversation as resolved.
Dismissed
|
||||||
| ) | ||||||
| } | ||||||
|
|
||||||
| override SensitiveDataClassification getClassification() { result = classification } | ||||||
| } | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.