Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .2ms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,15 @@ ignore-result:
- 44912790c892213daa0df821a006e1e1659e6e24 # value used for testing
- ac3704513c4ab9bde3fa3539b14152c95ba5698f # value used for testing
- ac2d6adbeca8901c1655bcf3e0eac027ca681825 # value used for testing
- cfb06617a386e8c6a6fd25cf2dee18d88dfecbdd # value used for testing
- 33269ddd7e8734ef20906f888fcd4c971d1483bc # value used for testing
- 48b64922d5f628b4d57839f044c63f7000d0f840 # value used for testing
- 38f3e9d8932aa9fc51a6a20295f8f1a95efc7799 # value used for testing
- 1b14f7b1653e85b0c4e4b08b8ba5b508a896d102 # value used for testing
- 8180b128c17dac4e375c712c9f265612ac528824 # value used for testing
- 5b1a634de50b1ecbe1df038e02dbce5487083d54 # value used for testing
- fc9d1484bb5c0c8cdd34b9790ebf90609674bb3d # value used for testing
- af16d5223104c029475f82cd780fd57115ed1e2f # value used for testing
- 91bc1fc92b04c56c5f746d50df5759e39b956146 # value used for testing
- 4d4af54fd6e3e1209094e5838f339b6c95636f79 # value used for testing
- fabcbd067a3bbf3cd5951d03ed4f17918241316a # value used for testing
2 changes: 1 addition & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"regexp"
"strings"

"github.com/checkmarx/2ms/lib/utils"
"github.com/checkmarx/2ms/v3/lib/utils"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand Down
10 changes: 5 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"sync"

"github.com/checkmarx/2ms/engine"
"github.com/checkmarx/2ms/lib/config"
"github.com/checkmarx/2ms/lib/reporting"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/plugins"
"github.com/checkmarx/2ms/v3/engine"
"github.com/checkmarx/2ms/v3/lib/config"
"github.com/checkmarx/2ms/v3/lib/reporting"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/checkmarx/2ms/v3/plugins"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand Down
6 changes: 3 additions & 3 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package cmd

import (
"fmt"
"github.com/checkmarx/2ms/engine"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/plugins"
"github.com/checkmarx/2ms/v3/engine"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/checkmarx/2ms/v3/plugins"
"github.com/stretchr/testify/assert"
"sync"
"testing"
Expand Down
23 changes: 19 additions & 4 deletions cmd/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package cmd

import (
"context"
"github.com/checkmarx/2ms/engine"
"github.com/checkmarx/2ms/engine/extra"
"github.com/checkmarx/2ms/lib/secrets"
"golang.org/x/sync/errgroup"
"sync"

"github.com/checkmarx/2ms/v3/engine"
"github.com/checkmarx/2ms/v3/engine/extra"
"github.com/checkmarx/2ms/v3/lib/secrets"
"golang.org/x/sync/errgroup"
)

func ProcessItems(engineInstance engine.IEngine, pluginName string) {
Expand Down Expand Up @@ -53,6 +54,20 @@ func ProcessSecrets() {
close(CvssScoreWithoutValidationChan)
}

func ProcessSecretsWithValidation() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason to create this function? can we follow a similar strategy to the preRun function from cmd/main.go? The idea is to eventually refactor to have common logic from the 2ms cli flow instead of duplicated code, so it would be better to not create new logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it will require to change ProcessSecrets() signature, I dont know if it will cause breaking changes in other places that importing this repo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why will it require to change the ProcessSecrets() signature?

defer Channels.WaitGroup.Done()

for secret := range SecretsChan {
Report.TotalSecretsFound++
SecretsExtrasChan <- secret
ValidationChan <- secret
Report.Results[secret.ID] = append(Report.Results[secret.ID], secret)
}
close(SecretsExtrasChan)
close(ValidationChan)
close(CvssScoreWithoutValidationChan)
}

func ProcessSecretsExtras() {
defer Channels.WaitGroup.Done()

Expand Down
8 changes: 4 additions & 4 deletions cmd/workers_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package cmd

import (
"github.com/checkmarx/2ms/engine"
"github.com/checkmarx/2ms/lib/reporting"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/plugins"
"github.com/checkmarx/2ms/v3/engine"
"github.com/checkmarx/2ms/v3/lib/reporting"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/checkmarx/2ms/v3/plugins"
"github.com/stretchr/testify/assert"
"sort"
"strconv"
Expand Down
16 changes: 8 additions & 8 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
"sync"
"text/tabwriter"

"github.com/checkmarx/2ms/engine/chunk"
"github.com/checkmarx/2ms/engine/linecontent"
"github.com/checkmarx/2ms/engine/rules"
"github.com/checkmarx/2ms/engine/score"
"github.com/checkmarx/2ms/engine/semaphore"
"github.com/checkmarx/2ms/engine/validation"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/plugins"
"github.com/checkmarx/2ms/v3/engine/chunk"
"github.com/checkmarx/2ms/v3/engine/linecontent"
"github.com/checkmarx/2ms/v3/engine/rules"
"github.com/checkmarx/2ms/v3/engine/score"
"github.com/checkmarx/2ms/v3/engine/semaphore"
"github.com/checkmarx/2ms/v3/engine/validation"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/checkmarx/2ms/v3/plugins"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/zricethezav/gitleaks/v8/config"
Expand Down
4 changes: 2 additions & 2 deletions engine/engine_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"path/filepath"
"testing"

"github.com/checkmarx/2ms/engine/chunk"
"github.com/checkmarx/2ms/engine/rules"
"github.com/checkmarx/2ms/engine/semaphore"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/plugins"
"github.com/checkmarx/2ms/v3/engine/chunk"
"github.com/checkmarx/2ms/v3/engine/rules"
"github.com/checkmarx/2ms/v3/engine/semaphore"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/checkmarx/2ms/v3/plugins"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion engine/extra/extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"sync"

"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/lib/secrets"
)

type addExtraFunc = func(*secrets.Secret) interface{}
Expand Down
2 changes: 1 addition & 1 deletion engine/extra/extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package extra
import (
"encoding/base64"
"fmt"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/stretchr/testify/assert"
"sync"
"testing"
Expand Down
2 changes: 1 addition & 1 deletion engine/rules/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package rules_test
import (
"testing"

"github.com/checkmarx/2ms/engine/rules"
"github.com/checkmarx/2ms/v3/engine/rules"
"github.com/zricethezav/gitleaks/v8/config"
)

Expand Down
4 changes: 2 additions & 2 deletions engine/score/score.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package score

import (
"github.com/checkmarx/2ms/engine/rules"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/engine/rules"
"github.com/checkmarx/2ms/v3/lib/secrets"
"math"
)

Expand Down
8 changes: 4 additions & 4 deletions engine/score/score_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package score_test

import (
. "github.com/checkmarx/2ms/engine"
"github.com/checkmarx/2ms/engine/rules"
"github.com/checkmarx/2ms/engine/score"
"github.com/checkmarx/2ms/lib/secrets"
. "github.com/checkmarx/2ms/v3/engine"
"github.com/checkmarx/2ms/v3/engine/rules"
"github.com/checkmarx/2ms/v3/engine/score"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/stretchr/testify/assert"
ruleConfig "github.com/zricethezav/gitleaks/v8/cmd/generate/config/rules"
"sync"
Expand Down
2 changes: 1 addition & 1 deletion engine/validation/alibaba.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"time"

"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/rs/zerolog/log"
)

Expand Down
2 changes: 1 addition & 1 deletion engine/validation/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"strings"

"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/rs/zerolog/log"
)

Expand Down
2 changes: 1 addition & 1 deletion engine/validation/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"net/http"

"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/rs/zerolog/log"
)

Expand Down
2 changes: 1 addition & 1 deletion engine/validation/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"net/http"

"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/rs/zerolog/log"
)

