Skip to content

Commit b578c1d

Browse files
committed
Convert go/incorrect-integer-conversion tests to postprocessing query
1 parent c308978 commit b578c1d

10 files changed

+827
-168
lines changed

go/ql/test/query-tests/Security/CWE-681/IncorrectIntegerConversion.expected

+678-1
Large diffs are not rendered by default.

go/ql/test/query-tests/Security/CWE-681/IncorrectIntegerConversion.go

+131-131
Large diffs are not rendered by default.

go/ql/test/query-tests/Security/CWE-681/IncorrectIntegerConversion.ql

-20
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
query: Security/CWE-681/IncorrectIntegerConversionQuery.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

go/ql/test/query-tests/Security/CWE-681/Test32BitArchitectureBuildConstraintInFileName_386.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ func testIntSource386() {
1616
_ = uint32(parsed)
1717
}
1818
{
19-
parsed, err := strconv.ParseUint("3456", 10, 0)
19+
parsed, err := strconv.ParseUint("3456", 10, 0) // $ Source
2020
if err != nil {
2121
panic(err)
2222
}
23-
_ = int32(parsed) // $ hasValueFlow="parsed"
23+
_ = int32(parsed) // $ Alert Sink
2424
_ = uint32(parsed)
2525
}
2626
{

go/ql/test/query-tests/Security/CWE-681/Test32BitArchitectureBuildConstraints.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ func testIntSource32() {
1919
_ = uint32(parsed)
2020
}
2121
{
22-
parsed, err := strconv.ParseUint("3456", 10, 0)
22+
parsed, err := strconv.ParseUint("3456", 10, 0) // $ Source
2323
if err != nil {
2424
panic(err)
2525
}
26-
_ = int32(parsed) // $ hasValueFlow="parsed"
26+
_ = int32(parsed) // $ Alert Sink
2727
_ = uint32(parsed)
2828
}
2929
{

go/ql/test/query-tests/Security/CWE-681/Test64BitArchitectureBuildConstraintInFileName_amd64.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ func testIntSinkAmd64() {
1616
_ = uint(parsed)
1717
}
1818
{
19-
parsed, err := strconv.ParseUint("3456", 10, 64)
19+
parsed, err := strconv.ParseUint("3456", 10, 64) // $ Source
2020
if err != nil {
2121
panic(err)
2222
}
23-
_ = int(parsed) // $ hasValueFlow="parsed"
23+
_ = int(parsed) // $ Alert Sink
2424
_ = uint(parsed)
2525
}
2626
}

go/ql/test/query-tests/Security/CWE-681/Test64BitArchitectureBuildConstraints.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ func testIntSink64() {
1919
_ = uint(parsed)
2020
}
2121
{
22-
parsed, err := strconv.ParseUint("3456", 10, 64)
22+
parsed, err := strconv.ParseUint("3456", 10, 64) // $ Source
2323
if err != nil {
2424
panic(err)
2525
}
26-
_ = int(parsed) // $ hasValueFlow="parsed"
26+
_ = int(parsed) // $ Alert Sink
2727
_ = uint(parsed)
2828
}
2929
}

go/ql/test/query-tests/Security/CWE-681/TestNoArchitectureBuildConstraints.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ import (
99

1010
func testIntSizeIsArchicturallyDependent1() {
1111
{
12-
parsed, err := strconv.ParseInt("3456", 10, 0)
12+
parsed, err := strconv.ParseInt("3456", 10, 0) // $ Source
1313
if err != nil {
1414
panic(err)
1515
}
16-
_ = int32(parsed) // $ hasValueFlow="parsed"
17-
_ = uint32(parsed) // $ hasValueFlow="parsed"
16+
_ = int32(parsed) // $ Alert Sink
17+
_ = uint32(parsed) // $ Alert Sink
1818
}
1919
{
20-
parsed, err := strconv.ParseInt("3456", 10, 64)
20+
parsed, err := strconv.ParseInt("3456", 10, 64) // $ Source
2121
if err != nil {
2222
panic(err)
2323
}
24-
_ = int(parsed) // $ hasValueFlow="parsed"
25-
_ = uint(parsed) // $ hasValueFlow="parsed"
24+
_ = int(parsed) // $ Alert Sink
25+
_ = uint(parsed) // $ Alert Sink
2626
}
2727
}

go/ql/test/query-tests/Security/CWE-681/TestOldBuildConstraints.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ func oldTestIntSink64() {
2020
_ = uint(parsed)
2121
}
2222
{
23-
parsed, err := strconv.ParseUint("3456", 10, 64)
23+
parsed, err := strconv.ParseUint("3456", 10, 64) // $ Source
2424
if err != nil {
2525
panic(err)
2626
}
27-
_ = int(parsed) // $ hasValueFlow="parsed"
27+
_ = int(parsed) // $ Alert Sink
2828
_ = uint(parsed)
2929
}
3030
}

0 commit comments

Comments
 (0)