From ed2e5b0f9228ebce736e10e9d219bae243101e05 Mon Sep 17 00:00:00 2001 From: Slavomir Date: Wed, 9 Sep 2020 14:17:03 +0200 Subject: [PATCH] Extend `MarshalingFunction` and `UnmarshalingFunction` with `encoding/asn1` --- .../go/frameworks/stdlib/EncodingAsn1.qll | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ql/src/semmle/go/frameworks/stdlib/EncodingAsn1.qll b/ql/src/semmle/go/frameworks/stdlib/EncodingAsn1.qll index 9ae98c3d1b2..f0ae25d9fbe 100644 --- a/ql/src/semmle/go/frameworks/stdlib/EncodingAsn1.qll +++ b/ql/src/semmle/go/frameworks/stdlib/EncodingAsn1.qll @@ -6,6 +6,34 @@ import go /** Provides models of commonly used functions in the `encoding/asn1` package. */ module EncodingAsn1 { + /** The `Marshal` or `MarshalWithParams` function in the `encoding/asn1` package. */ + private class MarshalFunction extends MarshalingFunction::Range { + MarshalFunction() { + hasQualifiedName("encoding/asn1", "Marshal") or + hasQualifiedName("encoding/asn1", "MarshalWithParams") + } + + override FunctionInput getAnInput() { result.isParameter(0) } + + override FunctionOutput getOutput() { result.isResult(0) } + + override string getFormat() { result = "ASN1" } + } + + /** The `Unmarshal` or `UnmarshalWithParams` function in the `encoding/asn1` package. */ + private class UnmarshalFunction extends UnmarshalingFunction::Range { + UnmarshalFunction() { + hasQualifiedName("encoding/asn1", "Unmarshal") or + hasQualifiedName("encoding/asn1", "UnmarshalWithParams") + } + + override FunctionInput getAnInput() { result.isParameter(0) } + + override FunctionOutput getOutput() { result.isParameter(1) } + + override string getFormat() { result = "ASN1" } + } + private class FunctionModels extends TaintTracking::FunctionModel { FunctionInput inp; FunctionOutput outp;