Expand Down
2 changes: 1 addition & 1 deletion engine/validation/pairs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package validation
import (
"sync"

"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/lib/secrets"
)

type pairsByRuleId map[string][]*secrets.Secret
Expand Down
4 changes: 2 additions & 2 deletions engine/validation/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package validation
import (
"sync"

"github.com/checkmarx/2ms/engine/extra"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/engine/extra"
"github.com/checkmarx/2ms/v3/lib/secrets"
)

type validationFunc = func(*secrets.Secret) (secrets.ValidationResult, string)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/checkmarx/2ms
module github.com/checkmarx/2ms/v3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we jumping on the version here? If we don't have a strong reason to do this, we can stay here and not make people update their imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to add to the module name the v3 suffix (this is go conventions in order to be able to import releases with major of 3..)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that but my question is, why do we need to bump the version? If we are not making a significant change to the project and as far as I understand, we can add the suggested feature without impacting the current use of the 2ms, the version bump is not needed, right?


go 1.23.6

Expand Down
4 changes: 2 additions & 2 deletions lib/reporting/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"path/filepath"
"strings"

"github.com/checkmarx/2ms/lib/config"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/lib/config"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/rs/zerolog/log"
)

Expand Down
4 changes: 2 additions & 2 deletions lib/reporting/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"testing"

"github.com/checkmarx/2ms/lib/config"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/lib/config"
"github.com/checkmarx/2ms/v3/lib/secrets"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
Expand Down
4 changes: 2 additions & 2 deletions lib/reporting/sarif.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"strings"

"github.com/checkmarx/2ms/lib/config"
"github.com/checkmarx/2ms/lib/secrets"
"github.com/checkmarx/2ms/v3/lib/config"
"github.com/checkmarx/2ms/v3/lib/secrets"
)

func writeSarif(report *Report, cfg *config.Config) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/checkmarx/2ms/lib/utils"
"github.com/checkmarx/2ms/v3/lib/utils"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"os"
"os/signal"

"github.com/checkmarx/2ms/cmd"
"github.com/checkmarx/2ms/lib/utils"
"github.com/checkmarx/2ms/v3/cmd"
"github.com/checkmarx/2ms/v3/lib/utils"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
Expand Down
Loading
Loading