Add compress/lzw taint tracking

This commit is contained in:
Slavomir
2020-08-05 18:34:05 +02:00
parent 053496dbcc
commit 441d29b2b7
3 changed files with 63 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import semmle.go.frameworks.stdlib.Bytes
import semmle.go.frameworks.stdlib.CompressBzip2
import semmle.go.frameworks.stdlib.CompressFlate
import semmle.go.frameworks.stdlib.CompressGzip
import semmle.go.frameworks.stdlib.CompressLzw
/** A `String()` method. */
class StringMethod extends TaintTracking::FunctionModel, Method {

View File

@@ -0,0 +1,27 @@
/**
* Provides classes modeling security-relevant aspects of the `compress/lzw` package.
*/
import go
/** Provides models of commonly used functions in the `compress/lzw` package. */
module CompressLzw {
private class FunctionModels extends TaintTracking::FunctionModel {
FunctionInput inp;
FunctionOutput outp;
FunctionModels() {
// signature: func NewReader(r io.Reader, order Order, litWidth int) io.ReadCloser
hasQualifiedName("compress/lzw", "NewReader") and
(inp.isParameter(0) and outp.isResult())
or
// signature: func NewWriter(w io.Writer, order Order, litWidth int) io.WriteCloser
hasQualifiedName("compress/lzw", "NewWriter") and
(inp.isResult() and outp.isParameter(0))
}
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
input = inp and output = outp
}
}
}

View File

@@ -0,0 +1,35 @@
// Code generated by https://github.com/gagliardetto/codebox. DO NOT EDIT.
package main
import (
"compress/lzw"
"io"
)
func TaintStepTest_CompressLzwNewReader_B0I0O0(sourceCQL interface{}) interface{} {
fromReader656 := sourceCQL.(io.Reader)
intoReadCloser414 := lzw.NewReader(fromReader656, 0, 0)
return intoReadCloser414
}
func TaintStepTest_CompressLzwNewWriter_B0I0O0(sourceCQL interface{}) interface{} {
fromWriteCloser518 := sourceCQL.(io.WriteCloser)
var intoWriter650 io.Writer
intermediateCQL := lzw.NewWriter(intoWriter650, 0, 0)
link(fromWriteCloser518, intermediateCQL)
return intoWriter650
}
func RunAllTaints_CompressLzw() {
{
source := newSource(0)
out := TaintStepTest_CompressLzwNewReader_B0I0O0(source)
sink(0, out)
}
{
source := newSource(1)
out := TaintStepTest_CompressLzwNewWriter_B0I0O0(source)
sink(1, out)
}
}