mirror of
https://github.com/github/codeql.git
synced 2026-01-29 14:23:03 +01:00
Merge branch 'standard-lib-pt-6' into stdlib-339-340-342-346-347
This commit is contained in:
@@ -16,6 +16,11 @@ import semmle.go.frameworks.stdlib.Fmt
|
||||
import semmle.go.frameworks.stdlib.ContainerHeap
|
||||
import semmle.go.frameworks.stdlib.ContainerList
|
||||
import semmle.go.frameworks.stdlib.ContainerRing
|
||||
import semmle.go.frameworks.stdlib.Crypto
|
||||
import semmle.go.frameworks.stdlib.CryptoCipher
|
||||
import semmle.go.frameworks.stdlib.CryptoRsa
|
||||
import semmle.go.frameworks.stdlib.CryptoTls
|
||||
import semmle.go.frameworks.stdlib.CryptoX509
|
||||
import semmle.go.frameworks.stdlib.Mime
|
||||
import semmle.go.frameworks.stdlib.MimeMultipart
|
||||
import semmle.go.frameworks.stdlib.MimeQuotedprintable
|
||||
@@ -239,15 +244,3 @@ module URL {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Provides models of some functions in the `crypto/cipher` package. */
|
||||
module CryptoCipher {
|
||||
private class AeadOpenFunction extends TaintTracking::FunctionModel, Method {
|
||||
AeadOpenFunction() { this.hasQualifiedName("crypto/cipher", "AEAD", "Open") }
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
|
||||
inp.isParameter(2) and
|
||||
outp.isResult(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
ql/src/semmle/go/frameworks/stdlib/Crypto.qll
Normal file
23
ql/src/semmle/go/frameworks/stdlib/Crypto.qll
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Provides classes modeling security-relevant aspects of the `crypto` package.
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
/** Provides models of commonly used functions in the `crypto` package. */
|
||||
module Crypto {
|
||||
private class MethodModels extends TaintTracking::FunctionModel, Method {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
MethodModels() {
|
||||
// signature: func (Decrypter).Decrypt(rand io.Reader, msg []byte, opts DecrypterOpts) (plaintext []byte, err error)
|
||||
this.implements("crypto", "Decrypter", "Decrypt") and
|
||||
(inp.isParameter(1) and outp.isResult(0))
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
}
|
||||
30
ql/src/semmle/go/frameworks/stdlib/CryptoCipher.qll
Normal file
30
ql/src/semmle/go/frameworks/stdlib/CryptoCipher.qll
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Provides classes modeling security-relevant aspects of the `crypto/cipher` package.
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
/** Provides models of commonly used functions in the `crypto/cipher` package. */
|
||||
module CryptoCipher {
|
||||
private class MethodModels extends TaintTracking::FunctionModel, Method {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
MethodModels() {
|
||||
// signature: func (Block).Decrypt(dst []byte, src []byte)
|
||||
this.implements("crypto/cipher", "Block", "Decrypt") and
|
||||
(inp.isParameter(1) and outp.isParameter(0))
|
||||
or
|
||||
// signature: func (AEAD).Open(dst []byte, nonce []byte, ciphertext []byte, additionalData []byte) ([]byte, error)
|
||||
this.implements("crypto/cipher", "AEAD", "Open") and
|
||||
(
|
||||
inp.isParameter(2) and
|
||||
(outp.isParameter(0) or outp.isResult(0))
|
||||
)
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
}
|
||||
42
ql/src/semmle/go/frameworks/stdlib/CryptoRsa.qll
Normal file
42
ql/src/semmle/go/frameworks/stdlib/CryptoRsa.qll
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Provides classes modeling security-relevant aspects of the `crypto/rsa` package.
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
/** Provides models of commonly used functions in the `crypto/rsa` package. */
|
||||
module CryptoRsa {
|
||||
private class FunctionModels extends TaintTracking::FunctionModel {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
FunctionModels() {
|
||||
// signature: func DecryptOAEP(hash hash.Hash, random io.Reader, priv *PrivateKey, ciphertext []byte, label []byte) ([]byte, error)
|
||||
hasQualifiedName("crypto/rsa", "DecryptOAEP") and
|
||||
(inp.isParameter(3) and outp.isResult(0))
|
||||
or
|
||||
// signature: func DecryptPKCS1v15(rand io.Reader, priv *PrivateKey, ciphertext []byte) ([]byte, error)
|
||||
hasQualifiedName("crypto/rsa", "DecryptPKCS1v15") and
|
||||
(inp.isParameter(2) and outp.isResult(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 (*PrivateKey).Decrypt(rand io.Reader, ciphertext []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error)
|
||||
this.hasQualifiedName("crypto/rsa", "PrivateKey", "Decrypt") and
|
||||
(inp.isParameter(1) and outp.isResult(0))
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
}
|
||||
39
ql/src/semmle/go/frameworks/stdlib/CryptoTls.qll
Normal file
39
ql/src/semmle/go/frameworks/stdlib/CryptoTls.qll
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Provides classes modeling security-relevant aspects of the `crypto/tls` package.
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
/** Provides models of commonly used functions in the `crypto/tls` package. */
|
||||
module CryptoTls {
|
||||
private class FunctionModels extends TaintTracking::FunctionModel {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
FunctionModels() {
|
||||
// signature: func Client(conn net.Conn, config *Config) *Conn
|
||||
hasQualifiedName("crypto/tls", "Client") and
|
||||
(
|
||||
inp.isParameter(0) and outp.isResult()
|
||||
or
|
||||
inp.isResult() and outp.isParameter(0)
|
||||
)
|
||||
or
|
||||
// signature: func NewListener(inner net.Listener, config *Config) net.Listener
|
||||
hasQualifiedName("crypto/tls", "NewListener") and
|
||||
(inp.isParameter(0) and outp.isResult())
|
||||
or
|
||||
// signature: func Server(conn net.Conn, config *Config) *Conn
|
||||
hasQualifiedName("crypto/tls", "Server") and
|
||||
(
|
||||
inp.isParameter(0) and outp.isResult()
|
||||
or
|
||||
inp.isResult() and outp.isParameter(0)
|
||||
)
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
}
|
||||
23
ql/src/semmle/go/frameworks/stdlib/CryptoX509.qll
Normal file
23
ql/src/semmle/go/frameworks/stdlib/CryptoX509.qll
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Provides classes modeling security-relevant aspects of the `crypto/x509` package.
|
||||
*/
|
||||
|
||||
import go
|
||||
|
||||
/** Provides models of commonly used functions in the `crypto/x509` package. */
|
||||
module CryptoX509 {
|
||||
private class FunctionModels extends TaintTracking::FunctionModel {
|
||||
FunctionInput inp;
|
||||
FunctionOutput outp;
|
||||
|
||||
FunctionModels() {
|
||||
// signature: func DecryptPEMBlock(b *encoding/pem.Block, password []byte) ([]byte, error)
|
||||
hasQualifiedName("crypto/x509", "DecryptPEMBlock") and
|
||||
(inp.isParameter(0) and outp.isResult(0))
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
input = inp and output = outp
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Code generated by https://github.com/gagliardetto/codebox. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import "crypto"
|
||||
|
||||
func TaintStepTest_CryptoDecrypterDecrypt_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromByte656 := sourceCQL.([]byte)
|
||||
var mediumObjCQL crypto.Decrypter
|
||||
intoByte414, _ := mediumObjCQL.Decrypt(nil, fromByte656, nil)
|
||||
return intoByte414
|
||||
}
|
||||
|
||||
func RunAllTaints_Crypto() {
|
||||
{
|
||||
source := newSource(0)
|
||||
out := TaintStepTest_CryptoDecrypterDecrypt_B0I0O0(source)
|
||||
sink(0, out)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// Code generated by https://github.com/gagliardetto/codebox. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import "crypto/cipher"
|
||||
|
||||
func TaintStepTest_CryptoCipherStreamReaderRead_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromStreamReader656 := sourceCQL.(cipher.StreamReader)
|
||||
var intoByte414 []byte
|
||||
fromStreamReader656.Read(intoByte414)
|
||||
return intoByte414
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoCipherStreamWriterWrite_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromByte518 := sourceCQL.([]byte)
|
||||
var intoStreamWriter650 cipher.StreamWriter
|
||||
intoStreamWriter650.Write(fromByte518)
|
||||
return intoStreamWriter650
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoCipherBlockDecrypt_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromByte784 := sourceCQL.([]byte)
|
||||
var intoByte957 []byte
|
||||
var mediumObjCQL cipher.Block
|
||||
mediumObjCQL.Decrypt(intoByte957, fromByte784)
|
||||
return intoByte957
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoCipherAEADOpen_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromByte520 := sourceCQL.([]byte)
|
||||
var intoByte443 []byte
|
||||
var mediumObjCQL cipher.AEAD
|
||||
mediumObjCQL.Open(intoByte443, nil, fromByte520, nil)
|
||||
return intoByte443
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoCipherAEADOpen_B0I0O1(sourceCQL interface{}) interface{} {
|
||||
fromByte127 := sourceCQL.([]byte)
|
||||
var mediumObjCQL cipher.AEAD
|
||||
intoByte483, _ := mediumObjCQL.Open(nil, nil, fromByte127, nil)
|
||||
return intoByte483
|
||||
}
|
||||
|
||||
func RunAllTaints_CryptoCipher() {
|
||||
{
|
||||
source := newSource(0)
|
||||
out := TaintStepTest_CryptoCipherStreamReaderRead_B0I0O0(source)
|
||||
sink(0, out)
|
||||
}
|
||||
{
|
||||
source := newSource(1)
|
||||
out := TaintStepTest_CryptoCipherStreamWriterWrite_B0I0O0(source)
|
||||
sink(1, out)
|
||||
}
|
||||
{
|
||||
source := newSource(2)
|
||||
out := TaintStepTest_CryptoCipherBlockDecrypt_B0I0O0(source)
|
||||
sink(2, out)
|
||||
}
|
||||
{
|
||||
source := newSource(3)
|
||||
out := TaintStepTest_CryptoCipherAEADOpen_B0I0O0(source)
|
||||
sink(3, out)
|
||||
}
|
||||
{
|
||||
source := newSource(4)
|
||||
out := TaintStepTest_CryptoCipherAEADOpen_B0I0O1(source)
|
||||
sink(4, out)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Code generated by https://github.com/gagliardetto/codebox. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import "crypto/rsa"
|
||||
|
||||
func TaintStepTest_CryptoRsaDecryptOAEP_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromByte656 := sourceCQL.([]byte)
|
||||
intoByte414, _ := rsa.DecryptOAEP(nil, nil, nil, fromByte656, nil)
|
||||
return intoByte414
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoRsaDecryptPKCS1V15_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromByte518 := sourceCQL.([]byte)
|
||||
intoByte650, _ := rsa.DecryptPKCS1v15(nil, nil, fromByte518)
|
||||
return intoByte650
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoRsaPrivateKeyDecrypt_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromByte784 := sourceCQL.([]byte)
|
||||
var mediumObjCQL rsa.PrivateKey
|
||||
intoByte957, _ := mediumObjCQL.Decrypt(nil, fromByte784, nil)
|
||||
return intoByte957
|
||||
}
|
||||
|
||||
func RunAllTaints_CryptoRsa() {
|
||||
{
|
||||
source := newSource(0)
|
||||
out := TaintStepTest_CryptoRsaDecryptOAEP_B0I0O0(source)
|
||||
sink(0, out)
|
||||
}
|
||||
{
|
||||
source := newSource(1)
|
||||
out := TaintStepTest_CryptoRsaDecryptPKCS1V15_B0I0O0(source)
|
||||
sink(1, out)
|
||||
}
|
||||
{
|
||||
source := newSource(2)
|
||||
out := TaintStepTest_CryptoRsaPrivateKeyDecrypt_B0I0O0(source)
|
||||
sink(2, out)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// Code generated by https://github.com/gagliardetto/codebox. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
)
|
||||
|
||||
func TaintStepTest_CryptoTlsClient_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromConn656 := sourceCQL.(net.Conn)
|
||||
intoConn414 := tls.Client(fromConn656, nil)
|
||||
return intoConn414
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoTlsClient_B1I0O0(sourceCQL interface{}) interface{} {
|
||||
fromConn518 := sourceCQL.(*tls.Conn)
|
||||
var intoConn650 net.Conn
|
||||
intermediateCQL := tls.Client(intoConn650, nil)
|
||||
link(fromConn518, intermediateCQL)
|
||||
return intoConn650
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoTlsNewListener_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromListener784 := sourceCQL.(net.Listener)
|
||||
intoListener957 := tls.NewListener(fromListener784, nil)
|
||||
return intoListener957
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoTlsServer_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromConn520 := sourceCQL.(net.Conn)
|
||||
intoConn443 := tls.Server(fromConn520, nil)
|
||||
return intoConn443
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoTlsServer_B1I0O0(sourceCQL interface{}) interface{} {
|
||||
fromConn127 := sourceCQL.(*tls.Conn)
|
||||
var intoConn483 net.Conn
|
||||
intermediateCQL := tls.Server(intoConn483, nil)
|
||||
link(fromConn127, intermediateCQL)
|
||||
return intoConn483
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoTlsConnRead_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromConn989 := sourceCQL.(tls.Conn)
|
||||
var intoByte982 []byte
|
||||
fromConn989.Read(intoByte982)
|
||||
return intoByte982
|
||||
}
|
||||
|
||||
func TaintStepTest_CryptoTlsConnWrite_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromByte417 := sourceCQL.([]byte)
|
||||
var intoConn584 tls.Conn
|
||||
intoConn584.Write(fromByte417)
|
||||
return intoConn584
|
||||
}
|
||||
|
||||
func RunAllTaints_CryptoTls() {
|
||||
{
|
||||
source := newSource(0)
|
||||
out := TaintStepTest_CryptoTlsClient_B0I0O0(source)
|
||||
sink(0, out)
|
||||
}
|
||||
{
|
||||
source := newSource(1)
|
||||
out := TaintStepTest_CryptoTlsClient_B1I0O0(source)
|
||||
sink(1, out)
|
||||
}
|
||||
{
|
||||
source := newSource(2)
|
||||
out := TaintStepTest_CryptoTlsNewListener_B0I0O0(source)
|
||||
sink(2, out)
|
||||
}
|
||||
{
|
||||
source := newSource(3)
|
||||
out := TaintStepTest_CryptoTlsServer_B0I0O0(source)
|
||||
sink(3, out)
|
||||
}
|
||||
{
|
||||
source := newSource(4)
|
||||
out := TaintStepTest_CryptoTlsServer_B1I0O0(source)
|
||||
sink(4, out)
|
||||
}
|
||||
{
|
||||
source := newSource(5)
|
||||
out := TaintStepTest_CryptoTlsConnRead_B0I0O0(source)
|
||||
sink(5, out)
|
||||
}
|
||||
{
|
||||
source := newSource(6)
|
||||
out := TaintStepTest_CryptoTlsConnWrite_B0I0O0(source)
|
||||
sink(6, out)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Code generated by https://github.com/gagliardetto/codebox. DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
)
|
||||
|
||||
func TaintStepTest_CryptoX509DecryptPEMBlock_B0I0O0(sourceCQL interface{}) interface{} {
|
||||
fromBlock656 := sourceCQL.(*pem.Block)
|
||||
intoByte414, _ := x509.DecryptPEMBlock(fromBlock656, nil)
|
||||
return intoByte414
|
||||
}
|
||||
|
||||
func RunAllTaints_CryptoX509() {
|
||||
{
|
||||
source := newSource(0)
|
||||
out := TaintStepTest_CryptoX509DecryptPEMBlock_B0I0O0(source)
|
||||
sink(0, out)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user