Files
codeql/go/ql/test/query-tests/Security/CWE-327/CryptoAlgorithm.ql
2025-11-19 14:36:26 +00:00

48 lines
1.4 KiB
Plaintext

import go
import ModelValidation
import utils.test.InlineExpectationsTest
module Test implements TestSig {
string getARelevantTag() { result = "CryptographicOperation" }
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "CryptographicOperation" and
exists(
CryptographicOperation::Range ho, string algorithm, string initialization, string blockMode
|
algorithm = ho.getAlgorithm().toString() + "." and
(
blockMode = " blockMode: " + ho.getBlockMode().toString() + "."
or
not exists(ho.getBlockMode()) and blockMode = ""
) and
exists(int c | c = count(ho.getInitialization()) |
c = 0 and initialization = ""
or
c = 1 and
initialization =
" init from line " +
strictconcat(DataFlow::Node init |
init = ho.getInitialization()
|
init.getStartLine().toString(), ","
) + "."
or
c > 1 and
initialization =
" init from lines " +
strictconcat(DataFlow::Node init |
init = ho.getInitialization()
|
init.getStartLine().toString(), ","
) + "."
) and
ho.getLocation() = location and
element = ho.toString() and
value = "\"" + algorithm + blockMode + initialization + "\""
)
}
}
import MakeTest<Test>