Skip to content

Commit c6935eb

Browse files
authored
feat: add scan with validation func to Scanner interface (#298)
<!-- Thanks for contributing to 2ms by offering a pull request. --> Closes # **Proposed Changes** <!-- Please describe the big picture of your changes here. If it fixes a bug or resolves a feature request, be sure to link to that issue. --> **Checklist** - [x] I covered my changes with tests. - [ ] I Updated the documentation that is affected by my changes: - [ ] Change in the CLI arguments - [ ] Change in the configuration file I submit this contribution under the Apache-2.0 license.
1 parent be5ad6f commit c6935eb

35 files changed

+326
-106
lines changed

.2ms.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,15 @@ ignore-result:
9494
- 44912790c892213daa0df821a006e1e1659e6e24 # value used for testing
9595
- ac3704513c4ab9bde3fa3539b14152c95ba5698f # value used for testing
9696
- ac2d6adbeca8901c1655bcf3e0eac027ca681825 # value used for testing
97+
- cfb06617a386e8c6a6fd25cf2dee18d88dfecbdd # value used for testing
98+
- 33269ddd7e8734ef20906f888fcd4c971d1483bc # value used for testing
99+
- 48b64922d5f628b4d57839f044c63f7000d0f840 # value used for testing
100+
- 38f3e9d8932aa9fc51a6a20295f8f1a95efc7799 # value used for testing
101+
- 1b14f7b1653e85b0c4e4b08b8ba5b508a896d102 # value used for testing
102+
- 8180b128c17dac4e375c712c9f265612ac528824 # value used for testing
103+
- 5b1a634de50b1ecbe1df038e02dbce5487083d54 # value used for testing
104+
- fc9d1484bb5c0c8cdd34b9790ebf90609674bb3d # value used for testing
105+
- af16d5223104c029475f82cd780fd57115ed1e2f # value used for testing
106+
- 91bc1fc92b04c56c5f746d50df5759e39b956146 # value used for testing
107+
- 4d4af54fd6e3e1209094e5838f339b6c95636f79 # value used for testing
108+
- fabcbd067a3bbf3cd5951d03ed4f17918241316a # value used for testing

cmd/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"regexp"
77
"strings"
88

9-
"github.com/checkmarx/2ms/lib/utils"
9+
"github.com/checkmarx/2ms/v3/lib/utils"
1010
"github.com/rs/zerolog"
1111
"github.com/rs/zerolog/log"
1212
"github.com/spf13/cobra"

cmd/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"fmt"
55
"sync"
66

7-
"github.com/checkmarx/2ms/engine"
8-
"github.com/checkmarx/2ms/lib/config"
9-
"github.com/checkmarx/2ms/lib/reporting"
10-
"github.com/checkmarx/2ms/lib/secrets"
11-
"github.com/checkmarx/2ms/plugins"
7+
"github.com/checkmarx/2ms/v3/engine"
8+
"github.com/checkmarx/2ms/v3/lib/config"
9+
"github.com/checkmarx/2ms/v3/lib/reporting"
10+
"github.com/checkmarx/2ms/v3/lib/secrets"
11+
"github.com/checkmarx/2ms/v3/plugins"
1212
"github.com/rs/zerolog"
1313
"github.com/rs/zerolog/log"
1414
"github.com/spf13/cobra"

cmd/main_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package cmd
22

33
import (
44
"fmt"
5-
"github.com/checkmarx/2ms/engine"
6-
"github.com/checkmarx/2ms/lib/secrets"
7-
"github.com/checkmarx/2ms/plugins"
5+
"github.com/checkmarx/2ms/v3/engine"
6+
"github.com/checkmarx/2ms/v3/lib/secrets"
7+
"github.com/checkmarx/2ms/v3/plugins"
88
"github.com/stretchr/testify/assert"
99
"sync"
1010
"testing"

cmd/workers.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package cmd
22

33
import (
44
"context"
5-
"github.com/checkmarx/2ms/engine"
6-
"github.com/checkmarx/2ms/engine/extra"
7-
"github.com/checkmarx/2ms/lib/secrets"
8-
"golang.org/x/sync/errgroup"
95
"sync"
6+
7+
"github.com/checkmarx/2ms/v3/engine"
8+
"github.com/checkmarx/2ms/v3/engine/extra"
9+
"github.com/checkmarx/2ms/v3/lib/secrets"
10+
"golang.org/x/sync/errgroup"
1011
)
1112

1213
func ProcessItems(engineInstance engine.IEngine, pluginName string) {
@@ -53,6 +54,20 @@ func ProcessSecrets() {
5354
close(CvssScoreWithoutValidationChan)
5455
}
5556

57+
func ProcessSecretsWithValidation() {
58+
defer Channels.WaitGroup.Done()
59+
60+
for secret := range SecretsChan {
61+
Report.TotalSecretsFound++
62+
SecretsExtrasChan <- secret
63+
ValidationChan <- secret
64+
Report.Results[secret.ID] = append(Report.Results[secret.ID], secret)
65+
}
66+
close(SecretsExtrasChan)
67+
close(ValidationChan)
68+
close(CvssScoreWithoutValidationChan)
69+
}
70+
5671
func ProcessSecretsExtras() {
5772
defer Channels.WaitGroup.Done()
5873

cmd/workers_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package cmd
22

33
import (
4-
"github.com/checkmarx/2ms/engine"
5-
"github.com/checkmarx/2ms/lib/reporting"
6-
"github.com/checkmarx/2ms/lib/secrets"
7-
"github.com/checkmarx/2ms/plugins"
4+
"github.com/checkmarx/2ms/v3/engine"
5+
"github.com/checkmarx/2ms/v3/lib/reporting"
6+
"github.com/checkmarx/2ms/v3/lib/secrets"
7+
"github.com/checkmarx/2ms/v3/plugins"
88
"github.com/stretchr/testify/assert"
99
"sort"
1010
"strconv"

engine/engine.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import (
1414
"sync"
1515
"text/tabwriter"
1616

17-
"github.com/checkmarx/2ms/engine/chunk"
18-
"github.com/checkmarx/2ms/engine/linecontent"
19-
"github.com/checkmarx/2ms/engine/rules"
20-
"github.com/checkmarx/2ms/engine/score"
21-
"github.com/checkmarx/2ms/engine/semaphore"
22-
"github.com/checkmarx/2ms/engine/validation"
23-
"github.com/checkmarx/2ms/lib/secrets"
24-
"github.com/checkmarx/2ms/plugins"
17+
"github.com/checkmarx/2ms/v3/engine/chunk"
18+
"github.com/checkmarx/2ms/v3/engine/linecontent"
19+
"github.com/checkmarx/2ms/v3/engine/rules"
20+
"github.com/checkmarx/2ms/v3/engine/score"
21+
"github.com/checkmarx/2ms/v3/engine/semaphore"
22+
"github.com/checkmarx/2ms/v3/engine/validation"
23+
"github.com/checkmarx/2ms/v3/lib/secrets"
24+
"github.com/checkmarx/2ms/v3/plugins"
2525
"github.com/rs/zerolog/log"
2626
"github.com/spf13/cobra"
2727
"github.com/zricethezav/gitleaks/v8/config"

engine/engine_mock.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

engine/engine_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010
"path/filepath"
1111
"testing"
1212

13-
"github.com/checkmarx/2ms/engine/chunk"
14-
"github.com/checkmarx/2ms/engine/rules"
15-
"github.com/checkmarx/2ms/engine/semaphore"
16-
"github.com/checkmarx/2ms/lib/secrets"
17-
"github.com/checkmarx/2ms/plugins"
13+
"github.com/checkmarx/2ms/v3/engine/chunk"
14+
"github.com/checkmarx/2ms/v3/engine/rules"
15+
"github.com/checkmarx/2ms/v3/engine/semaphore"
16+
"github.com/checkmarx/2ms/v3/lib/secrets"
17+
"github.com/checkmarx/2ms/v3/plugins"
1818
"github.com/rs/zerolog"
1919
"github.com/rs/zerolog/log"
2020
"github.com/stretchr/testify/assert"

engine/extra/extra.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"sync"
99

10-
"github.com/checkmarx/2ms/lib/secrets"
10+
"github.com/checkmarx/2ms/v3/lib/secrets"
1111
)
1212

1313
type addExtraFunc = func(*secrets.Secret) interface{}

0 commit comments

Comments
 (0)