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

Go: extract explicit alias types #18283

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cf1affc
Go: Update dbscheme for aliases
mbg Aug 16, 2024
f602ba3
Go: Extract type aliases
mbg Aug 16, 2024
7abf9e6
Go: Extract alias names
mbg Aug 16, 2024
17c279b
Go: Fix formatting and documentation of `AliasType`
mbg Aug 16, 2024
14df781
Go: Update `AliasType` to implement `getUnderlyingType`
mbg Aug 19, 2024
81501bd
Go: Extract objects for aliases
mbg Aug 19, 2024
5502e13
Factor out `extractTypeObject`
owen-mc Aug 21, 2024
a0aaba1
Fix alias use in HTML template escaping passthrough
owen-mc Aug 20, 2024
1d39188
Use unique type param names in test
owen-mc Aug 20, 2024
d50a5c8
Fix syntax error in test
owen-mc Aug 21, 2024
56f2228
Improve `AliasType.getUnderlyingType`
owen-mc Aug 21, 2024
807be11
Update labels for alias types
owen-mc Aug 22, 2024
979da03
Add change note
owen-mc Aug 22, 2024
9233a02
Look through aliases in hasOwnField
smowton Aug 26, 2024
d68e176
Implement deep unaliasing, and use it in interface dispatch resolution
smowton Aug 26, 2024
4841200
Transparent aliases: don't look through named types
smowton Aug 28, 2024
cd47680
Transparent aliases: don't write an invalid type to the @types table …
smowton Aug 28, 2024
cf54064
Distinguish types with and without explicit aliases in the type-label…
smowton Aug 28, 2024
eaf65d9
Fix Mongodb additional taint step
smowton Aug 29, 2024
6adde0a
Don't repeat parts of extractType that populate tracking tables
smowton Aug 29, 2024
d23d36d
Fix flow through pointer types related by aliasing
smowton Aug 29, 2024
3ec68f6
Fix missed case
smowton Aug 29, 2024
0a5f217
Improve efficiency of composite-type deep-unalias computation
smowton Aug 30, 2024
f2b3c2f
Make deep-unalias computation even more efficient using unpack routines
smowton Aug 30, 2024
b455091
Only extract transparent-alias versions of types when necessary
smowton Aug 31, 2024
2a6ebca
Fix struct deepUnaliasedType predicate
smowton Sep 1, 2024
546d661
Implement deep-unalias for interface types
smowton Sep 1, 2024
635dd68
Fix TupleType's getDeepUnaliasedType, and make it efficient
smowton Sep 1, 2024
b7a4c85
autoformat and tidy an unnecessary direct db relation use
smowton Sep 1, 2024
f39b9db
Interface unaliasing: don't confuse the empty interface with the type…
smowton Sep 1, 2024
2b6786a
Ensure fields are created for de-aliased struct types
smowton Sep 2, 2024
d3355e3
autoformat
smowton Sep 2, 2024
3406e02
Interface types: distinguish otherwise-identical interfaces with non-…
owen-mc Dec 11, 2024
a4b500c
Upgrade/downgrade scripts
owen-mc Dec 11, 2024
305353e
Accept test changes
owen-mc Dec 13, 2024
3c44685
Test changes to be investigated
owen-mc Dec 13, 2024
187b5ee
Make four predicates private
owen-mc Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix alias use in HTML template escaping passthrough
owen-mc committed Dec 10, 2024
commit a0aaba1db3c259197b6d96585da5b28c05e3eeda
11 changes: 11 additions & 0 deletions go/ql/lib/semmle/go/Types.qll
Original file line number Diff line number Diff line change
@@ -1066,6 +1066,17 @@ class AliasType extends @typealias, CompositeType {
override Type getUnderlyingType() { result = this.getRhs().getUnderlyingType() }
}

/**
* Gets the non-alias type at the end of the alias chain starting at `t`.
*
* If `t` is not an alias type then `result` is `t`.
*/
Type unalias(Type t) {
not t instanceof AliasType and result = t
or
result = unalias(t.(AliasType).getRhs())
}

/**
* A type that implements the builtin interface `error`.
*/
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ module UntrustedToPassthroughTypeConversionConfig implements DataFlow::ConfigSig
additional predicate isSinkToPassthroughType(DataFlow::TypeCastNode sink, PassthroughTypeName name) {
exists(Type typ |
typ = sink.getResultType() and
typ.getUnderlyingType*().hasQualifiedName("html/template", name)
unalias(typ).hasQualifiedName("html/template", name)
)
}

@@ -80,7 +80,7 @@ module PassthroughTypeConversionToTemplateExecutionCallConfig implements DataFlo
) {
exists(Type typ |
typ = source.getResultType() and
typ.getUnderlyingType*().hasQualifiedName("html/template", name)
unalias(typ).hasQualifiedName("html/template", name)
)
}