Skip to content

Commit

Permalink
feat: add secure test
Browse files Browse the repository at this point in the history
  • Loading branch information
elsapet committed Feb 9, 2024
1 parent fd578ed commit ce387e1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
11 changes: 10 additions & 1 deletion tests/java/lang/apache_commons_collection/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ const { ruleId, ruleFile, testBase } = getEnvironment(__dirname)
describe(ruleId, () => {
const invoke = createNewInvoker(ruleId, ruleFile, testBase)

test("apache_commons_collection", () => {
test("apache_commons_collection_secure", () => {
const testCase = "secure/"

const results = invoke(testCase)

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

test("apache_commons_collection_insecure", () => {
const testCase = "insecure/"

const results = invoke(testCase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class Foo {
public static void bad(String[] args) throws Exception {
// bearer:expected java_lang_apache_commons_collection
// ok - version 3.2.2 +
InvokerTransformer transformer = new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc.exe"});
Object result = transformer.transform(null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import org.apache.commons.collections3;

public class Foo {
public static void bad(String[] args) throws Exception {
// bearer:expected java_lang_apache_commons_collection
InvokerTransformer transformer = new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc.exe"});
Object result = transformer.transform(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[{
"groupId": "org.apache.commons",
"artifactId": "commons-collections3",
"version": "3.2.2"
},
{
"groupId": "test1",
"artifactId": "testartifact1",
"version": "1.0.beta"
}]

0 comments on commit ce387e1

Please sign in to comment.