Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c2835af
unique-id
cx-hitesh-madgulkar Oct 16, 2025
07248af
config-file-save
cx-hitesh-madgulkar Oct 16, 2025
d996c7a
unique-id
cx-hitesh-madgulkar Oct 17, 2025
37efa83
license-name-corrected
cx-hitesh-madgulkar Oct 17, 2025
7106c1f
Merge branch 'main' of https://github.com/Checkmarx/ast-cli into feat…
cx-hitesh-madgulkar Oct 24, 2025
0051eb6
interface-conversion-check
cx-hitesh-madgulkar Oct 24, 2025
0dda5b5
removing-domain-from-username-if-exists
cx-hitesh-madgulkar Oct 27, 2025
ab57cb2
using-standalone-license
cx-hitesh-madgulkar Oct 27, 2025
6bf553d
calling-telemetry-api-post-valid-login
cx-hitesh-madgulkar Oct 27, 2025
419bd21
Merge branch 'main' of https://github.com/Checkmarx/ast-cli into feat…
cx-hitesh-madgulkar Oct 27, 2025
9e0b036
Merge branch 'main' of https://github.com/Checkmarx/ast-cli into feat…
cx-hitesh-madgulkar Oct 30, 2025
ba92626
post-login-setting-type-n-subtype-as-authentication
cx-hitesh-madgulkar Oct 30, 2025
46b3681
dev-done-using-developer-license
cx-hitesh-madgulkar Oct 31, 2025
6b0ef20
Merge branch 'main' of https://github.com/Checkmarx/ast-cli into feat…
cx-hitesh-madgulkar Nov 3, 2025
75d3ddc
Code changes done to get license details
cx-rahul-pidde Nov 5, 2025
d0ec2f8
removed commented code
cx-rahul-pidde Nov 5, 2025
e15e699
removed commented code
cx-rahul-pidde Nov 5, 2025
9435b25
updated test cases and added license details in respose
cx-rahul-pidde Nov 17, 2025
7d905f8
changed-file-path-to-download-vorpal-sca-resolver (#1344)
cx-hitesh-madgulkar Nov 5, 2025
c899597
Updated macos version (AST-0000) (#1346)
cx-anurag-dalke Nov 5, 2025
de69577
Change macOS runner and add architecture detection
cx-anurag-dalke Nov 5, 2025
8128997
Modify Cosign installation in release workflow
cx-anurag-dalke Nov 5, 2025
4b874b7
Update release.yml
cx-anurag-dalke Nov 5, 2025
0fc3168
Fix AST-120637 vulnerability undate ../containerd from v 1.7.28 to 1.…
Nov 13, 2025
05cccbc
Fix AST-120637 vulnerability undate ../containerd from v 1.7.28 to 1.…
cx-margarita-levitm Nov 17, 2025
2d2b749
Containers cloud scan integration tests (AST-107639) (#1347)
cx-dmitri-rivin Nov 17, 2025
3c7bb37
Merge branch 'main' of https://github.com/Checkmarx/ast-cli
cx-rahul-pidde Nov 17, 2025
7008205
pulled-main
cx-hitesh-madgulkar Nov 27, 2025
97da1ee
get-unique-id-func-refactored
cx-hitesh-madgulkar Nov 27, 2025
a360ffb
Merge branch 'main' of https://github.com/Checkmarx/ast-cli
cx-rahul-pidde Nov 28, 2025
c635469
fixed lint issue
cx-rahul-pidde Nov 17, 2025
14b648b
removed unused parameter
cx-rahul-pidde Nov 17, 2025
f41fc36
updated license as Checkmarx Developer Assist
cx-rahul-pidde Nov 28, 2025
35b4d6f
added validaion
cx-rahul-pidde Nov 28, 2025
897ebdb
fixed conflicts
cx-rahul-pidde Nov 28, 2025
dac29b8
updated flag name
cx-rahul-pidde Nov 28, 2025
bd5f3c2
removed unique id logs
cx-rahul-pidde Nov 28, 2025
3b2970f
Update jwt-helper.go
cx-rahul-pidde Dec 1, 2025
3b8f3b0
Update jwt-helper-mock.go
cx-rahul-pidde Dec 1, 2025
58530e3
Merge branch 'main' into other/devassist-license-changes
cx-rahul-pidde Dec 5, 2025
6818d3a
Merge branch 'main' into other/devassist-license-changes
cx-margarita-levitm Dec 8, 2025
1b277ab
Merge branch 'main' into other/devassist-license-changes
cx-rahul-pidde Dec 10, 2025
ab7ce06
Merge branch 'main' into other/devassist-license-changes
cx-anurag-dalke Dec 11, 2025
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
20 changes: 17 additions & 3 deletions internal/commands/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"

"github.com/MakeNowJust/heredoc"
"github.com/checkmarx/ast-cli/internal/logger"
"github.com/checkmarx/ast-cli/internal/params"
"github.com/checkmarx/ast-cli/internal/wrappers"
"github.com/google/uuid"
Expand Down Expand Up @@ -38,7 +39,7 @@ type ClientCreated struct {
Secret string `json:"secret"`
}

func NewAuthCommand(authWrapper wrappers.AuthWrapper) *cobra.Command {
func NewAuthCommand(authWrapper wrappers.AuthWrapper, telemetryWrapper wrappers.TelemetryWrapper) *cobra.Command {
authCmd := &cobra.Command{
Use: "auth",
Short: "Validate authentication and create OAuth2 credentials",
Expand Down Expand Up @@ -110,13 +111,13 @@ func NewAuthCommand(authWrapper wrappers.AuthWrapper) *cobra.Command {
`,
),
},
RunE: validLogin(),
RunE: validLogin(telemetryWrapper),
}
authCmd.AddCommand(createClientCmd, validLoginCmd)
return authCmd
}

func validLogin() func(cmd *cobra.Command, args []string) error {
func validLogin(telemetryWrapper wrappers.TelemetryWrapper) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
clientID := viper.GetString(params.AccessKeyIDConfigKey)
clientSecret := viper.GetString(params.AccessKeySecretConfigKey)
Expand All @@ -125,6 +126,19 @@ func validLogin() func(cmd *cobra.Command, args []string) error {
authWrapper := wrappers.NewAuthHTTPWrapper()
authWrapper.SetPath(viper.GetString(params.ScansPathKey))
err := authWrapper.ValidateLogin()

uniqueID := wrappers.GetUniqueID()
if uniqueID != "" {
telemetryErr := telemetryWrapper.SendAIDataToLog(&wrappers.DataForAITelemetry{
UniqueID: uniqueID,
Type: "authentication",
SubType: "authentication",
})
if telemetryErr != nil {
logger.PrintIfVerbose("Failed to send telemetry data: " + telemetryErr.Error())
}
}

if err != nil {
return errors.Errorf("%s", err)
}
Expand Down
3 changes: 2 additions & 1 deletion internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func NewAstCLI(
)

versionCmd := util.NewVersionCommand()
authCmd := NewAuthCommand(authWrapper)
authCmd := NewAuthCommand(authWrapper, telemetryWrapper)
utilsCmd := util.NewUtilsCommand(
gitHubWrapper,
azureWrapper,
Expand All @@ -215,6 +215,7 @@ func NewAstCLI(
prWrapper,
learnMoreWrapper,
tenantWrapper,
jwtWrapper,
chatWrapper,
policyWrapper,
scansWrapper,
Expand Down
3 changes: 2 additions & 1 deletion internal/commands/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func runTelemetryAI(telemetryWrapper wrappers.TelemetryWrapper) func(*cobra.Comm
scanType, _ := cmd.Flags().GetString("scan-type")
status, _ := cmd.Flags().GetString("status")
totalCount, _ := cmd.Flags().GetInt("total-count")

uniqueID := wrappers.GetUniqueID()
err := telemetryWrapper.SendAIDataToLog(&wrappers.DataForAITelemetry{
AIProvider: aiProvider,
ProblemSeverity: problemSeverity,
Expand All @@ -69,6 +69,7 @@ func runTelemetryAI(telemetryWrapper wrappers.TelemetryWrapper) func(*cobra.Comm
ScanType: scanType,
Status: status,
TotalCount: totalCount,
UniqueID: uniqueID,
})

if err != nil {
Expand Down
28 changes: 24 additions & 4 deletions internal/commands/util/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/spf13/cobra"
)

func NewTenantConfigurationCommand(wrapper wrappers.TenantConfigurationWrapper) *cobra.Command {
func NewTenantConfigurationCommand(wrapper wrappers.TenantConfigurationWrapper, jwtWrapper wrappers.JWTWrapper) *cobra.Command {
cmd := &cobra.Command{
Use: "tenant",
Short: "Shows the tenant settings",
Expand All @@ -27,7 +27,7 @@ func NewTenantConfigurationCommand(wrapper wrappers.TenantConfigurationWrapper)
`,
),
},
RunE: runTenantCmd(wrapper),
RunE: runTenantCmd(wrapper, jwtWrapper),
}
cmd.PersistentFlags().String(
params.FormatFlag,
Expand All @@ -40,7 +40,7 @@ func NewTenantConfigurationCommand(wrapper wrappers.TenantConfigurationWrapper)
return cmd
}

func runTenantCmd(wrapper wrappers.TenantConfigurationWrapper) func(cmd *cobra.Command, args []string) error {
func runTenantCmd(wrapper wrappers.TenantConfigurationWrapper, jwtWrapper wrappers.JWTWrapper) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
tenantConfigurationResponse, errorModel, err := wrapper.GetTenantConfiguration()
if err != nil {
Expand All @@ -52,10 +52,16 @@ func runTenantCmd(wrapper wrappers.TenantConfigurationWrapper) func(cmd *cobra.C
if tenantConfigurationResponse != nil {
format, _ := cmd.Flags().GetString(params.FormatFlag)
tenantConfigurationResponseView := toTenantConfigurationResponseView(tenantConfigurationResponse)

licenseDetails, err := jwtWrapper.GetLicenseDetails()
if err == nil {
tenantConfigurationResponseView = appendLicenseDetails(tenantConfigurationResponseView, licenseDetails)
}

if format == "" {
format = defaultFormat
}
err := printer.Print(cmd.OutOrStdout(), tenantConfigurationResponseView, format)
err = printer.Print(cmd.OutOrStdout(), tenantConfigurationResponseView, format)
if err != nil {
return err
}
Expand All @@ -76,3 +82,17 @@ func toTenantConfigurationResponseView(response *[]*wrappers.TenantConfiguration
}
return tenantConfigurationResponseView
}

func appendLicenseDetails(responseView interface{}, licenseDetails map[string]string) interface{} {
tenantConfigurationResponseView := responseView.([]*wrappers.TenantConfigurationResponse)

for key, value := range licenseDetails {
licenseEntry := &wrappers.TenantConfigurationResponse{
Key: key,
Value: value,
}
tenantConfigurationResponseView = append(tenantConfigurationResponseView, licenseEntry)
}

return tenantConfigurationResponseView
}
12 changes: 6 additions & 6 deletions internal/commands/util/tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@ import (
)

func TestTenantConfigurationHelp(t *testing.T) {
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{})
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{}, &mock.JWTMockWrapper{})
cmd.SetArgs([]string{"utils", "tenant", "--help"})
err := cmd.Execute()
assert.Assert(t, err == nil)
}

func TestTenantConfigurationJsonFormat(t *testing.T) {
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{})
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{}, &mock.JWTMockWrapper{})
cmd.SetArgs([]string{"utils", "tenant", "--format", "json"})
err := cmd.Execute()
assert.NilError(t, err, "Tenant configuration command should run with no errors and print to json")
}

func TestTenantConfigurationListFormat(t *testing.T) {
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{})
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{}, &mock.JWTMockWrapper{})
cmd.SetArgs([]string{"utils", "tenant", "--format", "list"})
err := cmd.Execute()
assert.NilError(t, err, "Tenant configuration command should run with no errors and print to list")
}

func TestTenantConfigurationTableFormat(t *testing.T) {
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{})
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{}, &mock.JWTMockWrapper{})
cmd.SetArgs([]string{"utils", "tenant", "--format", "table"})
err := cmd.Execute()
assert.NilError(t, err, "Tenant configuration command should run with no errors and print to table")
}

