Files
opencode-power-pack/skills/variant-analysis/resources/codeql/go.ql
Wayner Barrios ab04919087 Add 10 more piolium security skills (MIT)
GitHub Actions prompt-injection audit, threat modeling, differential
review, variant analysis, SARIF parsing, Semgrep/CodeQL scanning and
rule authoring, and WooYun-derived web vuln methodology. Generalized
semgrep's piolium-specific subagent references. Skill count 45 -> 55.
2026-08-02 15:54:18 -04:00

70 lines
2.0 KiB
Plaintext

/**
* @name [VARIANT_NAME]
* @description Find variants of [ORIGINAL_BUG_ID]
* @kind path-problem
* @problem.severity error
* @tags security variant-analysis
*/
import go
import semmle.go.dataflow.TaintTracking
import DataFlow::PathGraph
module VariantConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
// HTTP request values
exists(DataFlow::CallNode c |
c.getTarget().hasQualifiedName("net/http", "Request", ["FormValue", "PostFormValue"]) and
source = c.getResult()
)
or
// URL query params
exists(DataFlow::CallNode c |
c.getTarget().hasQualifiedName("net/url", "Values", "Get") and
source = c.getResult()
)
or
// Gin framework
exists(DataFlow::CallNode c |
c.getTarget().hasQualifiedName("github.com/gin-gonic/gin", "Context", ["Query", "Param", "PostForm"]) and
source = c.getResult()
)
}
predicate isSink(DataFlow::Node sink) {
// Command injection
exists(DataFlow::CallNode c |
c.getTarget().hasQualifiedName("os/exec", "Command") and
sink = c.getArgument(0)
)
or
// SQL injection
exists(DataFlow::CallNode c |
c.getTarget().hasQualifiedName("database/sql", "DB", ["Query", "Exec", "QueryRow"]) and
sink = c.getArgument(0)
)
or
// Path traversal
exists(DataFlow::CallNode c |
c.getTarget().hasQualifiedName("os", ["Open", "OpenFile", "ReadFile"]) and
sink = c.getArgument(0)
)
}
predicate isBarrier(DataFlow::Node node) {
exists(DataFlow::CallNode c |
c.getTarget().getName() in ["Escape", "Quote", "Clean", "ParseInt", "Atoi"] and
node = c.getResult()
)
}
}
module VariantFlow = TaintTracking::Global<VariantConfig>;
import VariantFlow::PathGraph
from VariantFlow::PathNode source, VariantFlow::PathNode sink
where VariantFlow::flowPath(source, sink)
select sink.getNode(), source, sink,
"Tainted data from $@ flows to dangerous sink.",
source.getNode(), "user input"