Skip to content

Commit

Permalink
rename dummy
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Sep 21, 2023
1 parent 7ef6644 commit fceefe9
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 191 deletions.
34 changes: 17 additions & 17 deletions xray/commands/audit/jas/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ func TestExcludeSuppressResults(t *testing.T) {
}{
{
sarifResults: []*sarif.Result{
utils.CreateDummyResultWithOneLocation("", 0, 0, 0, 0, "snippet1", "ruleId1", "level1"),
utils.CreateDummyResultWithOneLocation("", 0, 0, 0, 0, "snippet2", "ruleId2", "level2"),
utils.CreateResultWithOneLocation("", 0, 0, 0, 0, "snippet1", "ruleId1", "level1"),
utils.CreateResultWithOneLocation("", 0, 0, 0, 0, "snippet2", "ruleId2", "level2"),
},
expectedOutput: []*sarif.Result{
utils.CreateDummyResultWithOneLocation("", 0, 0, 0, 0, "snippet1", "ruleId1", "level1"),
utils.CreateDummyResultWithOneLocation("", 0, 0, 0, 0, "snippet2", "ruleId2", "level2"),
utils.CreateResultWithOneLocation("", 0, 0, 0, 0, "snippet1", "ruleId1", "level1"),
utils.CreateResultWithOneLocation("", 0, 0, 0, 0, "snippet2", "ruleId2", "level2"),
},
},
{
sarifResults: []*sarif.Result{
utils.CreateDummyResultWithOneLocation("", 0, 0, 0, 0, "snippet1", "ruleId1", "level1").WithSuppression([]*sarif.Suppression{sarif.NewSuppression("")}),
utils.CreateDummyResultWithOneLocation("", 0, 0, 0, 0, "snippet2", "ruleId2", "level2"),
utils.CreateResultWithOneLocation("", 0, 0, 0, 0, "snippet1", "ruleId1", "level1").WithSuppression([]*sarif.Suppression{sarif.NewSuppression("")}),
utils.CreateResultWithOneLocation("", 0, 0, 0, 0, "snippet2", "ruleId2", "level2"),
},
expectedOutput: []*sarif.Result{
utils.CreateDummyResultWithOneLocation("", 0, 0, 0, 0, "snippet2", "ruleId2", "level2"),
utils.CreateResultWithOneLocation("", 0, 0, 0, 0, "snippet2", "ruleId2", "level2"),
},
},
{
sarifResults: []*sarif.Result{
utils.CreateDummyResultWithOneLocation("", 0, 0, 0, 0, "snippet1", "ruleId1", "level1").WithSuppression([]*sarif.Suppression{sarif.NewSuppression("")}),
utils.CreateDummyResultWithOneLocation("", 0, 0, 0, 0, "snippet2", "ruleId2", "level2").WithSuppression([]*sarif.Suppression{sarif.NewSuppression("")}),
utils.CreateResultWithOneLocation("", 0, 0, 0, 0, "snippet1", "ruleId1", "level1").WithSuppression([]*sarif.Suppression{sarif.NewSuppression("")}),
utils.CreateResultWithOneLocation("", 0, 0, 0, 0, "snippet2", "ruleId2", "level2").WithSuppression([]*sarif.Suppression{sarif.NewSuppression("")}),
},
expectedOutput: []*sarif.Result{},
},
Expand All @@ -56,9 +56,9 @@ func TestAddScoreToRunRules(t *testing.T) {
}{
{
sarifRun: utils.CreateRunWithDummyResults(
utils.CreateDummyResultWithOneLocation("file1", 0, 0, 0, 0, "snippet", "rule1", "info"),
utils.CreateDummyResultWithOneLocation("file2", 0, 0, 0, 0, "snippet", "rule1", "info"),
utils.CreateDummyResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule2", "warning"),
utils.CreateResultWithOneLocation("file1", 0, 0, 0, 0, "snippet", "rule1", "info"),
utils.CreateResultWithOneLocation("file2", 0, 0, 0, 0, "snippet", "rule1", "info"),
utils.CreateResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule2", "warning"),
),
expectedOutput: []*sarif.ReportingDescriptor{
sarif.NewRule("rule1").WithProperties(sarif.Properties{"security-severity": "6.9"}),
Expand All @@ -67,11 +67,11 @@ func TestAddScoreToRunRules(t *testing.T) {
},
{
sarifRun: utils.CreateRunWithDummyResults(
utils.CreateDummyResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule1", "none"),
utils.CreateDummyResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule2", "note"),
utils.CreateDummyResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule3", "info"),
utils.CreateDummyResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule4", "warning"),
utils.CreateDummyResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule5", "error"),
utils.CreateResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule1", "none"),
utils.CreateResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule2", "note"),
utils.CreateResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule3", "info"),
utils.CreateResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule4", "warning"),
utils.CreateResultWithOneLocation("file", 0, 0, 0, 0, "snippet", "rule5", "error"),
),
expectedOutput: []*sarif.ReportingDescriptor{
sarif.NewRule("rule1").WithProperties(sarif.Properties{"security-severity": "0.0"}),
Expand Down
80 changes: 40 additions & 40 deletions xray/commands/audit/jas/sast/sastscanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,70 +81,70 @@ func TestGroupResultsByLocation(t *testing.T) {
{
// No similar groups at all
run: utils.CreateRunWithDummyResults(
utils.CreateDummyResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info"),
utils.CreateDummyResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "note"),
utils.CreateDummyResultWithOneLocation("file", 5, 6, 7, 8, "snippet", "rule1", "info"),
utils.CreateDummyResultWithOneLocation("file2", 1, 2, 3, 4, "snippet", "rule1", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateDummyCodeFlow(utils.CreateDummyThreadFlow(
utils.CreateDummyLocation("other", 0, 0, 0, 0, "other-snippet"),
utils.CreateDummyLocation("file2", 1, 2, 3, 4, "snippet"),
utils.CreateResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info"),
utils.CreateResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "note"),
utils.CreateResultWithOneLocation("file", 5, 6, 7, 8, "snippet", "rule1", "info"),
utils.CreateResultWithOneLocation("file2", 1, 2, 3, 4, "snippet", "rule1", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateCodeFlow(utils.CreateThreadFlow(
utils.CreateLocation("other", 0, 0, 0, 0, "other-snippet"),
utils.CreateLocation("file2", 1, 2, 3, 4, "snippet"),
)),
}),
utils.CreateDummyResultWithOneLocation("file2", 1, 2, 3, 4, "snippet", "rule2", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateDummyCodeFlow(utils.CreateDummyThreadFlow(
utils.CreateDummyLocation("other2", 1, 1, 1, 1, "other-snippet2"),
utils.CreateDummyLocation("file2", 1, 2, 3, 4, "snippet"),
utils.CreateResultWithOneLocation("file2", 1, 2, 3, 4, "snippet", "rule2", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateCodeFlow(utils.CreateThreadFlow(
utils.CreateLocation("other2", 1, 1, 1, 1, "other-snippet2"),
utils.CreateLocation("file2", 1, 2, 3, 4, "snippet"),
)),
}),
),
expectedOutput: utils.CreateRunWithDummyResults(
utils.CreateDummyResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info"),
utils.CreateDummyResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "note"),
utils.CreateDummyResultWithOneLocation("file", 5, 6, 7, 8, "snippet", "rule1", "info"),
utils.CreateDummyResultWithOneLocation("file2", 1, 2, 3, 4, "snippet", "rule1", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateDummyCodeFlow(utils.CreateDummyThreadFlow(
utils.CreateDummyLocation("other", 0, 0, 0, 0, "other-snippet"),
utils.CreateDummyLocation("file2", 1, 2, 3, 4, "snippet"),
utils.CreateResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info"),
utils.CreateResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "note"),
utils.CreateResultWithOneLocation("file", 5, 6, 7, 8, "snippet", "rule1", "info"),
utils.CreateResultWithOneLocation("file2", 1, 2, 3, 4, "snippet", "rule1", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateCodeFlow(utils.CreateThreadFlow(
utils.CreateLocation("other", 0, 0, 0, 0, "other-snippet"),
utils.CreateLocation("file2", 1, 2, 3, 4, "snippet"),
)),
}),
utils.CreateDummyResultWithOneLocation("file2", 1, 2, 3, 4, "snippet", "rule2", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateDummyCodeFlow(utils.CreateDummyThreadFlow(
utils.CreateDummyLocation("other2", 1, 1, 1, 1, "other-snippet2"),
utils.CreateDummyLocation("file2", 1, 2, 3, 4, "snippet"),
utils.CreateResultWithOneLocation("file2", 1, 2, 3, 4, "snippet", "rule2", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateCodeFlow(utils.CreateThreadFlow(
utils.CreateLocation("other2", 1, 1, 1, 1, "other-snippet2"),
utils.CreateLocation("file2", 1, 2, 3, 4, "snippet"),
)),
}),
),
},
{
// With similar groups
run: utils.CreateRunWithDummyResults(
utils.CreateDummyResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateDummyCodeFlow(utils.CreateDummyThreadFlow(
utils.CreateDummyLocation("other", 0, 0, 0, 0, "other-snippet"),
utils.CreateDummyLocation("file", 1, 2, 3, 4, "snippet"),
utils.CreateResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateCodeFlow(utils.CreateThreadFlow(
utils.CreateLocation("other", 0, 0, 0, 0, "other-snippet"),
utils.CreateLocation("file", 1, 2, 3, 4, "snippet"),
)),
}),
utils.CreateDummyResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateDummyCodeFlow(utils.CreateDummyThreadFlow(
utils.CreateDummyLocation("other2", 1, 1, 1, 1, "other-snippet"),
utils.CreateDummyLocation("file", 1, 2, 3, 4, "snippet"),
utils.CreateResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateCodeFlow(utils.CreateThreadFlow(
utils.CreateLocation("other2", 1, 1, 1, 1, "other-snippet"),
utils.CreateLocation("file", 1, 2, 3, 4, "snippet"),
)),
}),
utils.CreateDummyResultWithOneLocation("file", 5, 6, 7, 8, "snippet", "rule1", "info"),
utils.CreateDummyResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info"),
utils.CreateResultWithOneLocation("file", 5, 6, 7, 8, "snippet", "rule1", "info"),
utils.CreateResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info"),
),
expectedOutput: utils.CreateRunWithDummyResults(
utils.CreateDummyResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateDummyCodeFlow(utils.CreateDummyThreadFlow(
utils.CreateDummyLocation("other", 0, 0, 0, 0, "other-snippet"),
utils.CreateDummyLocation("file", 1, 2, 3, 4, "snippet"),
utils.CreateResultWithOneLocation("file", 1, 2, 3, 4, "snippet", "rule1", "info").WithCodeFlows([]*sarif.CodeFlow{
utils.CreateCodeFlow(utils.CreateThreadFlow(
utils.CreateLocation("other", 0, 0, 0, 0, "other-snippet"),
utils.CreateLocation("file", 1, 2, 3, 4, "snippet"),
)),
utils.CreateDummyCodeFlow(utils.CreateDummyThreadFlow(
utils.CreateDummyLocation("other2", 1, 1, 1, 1, "other-snippet"),
utils.CreateDummyLocation("file", 1, 2, 3, 4, "snippet"),
utils.CreateCodeFlow(utils.CreateThreadFlow(
utils.CreateLocation("other2", 1, 1, 1, 1, "other-snippet"),
utils.CreateLocation("file", 1, 2, 3, 4, "snippet"),
)),
}),
utils.CreateDummyResultWithOneLocation("file", 5, 6, 7, 8, "snippet", "rule1", "info"),
utils.CreateResultWithOneLocation("file", 5, 6, 7, 8, "snippet", "rule1", "info"),
),
},
}
Expand Down
Loading

0 comments on commit fceefe9

Please sign in to comment.