Skip to content

Commit

Permalink
Remove old-style models of built-in functions
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-mc committed May 7, 2024
1 parent 75c30d6 commit 79cdec8
Showing 1 changed file with 0 additions and 52 deletions.
52 changes: 0 additions & 52 deletions go/ql/lib/semmle/go/frameworks/Stdlib.qll
Original file line number Diff line number Diff line change
Expand Up @@ -44,58 +44,6 @@ import semmle.go.frameworks.stdlib.TextTabwriter
import semmle.go.frameworks.stdlib.TextTemplate
import semmle.go.frameworks.stdlib.Unsafe

// These are modeled using TaintTracking::FunctionModel because they doesn't have real type signatures,
// and therefore currently have an InvalidType, not a SignatureType, which breaks Models as Data.
/**
* A model of the built-in `append` function, which propagates taint from its arguments to its
* result.
*/
private class AppendFunction extends TaintTracking::FunctionModel {
AppendFunction() { this = Builtin::append() }

override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
inp.isParameter(_) and outp.isResult()
}
}

/**
* A model of the built-in `copy` function, which propagates taint from its second argument
* to its first.
*/
private class CopyFunction extends TaintTracking::FunctionModel {
CopyFunction() { this = Builtin::copy() }

override predicate hasTaintFlow(FunctionInput inp, FunctionOutput outp) {
inp.isParameter(1) and outp.isParameter(0)
}
}

/**
* A model of the built-in `min` function, which computes the smallest value of a fixed number of
* arguments of ordered types. There is at least one argument and "ordered types" includes e.g.
* strings, so we care about data flow through `min`.
*/
private class MinFunction extends DataFlow::FunctionModel {
MinFunction() { this = Builtin::min_() }

override predicate hasDataFlow(FunctionInput inp, FunctionOutput outp) {
inp.isParameter(_) and outp.isResult()
}
}

/**
* A model of the built-in `max` function, which computes the largest value of a fixed number of
* arguments of ordered types. There is at least one argument and "ordered types" includes e.g.
* strings, so we care about data flow through `max`.
*/
private class MaxFunction extends DataFlow::FunctionModel {
MaxFunction() { this = Builtin::max_() }

override predicate hasDataFlow(FunctionInput inp, FunctionOutput outp) {
inp.isParameter(_) and outp.isResult()
}
}

/** Provides a class for modeling functions which convert strings into integers. */
module IntegerParser {
/**
Expand Down

0 comments on commit 79cdec8

Please sign in to comment.