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
2 changes: 1 addition & 1 deletion .github/workflows/pr-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
exit 1
fi

if ! [[ "$PR_BRANCH" =~ ^(bug|feature|other)/ ]]; then
if ! [[ "$PR_BRANCH" =~ ^(bug|fix|feature|other)/ ]]; then
echo "::error::Branch name must start with 'bug/' or 'feature/' or 'other/'."
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Each line is a file pattern followed by one or more owners

# Specify the default owners for the entire repository
* @OrShamirCM @AlvoBen
* @AlvoBen @greensd4 @miryamfoiferCX
18 changes: 18 additions & 0 deletions internal/services/asca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

errorconstants "github.com/checkmarx/ast-cli/internal/constants/errors"
"github.com/checkmarx/ast-cli/internal/wrappers"
"github.com/checkmarx/ast-cli/internal/wrappers/grpcs"
"github.com/checkmarx/ast-cli/internal/wrappers/mock"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -130,3 +131,20 @@ func TestCreateASCAScanRequest_EngineRunningAndDefaultAgentAndNoLicense_Success(
assert.Nil(t, wrapperParams.ASCAWrapper.HealthCheck())
_ = wrapperParams.ASCAWrapper.ShutDown()
}

func TestCreateASCAScanRequest_whenCheckLicenseWithPackageEnforcementFFOff_shouldSuccess(t *testing.T) {
port, err := getAvailablePort()
if err != nil {
t.Fatalf("Failed to get available port: %v", err)
}

mock.Flag = wrappers.FeatureFlagResponseModel{Name: wrappers.PackageEnforcementEnabled, Status: false}

wrapperParams := AscaWrappersParam{
JwtWrapper: wrappers.NewJwtWrapper(),
FeatureFlagsWrapper: &mock.FeatureFlagsMockWrapper{},
ASCAWrapper: grpcs.NewASCAGrpcWrapper(port),
}
err = checkLicense(false, wrapperParams)
assert.Nil(t, err)
}
20 changes: 11 additions & 9 deletions internal/wrappers/jwt-helper.go
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe return
if !flagResponse.Status {
return true, nil
}
jwtStruct, err := getJwtStruct()...

Early return if the feature flag is disabled, to avoid unnecessary nested logic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good idea!

Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,18 @@ func getJwtStruct() (*JWTStruct, error) {
// IsAllowedEngine will return if the engine is allowed in the user license
func (*JWTStruct) IsAllowedEngine(engine string, featureFlagsWrapper FeatureFlagsWrapper) (bool, error) {
flagResponse, _ := GetSpecificFeatureFlag(featureFlagsWrapper, PackageEnforcementEnabled)
if flagResponse.Status {
jwtStruct, err := getJwtStruct()
if err != nil {
return false, err
}
if !flagResponse.Status {
return true, nil
}

jwtStruct, err := getJwtStruct()
if err != nil {
return false, err
}

for _, allowedEngine := range jwtStruct.AstLicense.LicenseData.AllowedEngines {
if strings.EqualFold(allowedEngine, engine) {
return true, nil
}
for _, allowedEngine := range jwtStruct.AstLicense.LicenseData.AllowedEngines {
if strings.EqualFold(allowedEngine, engine) {
return true, nil
}
}
return false, nil
Expand Down
2 changes: 1 addition & 1 deletion test/integration/bfl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestRunGetBflWithInvalidScanIDandQueryID(t *testing.T) {
err, _ := executeCommand(
t, "results", "bfl",
flag(params.ScanIDFlag), "123456",
flag(params.QueryIDFlag), "abcd",
flag(params.QueryIDFlag), "1",
flag(params.FormatFlag), "json")

assertError(t, err, "Failed getting BFL: CODE: 5002, Failed getting BFL")
Expand Down
Loading