Files
codeql/go/ql/test/experimental/frameworks/CleverGo/HeaderWrite.ql
Rasmus Wriedt Larsen 0b486ade9b Go: Autoformat
2022-06-02 15:12:13 +02:00

59 lines
2.0 KiB
Plaintext

import go
import TestUtilities.InlineExpectationsTest
import experimental.frameworks.CleverGo
class HttpHeaderWriteTest extends InlineExpectationsTest {
HttpHeaderWriteTest() { this = "HttpHeaderWriteTest" }
override string getARelevantTag() {
result = ["headerKeyNode", "headerValNode", "headerKey", "headerVal"]
}
override predicate hasActualResult(Location location, string element, string tag, string value) {
// Dynamic key-value header:
exists(HTTP::HeaderWrite hw |
hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
(
element = hw.getName().toString() and
value = hw.getName().toString() and
tag = "headerKeyNode"
or
element = hw.getValue().toString() and
value = hw.getValue().toString() and
tag = "headerValNode"
)
)
or
// Static key, dynamic value header:
exists(HTTP::HeaderWrite hw |
hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
(
element = hw.getHeaderName().toString() and
value = hw.getHeaderName() and
tag = "headerKey"
or
element = hw.getValue().toString() and
value = hw.getValue().toString() and
tag = "headerValNode"
)
)
or
// Static key, static value header:
exists(HTTP::HeaderWrite hw |
hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
(
element = hw.getHeaderName().toString() and
value = hw.getHeaderName() and
tag = "headerKey"
or
element = hw.getHeaderValue().toString() and
value = hw.getHeaderValue() and
tag = "headerVal"
)
)
}
}