mirror of
https://github.com/github/codeql.git
synced 2026-01-30 14:52:57 +01:00
Add taint-tracking for mime 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.Mime
|
||||
import semmle.go.frameworks.stdlib.Path
|
||||
import semmle.go.frameworks.stdlib.PathFilepath
|
||||
|
||||
|
||||
50
ql/src/semmle/go/frameworks/stdlib/Mime.qll
Normal file
50
ql/src/semmle/go/frameworks/stdlib/Mime.qll
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Provides classes modeling security-relevant aspects of the `mime` package.
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
/** Provides models of commonly used functions in the `mime` package. */
|
||||
module Mime {
|
||||
private class FunctionModels extends TaintTracking::FunctionModel {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
FunctionModels() {
|
||||
// signature: func FormatMediaType(t string, param map[string]string) string
|
||||
hasQualifiedName("mime", "FormatMediaType") and
|
||||
(inp.isParameter(_) and outp.isResult())
|
||||
or
|
||||
// signature: func ParseMediaType(v string) (mediatype string, params map[string]string, err error)
|
||||
hasQualifiedName("mime", "ParseMediaType") and
|
||||
(inp.isParameter(0) and outp.isResult([0, 1]))
|
||||
}
|
||||
|
||||
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 (*WordDecoder).Decode(word string) (string, error)
|
||||
this.hasQualifiedName("mime", "WordDecoder", "Decode") and
|
||||
(inp.isParameter(0) and outp.isResult(0))
|
||||
or
|
||||
// signature: func (*WordDecoder).DecodeHeader(header string) (string, error)
|
||||
this.hasQualifiedName("mime", "WordDecoder", "DecodeHeader") and
|
||||
(inp.isParameter(0) and outp.isResult(0))
|
||||
or
|
||||
// signature: func (WordEncoder).Encode(charset string, s string) string
|
||||
this.hasQualifiedName("mime", "WordEncoder", "Encode") and
|
||||
(inp.isParameter(1) and outp.isResult())
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// Code generated by https://github.com/gagliardetto/codebox. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import "mime"
|
||||
|
||||
func TaintStepTest_MimeFormatMediaType_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromString656 := sourceCQL.(string)
|
||||
intoString414 := mime.FormatMediaType(fromString656, nil)
|
||||
return intoString414
|
||||
}
|
||||
|
||||
func TaintStepTest_MimeFormatMediaType_B0I1O0(sourceCQL interface{}) interface{} {
|
||||
fromMapstringstring518 := sourceCQL.(map[string]string)
|
||||
intoString650 := mime.FormatMediaType("", fromMapstringstring518)
|
||||
return intoString650
|
||||
}
|
||||
|
||||
func TaintStepTest_MimeParseMediaType_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromString784 := sourceCQL.(string)
|
||||
intoString957, _, _ := mime.ParseMediaType(fromString784)
|
||||
return intoString957
|
||||
}
|
||||
|
||||
func TaintStepTest_MimeParseMediaType_B0I0O1(sourceCQL interface{}) interface{} {
|
||||
fromString520 := sourceCQL.(string)
|
||||
_, intoMapstringstring443, _ := mime.ParseMediaType(fromString520)
|
||||
return intoMapstringstring443
|
||||
}
|
||||
|
||||
func TaintStepTest_MimeWordDecoderDecode_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromString127 := sourceCQL.(string)
|
||||
var mediumObjCQL mime.WordDecoder
|
||||
intoString483, _ := mediumObjCQL.Decode(fromString127)
|
||||
return intoString483
|
||||
}
|
||||
|
||||
func TaintStepTest_MimeWordDecoderDecodeHeader_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromString989 := sourceCQL.(string)
|
||||
var mediumObjCQL mime.WordDecoder
|
||||
intoString982, _ := mediumObjCQL.DecodeHeader(fromString989)
|
||||
return intoString982
|
||||
}
|
||||
|
||||
func TaintStepTest_MimeWordEncoderEncode_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromString417 := sourceCQL.(string)
|
||||
var mediumObjCQL mime.WordEncoder
|
||||
intoString584 := mediumObjCQL.Encode("", fromString417)
|
||||
return intoString584
|
||||
}
|
||||
|
||||
func RunAllTaints_Mime() {
|
||||
{
|
||||
source := newSource(0)
|
||||
out := TaintStepTest_MimeFormatMediaType_B0I0O0(source)
|
||||
sink(0, out)
|
||||
}
|
||||
{
|
||||
source := newSource(1)
|
||||
out := TaintStepTest_MimeFormatMediaType_B0I1O0(source)
|
||||
sink(1, out)
|
||||
}
|
||||
{
|
||||
source := newSource(2)
|
||||
out := TaintStepTest_MimeParseMediaType_B0I0O0(source)
|
||||
sink(2, out)
|
||||
}
|
||||
{
|
||||
source := newSource(3)
|
||||
out := TaintStepTest_MimeParseMediaType_B0I0O1(source)
|
||||
sink(3, out)
|
||||
}
|
||||
{
|
||||
source := newSource(4)
|
||||
out := TaintStepTest_MimeWordDecoderDecode_B0I0O0(source)
|
||||
sink(4, out)
|
||||
}
|
||||
{
|
||||
source := newSource(5)
|
||||
out := TaintStepTest_MimeWordDecoderDecodeHeader_B0I0O0(source)
|
||||
sink(5, out)
|
||||
}
|
||||
{
|
||||
source := newSource(6)
|
||||
out := TaintStepTest_MimeWordEncoderEncode_B0I0O0(source)
|
||||
sink(6, out)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user