mirror of
https://github.com/github/codeql.git
synced 2026-01-31 23:33:03 +01:00
Add compress/lzw taint tracking
This commit is contained in:
@@ -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 {
|
||||
|
||||
27
ql/src/semmle/go/frameworks/stdlib/CompressLzw.qll
Normal file
27
ql/src/semmle/go/frameworks/stdlib/CompressLzw.qll
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user