Skip to content

Commit

Permalink
ci(go): update to use annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
gotbadger committed Feb 22, 2024
1 parent ef46257 commit 64b38f2
Show file tree
Hide file tree
Showing 21 changed files with 188 additions and 677 deletions.
44 changes: 0 additions & 44 deletions tests/go/lang/information_leakage/__snapshots__/test.js.snap

This file was deleted.

36 changes: 25 additions & 11 deletions tests/go/lang/information_leakage/test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
const { createInvoker, getEnvironment } = require("../../../helper.js")
const {
createNewInvoker,
getEnvironment,
} = require("../../../helper.js")
const { ruleId, ruleFile, testBase } = getEnvironment(__dirname)

describe(ruleId, () => {
const invoke = createInvoker(ruleId, ruleFile, testBase)
const invoke = createNewInvoker(ruleId, ruleFile, testBase)

test("bad", () => {
const testCase = "bad.go"
expect(invoke(testCase)).toMatchSnapshot()
})

test("bad", () => {
const testCase = "bad.go"

test("ok", () => {
const testCase = "ok.go"
expect(invoke(testCase)).toMatchSnapshot()
})
})
const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})


test("ok", () => {
const testCase = "ok.go"

const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})

})
1 change: 1 addition & 0 deletions tests/go/lang/information_leakage/testdata/bad.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ func fetchUser(w http.ResponseWriter, r *http.Request) {
_, err := getUserFromDB(r.FormValue("username"))
if err != nil {
// Exposing detailed error to the client
# bearer:expected go_lang_information_leakage
http.Error(w, err.Error(), http.StatusInternalServerError)
}
// ...
Expand Down
136 changes: 0 additions & 136 deletions tests/go/lang/logger/__snapshots__/test.js.snap

This file was deleted.

36 changes: 25 additions & 11 deletions tests/go/lang/logger/test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
const { createInvoker, getEnvironment } = require("../../../helper.js")
const {
createNewInvoker,
getEnvironment,
} = require("../../../helper.js")
const { ruleId, ruleFile, testBase } = getEnvironment(__dirname)

describe(ruleId, () => {
const invoke = createInvoker(ruleId, ruleFile, testBase)
const invoke = createNewInvoker(ruleId, ruleFile, testBase)

test("bad", () => {
const testCase = "bad.go"
expect(invoke(testCase)).toMatchSnapshot()
})

test("bad", () => {
const testCase = "bad.go"

test("ok", () => {
const testCase = "ok.go"
expect(invoke(testCase)).toMatchSnapshot()
})
})
const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})


test("ok", () => {
const testCase = "ok.go"

const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})

})
3 changes: 3 additions & 0 deletions tests/go/lang/logger/testdata/bad.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ func main() {
name := user.Name
other, _ := user.FullName()

# bearer:expected go_lang_logger
log.Error().Msg(name) // expect detection
# bearer:expected go_lang_logger
log.Error().Msg(other) // expect detection
# bearer:expected go_lang_logger
log.Error().Msg(user) // expect detection
}
94 changes: 0 additions & 94 deletions tests/go/lang/weak_hash_md5/__snapshots__/test.js.snap

This file was deleted.

Loading

0 comments on commit 64b38f2

Please sign in to comment.