Skip to content

Commit

Permalink
ci(java): migrate to annotations (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
gotbadger authored Feb 22, 2024
1 parent 0fb2db6 commit c272c2d
Show file tree
Hide file tree
Showing 75 changed files with 598 additions and 2,560 deletions.

This file was deleted.

47 changes: 29 additions & 18 deletions tests/java/lang/cookie_missing_http_only/test.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
const { createInvoker, createNewInvoker, 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.java"
expect(invoke(testCase)).toMatchSnapshot();
})

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

const results = invoke(testCase)

test("ok", () => {
const testCase = "ok.java"
expect(invoke(testCase)).toMatchSnapshot();
})
expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})


// new invoker
const invokeV2 = createNewInvoker(ruleId, ruleFile, testBase)
test("main", () => {
const testCase = "main.java"

test("missing_http_only", () => {
const testCase = "main.java"
const results = invoke(testCase)

const results = invokeV2(testCase)
expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})


expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})
test("ok", () => {
const testCase = "ok.java"

const results = invoke(testCase)

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

})
1 change: 1 addition & 0 deletions tests/java/lang/cookie_missing_http_only/testdata/bad.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class Test
{
public void cookie() {
// bearer:expected java_lang_cookie_missing_http_only
Cookie cookie = new Cookie(COOKIE_NAME, cookieValue);
cookie.setPath("/WebGoat");
response.addCookie(cookie);
Expand Down
44 changes: 0 additions & 44 deletions tests/java/lang/cookie_missing_secure/__snapshots__/test.js.snap

This file was deleted.

46 changes: 28 additions & 18 deletions tests/java/lang/cookie_missing_secure/test.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
const { createInvoker, createNewInvoker, 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.java"

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

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


test("ok", () => {
const testCase = "ok.java"
expect(invoke(testCase)).toMatchSnapshot();
})
test("main", () => {
const testCase = "main.java"

// new invoker
const invokeV2 = createNewInvoker(ruleId, ruleFile, testBase)
const results = invoke(testCase)

test("missing_http_only", () => {
const testCase = "main.java"
expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})


const results = invokeV2(testCase)
test("ok", () => {
const testCase = "ok.java"

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})
const results = invoke(testCase)

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

})
1 change: 1 addition & 0 deletions tests/java/lang/cookie_missing_secure/testdata/bad.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class Test
{
public void cookie() {
// bearer:expected java_lang_cookie_missing_secure
Cookie cookie = new Cookie(COOKIE_NAME, cookieValue);
cookie.setPath("/WebGoat");
response.addCookie(cookie);
Expand Down
44 changes: 0 additions & 44 deletions tests/java/lang/file_permission_others/__snapshots__/test.js.snap

This file was deleted.

31 changes: 21 additions & 10 deletions tests/java/lang/file_permission_others/test.js
Original file line number Diff line number Diff line change
@@ -1,19 +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("ok", () => {
const testCase = "ok.java"

const results = invoke(testCase)

test("ok", () => {
const testCase = "ok.java"
expect(invoke(testCase)).toMatchSnapshot();
})
expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})


test("others", () => {
const testCase = "others.java"
expect(invoke(testCase)).toMatchSnapshot();
})
test("others", () => {
const testCase = "others.java"

const results = invoke(testCase)

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

})
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
public void addOtherPermission(final Path helm) throws IOException {
permissions = Files.getPosixFilePermissions(helm);
// bearer:expected java_lang_file_permission_others
permissions.add(PosixFilePermission.OTHER_WRITE);

Files.setPosixFilePermissions(helm, permissions);
Expand Down

This file was deleted.

Loading

0 comments on commit c272c2d

Please sign in to comment.