mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
Add taint-tracking for container/heap package
This commit is contained in:
@@ -12,6 +12,7 @@ import semmle.go.frameworks.stdlib.CompressFlate
|
||||
import semmle.go.frameworks.stdlib.CompressGzip
|
||||
import semmle.go.frameworks.stdlib.CompressLzw
|
||||
import semmle.go.frameworks.stdlib.CompressZlib
|
||||
import semmle.go.frameworks.stdlib.ContainerHeap
|
||||
import semmle.go.frameworks.stdlib.Mime
|
||||
import semmle.go.frameworks.stdlib.MimeMultipart
|
||||
import semmle.go.frameworks.stdlib.MimeQuotedprintable
|
||||
|
||||
50
ql/src/semmle/go/frameworks/stdlib/ContainerHeap.qll
Normal file
50
ql/src/semmle/go/frameworks/stdlib/ContainerHeap.qll
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Provides classes modeling security-relevant aspects of the `container/heap` package.
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
/** Provides models of commonly used functions in the `container/heap` package. */
|
||||
module ContainerHeap {
|
||||
private class FunctionModels extends TaintTracking::FunctionModel {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
FunctionModels() {
|
||||
// signature: func Pop(h Interface) interface{}
|
||||
hasQualifiedName("container/heap", "Pop") and
|
||||
(inp.isParameter(0) and outp.isResult())
|
||||
or
|
||||
// signature: func Push(h Interface, x interface{})
|
||||
hasQualifiedName("container/heap", "Push") and
|
||||
(inp.isParameter(1) and outp.isParameter(0))
|
||||
or
|
||||
// signature: func Remove(h Interface, i int) interface{}
|
||||
hasQualifiedName("container/heap", "Remove") and
|
||||
(inp.isParameter(0) and outp.isResult())
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
|
||||
private class MethodModels extends TaintTracking::FunctionModel, Method {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
MethodModels() {
|
||||
// signature: func (Interface).Pop() interface{}
|
||||
this.implements("container/heap", "Interface", "Pop") and
|
||||
(inp.isReceiver() and outp.isResult())
|
||||
or
|
||||
// signature: func (Interface).Push(x interface{})
|
||||
this.implements("container/heap", "Interface", "Push") and
|
||||
(inp.isParameter(0) and outp.isReceiver())
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// Code generated by https://github.com/gagliardetto/codebox. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import "container/heap"
|
||||
|
||||
func TaintStepTest_ContainerHeapPop_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromInterface656 := sourceCQL.(heap.Interface)
|
||||
intoInterface414 := heap.Pop(fromInterface656)
|
||||
return intoInterface414
|
||||
}
|
||||
|
||||
func TaintStepTest_ContainerHeapPush_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromInterface518 := sourceCQL.(interface{})
|
||||
var intoInterface650 heap.Interface
|
||||
heap.Push(intoInterface650, fromInterface518)
|
||||
return intoInterface650
|
||||
}
|
||||
|
||||
func TaintStepTest_ContainerHeapRemove_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromInterface784 := sourceCQL.(heap.Interface)
|
||||
intoInterface957 := heap.Remove(fromInterface784, 0)
|
||||
return intoInterface957
|
||||
}
|
||||
|
||||
func TaintStepTest_ContainerHeapInterfacePop_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromInterface520 := sourceCQL.(heap.Interface)
|
||||
intoInterface443 := fromInterface520.Pop()
|
||||
return intoInterface443
|
||||
}
|
||||
|
||||
func TaintStepTest_ContainerHeapInterfacePush_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromInterface127 := sourceCQL.(interface{})
|
||||
var intoInterface483 heap.Interface
|
||||
intoInterface483.Push(fromInterface127)
|
||||
return intoInterface483
|
||||
}
|
||||
|
||||
func RunAllTaints_ContainerHeap() {
|
||||
{
|
||||
source := newSource(0)
|
||||
out := TaintStepTest_ContainerHeapPop_B0I0O0(source)
|
||||
sink(0, out)
|
||||
}
|
||||
{
|
||||
source := newSource(1)
|
||||
out := TaintStepTest_ContainerHeapPush_B0I0O0(source)
|
||||
sink(1, out)
|
||||
}
|
||||
{
|
||||
source := newSource(2)
|
||||
out := TaintStepTest_ContainerHeapRemove_B0I0O0(source)
|
||||
sink(2, out)
|
||||
}
|
||||
{
|
||||
source := newSource(3)
|
||||
out := TaintStepTest_ContainerHeapInterfacePop_B0I0O0(source)
|
||||
sink(3, out)
|
||||
}
|
||||
{
|
||||
source := newSource(4)
|
||||
out := TaintStepTest_ContainerHeapInterfacePush_B0I0O0(source)
|
||||
sink(4, out)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user