mirror of
https://github.com/github/codeql.git
synced 2026-01-31 15:22:57 +01:00
Add taint-tracking for mime/quotedprintable package.
This commit is contained in:
@@ -14,6 +14,7 @@ import semmle.go.frameworks.stdlib.CompressLzw
|
||||
import semmle.go.frameworks.stdlib.CompressZlib
|
||||
import semmle.go.frameworks.stdlib.Mime
|
||||
import semmle.go.frameworks.stdlib.MimeMultipart
|
||||
import semmle.go.frameworks.stdlib.MimeQuotedprintable
|
||||
import semmle.go.frameworks.stdlib.Path
|
||||
import semmle.go.frameworks.stdlib.PathFilepath
|
||||
|
||||
|
||||
46
ql/src/semmle/go/frameworks/stdlib/MimeQuotedprintable.qll
Normal file
46
ql/src/semmle/go/frameworks/stdlib/MimeQuotedprintable.qll
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Provides classes modeling security-relevant aspects of the `mime/quotedprintable` package.
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
/** Provides models of commonly used functions in the `mime/quotedprintable` package. */
|
||||
module MimeQuotedprintable {
|
||||
private class FunctionModels extends TaintTracking::FunctionModel {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
FunctionModels() {
|
||||
// signature: func NewReader(r io.Reader) *Reader
|
||||
hasQualifiedName("mime/quotedprintable", "NewReader") and
|
||||
(inp.isParameter(0) and outp.isResult())
|
||||
or
|
||||
// signature: func NewWriter(w io.Writer) *Writer
|
||||
hasQualifiedName("mime/quotedprintable", "NewWriter") and
|
||||
(inp.isResult() and outp.isParameter(0))
|
||||
}
|
||||
|
||||
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 (*Reader).Read(p []byte) (n int, err error)
|
||||
this.hasQualifiedName("mime/quotedprintable", "Reader", "Read") and
|
||||
(inp.isReceiver() and outp.isParameter(0))
|
||||
or
|
||||
// signature: func (*Writer).Write(p []byte) (n int, err error)
|
||||
this.hasQualifiedName("mime/quotedprintable", "Writer", "Write") and
|
||||
(inp.isParameter(0) and outp.isReceiver())
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// Code generated by https://github.com/gagliardetto/codebox. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"mime/quotedprintable"
|
||||
)
|
||||
|
||||
func TaintStepTest_MimeQuotedprintableNewReader_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromReader656 := sourceCQL.(io.Reader)
|
||||
intoReader414 := quotedprintable.NewReader(fromReader656)
|
||||
return intoReader414
|
||||
}
|
||||
|
||||
func TaintStepTest_MimeQuotedprintableNewWriter_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromWriter518 := sourceCQL.(*quotedprintable.Writer)
|
||||
var intoWriter650 io.Writer
|
||||
intermediateCQL := quotedprintable.NewWriter(intoWriter650)
|
||||
link(fromWriter518, intermediateCQL)
|
||||
return intoWriter650
|
||||
}
|
||||
|
||||
func TaintStepTest_MimeQuotedprintableReaderRead_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromReader784 := sourceCQL.(quotedprintable.Reader)
|
||||
var intoByte957 []byte
|
||||
fromReader784.Read(intoByte957)
|
||||
return intoByte957
|
||||
}
|
||||
|
||||
func TaintStepTest_MimeQuotedprintableWriterWrite_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromByte520 := sourceCQL.([]byte)
|
||||
var intoWriter443 quotedprintable.Writer
|
||||
intoWriter443.Write(fromByte520)
|
||||
return intoWriter443
|
||||
}
|
||||
|
||||
func RunAllTaints_MimeQuotedprintable() {
|
||||
{
|
||||
source := newSource(0)
|
||||
out := TaintStepTest_MimeQuotedprintableNewReader_B0I0O0(source)
|
||||
sink(0, out)
|
||||
}
|
||||
{
|
||||
source := newSource(1)
|
||||
out := TaintStepTest_MimeQuotedprintableNewWriter_B0I0O0(source)
|
||||
sink(1, out)
|
||||
}
|
||||
{
|
||||
source := newSource(2)
|
||||
out := TaintStepTest_MimeQuotedprintableReaderRead_B0I0O0(source)
|
||||
sink(2, out)
|
||||
}
|
||||
{
|
||||
source := newSource(3)
|
||||
out := TaintStepTest_MimeQuotedprintableWriterWrite_B0I0O0(source)
|
||||
sink(3, out)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user