func TestTenantConfigurationInvalidFormat(t *testing.T) {
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{})
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{}, &mock.JWTMockWrapper{})
cmd.SetArgs([]string{"utils", "tenant", "--format", "MOCK"})
err := cmd.Execute()
assert.Assert(t, err.Error() == mockFormatErrorMessage)
}

func TestNewTenantConfigurationCommand(t *testing.T) {
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{})
cmd := NewTenantConfigurationCommand(mock.TenantConfigurationMockWrapper{}, &mock.JWTMockWrapper{})
assert.Assert(t, cmd != nil, "Tenant configuration command must exist")
}
3 changes: 2 additions & 1 deletion internal/commands/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func NewUtilsCommand(
prWrapper wrappers.PRWrapper,
learnMoreWrapper wrappers.LearnMoreWrapper,
tenantWrapper wrappers.TenantConfigurationWrapper,
jwtWrapper wrappers.JWTWrapper,
chatWrapper wrappers.ChatWrapper,
policyWrapper wrappers.PolicyWrapper,
scansWrapper wrappers.ScansWrapper,
Expand Down Expand Up @@ -76,7 +77,7 @@ func NewUtilsCommand(

learnMoreCmd := NewLearnMoreCommand(learnMoreWrapper)

tenantCmd := NewTenantConfigurationCommand(tenantWrapper)
tenantCmd := NewTenantConfigurationCommand(tenantWrapper, jwtWrapper)

maskSecretsCmd := NewMaskSecretsCommand(chatWrapper)

Expand Down
1 change: 1 addition & 0 deletions internal/commands/util/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestNewUtilsCommand(t *testing.T) {
nil,
mock.LearnMoreMockWrapper{},
mock.TenantConfigurationMockWrapper{},
&mock.JWTMockWrapper{},
mock.ChatMockWrapper{},
nil,
nil,
Expand Down
1 change: 1 addition & 0 deletions internal/params/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const (
RiskManagementPathEnv = "CX_RISK_MANAGEMENT_PATH"
ConfigFilePathEnv = "CX_CONFIG_FILE_PATH"
RealtimeScannerPathEnv = "CX_REALTIME_SCANNER_PATH"
UniqueIDEnv = "CX_UNIQUE_ID"
StartMultiPartUploadPathEnv = "CX_START_MULTIPART_UPLOAD_PATH"
MultipartPresignedPathEnv = "CX_MULTIPART_PRESIGNED_URL_PATH"
CompleteMultipartUploadPathEnv = "CX_COMPLETE_MULTIPART_UPLOAD_PATH"
Expand Down
1 change: 1 addition & 0 deletions internal/params/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ const (
APISecurityType = "api-security"
AIProtectionType = "AI Protection"
CheckmarxOneAssistType = "Checkmarx One Assist"
CheckmarxDevAssistType = "Checkmarx Developer Assist"
ContainersType = "containers"
APIDocumentationFlag = "apisec-swagger-filter"
IacType = "iac-security"
Expand Down
1 change: 1 addition & 0 deletions internal/params/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ var (
RiskManagementPathKey = strings.ToLower(RiskManagementPathEnv)
ConfigFilePathKey = strings.ToLower(ConfigFilePathEnv)
RealtimeScannerPathKey = strings.ToLower(RealtimeScannerPathEnv)
UniqueIDConfigKey = strings.ToLower(UniqueIDEnv)
StartMultiPartUploadPathKey = strings.ToLower(StartMultiPartUploadPathEnv)
MultipartPresignedPathKey = strings.ToLower(MultipartPresignedPathEnv)
CompleteMultiPartUploadPathKey = strings.ToLower(CompleteMultipartUploadPathEnv)
Expand Down
7 changes: 6 additions & 1 deletion internal/services/realtimeengine/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ func EnsureLicense(jwtWrapper wrappers.JWTWrapper) error {
return errors.Wrap(err, "failed to check AIProtectionType engine allowance")
}

if aiAllowed || assistAllowed {
devAssistAllowed, err := jwtWrapper.IsAllowedEngine(params.CheckmarxDevAssistType)
if err != nil {
return errors.Wrap(err, "failed to check Checkmarx Developer Assist engine allowance")
}

if aiAllowed || assistAllowed || devAssistAllowed {
return nil
}
return errors.New(errorconstants.ErrMissingAIFeatureLicense)
Expand Down
19 changes: 13 additions & 6 deletions internal/wrappers/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,19 @@ func retryHTTPForIAMRequest(requestFunc func() (*http.Response, error), retries
return nil, err
}

func setAgentNameAndOrigin(req *http.Request) {
func setAgentNameAndOrigin(req *http.Request, isAuth bool) {
agentStr := viper.GetString(commonParams.AgentNameKey) + "/" + commonParams.Version
req.Header.Set("User-Agent", agentStr)

originStr := viper.GetString(commonParams.OriginKey)
req.Header.Set("Cx-Origin", originStr)

if !isAuth {
uniqueID := GetUniqueID()
if uniqueID != "" {
req.Header.Set("UniqueId", uniqueID)
}
}
}

func GetClient(timeout uint) *http.Client {
Expand Down Expand Up @@ -375,7 +382,7 @@ func SendHTTPRequestByFullURLContentLength(
req.ContentLength = contentLength
}
client := GetClient(timeout)
setAgentNameAndOrigin(req)
setAgentNameAndOrigin(req, false)
if auth {
enrichWithOath2Credentials(req, accessToken, bearerFormat)
}
Expand Down Expand Up @@ -427,7 +434,7 @@ func SendHTTPRequestPasswordAuth(method string, body io.Reader, timeout uint, us
}
req, err := http.NewRequest(method, u, body)
client := GetClient(timeout)
setAgentNameAndOrigin(req)
setAgentNameAndOrigin(req, true)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -464,7 +471,7 @@ func HTTPRequestWithQueryParams(
}
req, err := http.NewRequest(method, u, body)
client := GetClient(timeout)
setAgentNameAndOrigin(req)
setAgentNameAndOrigin(req, false)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -512,7 +519,7 @@ func SendHTTPRequestWithJSONContentType(method, path string, body io.Reader, aut
}
req, err := http.NewRequest(method, fullURL, body)
client := GetClient(timeout)
setAgentNameAndOrigin(req)
setAgentNameAndOrigin(req, false)
req.Header.Add("Content-Type", jsonContentType)
if err != nil {
return nil, err
Expand Down Expand Up @@ -645,7 +652,7 @@ func writeCredentialsToCache(accessToken string) {
func getNewToken(credentialsPayload, authServerURI string) (string, error) {
payload := strings.NewReader(credentialsPayload)
req, err := http.NewRequest(http.MethodPost, authServerURI, payload)
setAgentNameAndOrigin(req)
setAgentNameAndOrigin(req, true)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/wrappers/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func TestSetAgentNameAndOrigin(t *testing.T) {

req := httptest.NewRequest(http.MethodGet, "http://example.com", nil)

setAgentNameAndOrigin(req)
setAgentNameAndOrigin(req, false)

userAgent := req.Header.Get("User-Agent")
origin := req.Header.Get("origin")
Expand Down
Loading
Loading