Skip to content
Open
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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ engine.Invoke(code.WORKFLOWID_CODE)

The `codeWorkflowEntryPoint` function:
- Checks if SAST is enabled for the organization
- Determines whether to use the native or legacy implementation based on feature flags
- Routes to either `EntryPointNative` (for Code Consistent Ignores support) or `EntryPointLegacy`
- Routes to the native `EntryPointNative` implementation
- Returns workflow data containing scan results as local findings

### Library Functions
Expand Down Expand Up @@ -149,4 +148,4 @@ All of our development will remain public for transparency. We thank the communi

GitHub issues have been disabled on this repository as part of our move to a closed-contribution model. The Snyk support team does not actively monitor GitHub issues on any Snyk development project.

For help with the Snyk CLI or Snyk in general, please use the [Snyk support page](https://support.snyk.io/), which is the fastest way to get assistance.
For help with the Snyk CLI or Snyk in general, please use the [Snyk support page](https://support.snyk.io/), which is the fastest way to get assistance.
21 changes: 0 additions & 21 deletions internal/commands/code_workflow/legacy_workflow.go

This file was deleted.

57 changes: 11 additions & 46 deletions pkg/code/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,24 @@ import (
"slices"

"github.com/rs/zerolog"
"github.com/snyk/error-catalog-golang-public/code"
"github.com/spf13/pflag"

"github.com/snyk/code-client-go/internal/commands/code_workflow"
"github.com/snyk/code-client-go/pkg/code/sast_contract"
"github.com/snyk/error-catalog-golang-public/code"
"github.com/snyk/go-application-framework/pkg/configuration"
"github.com/snyk/go-application-framework/pkg/local_workflows/config_utils"
errorutils "github.com/snyk/go-application-framework/pkg/local_workflows/error_utils"
"github.com/snyk/go-application-framework/pkg/workflow"

"github.com/snyk/code-client-go/pkg/code/sast_contract"
"github.com/spf13/pflag"
)

const (
codeWorkflowName = "code.test"
)

const (
ConfigurationSastEnabled = "internal_sast_enabled"
ConfigurationSastSettings = code_workflow.ConfigurationSastSettings
ConfigurationSlceEnabled = code_workflow.ConfigurationSlceEnabled
FfNameNativeImplementation = "snykCodeClientNativeImplementation"
ConfigurationSastEnabled = "internal_sast_enabled"
ConfigurationSastSettings = code_workflow.ConfigurationSastSettings
ConfigurationSlceEnabled = code_workflow.ConfigurationSlceEnabled
)

// ConfigurarionSlceEnabled is kept for backward compatibility.
Expand Down Expand Up @@ -166,25 +163,6 @@ func getSlceEnabled(engine workflow.Engine) configuration.DefaultValueFunction {
return callback
}

func useNativeImplementation(config configuration.Configuration, logger *zerolog.Logger, sastEnabled bool, scleEnabled bool) bool {
useConsistentIgnoresFF := config.GetBool(configuration.FF_CODE_CONSISTENT_IGNORES)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is still an org/group level feature flag.
https://github.com/snyk/registry/blob/4b930c34f61661b32e27d9d2ceb086a71337b58d/src/lib/domain/internal-developer-tooling/features/index.ts#L1249-L1251

Despite it is set to ' true ' by default, customers can still disable it in the org/group settings page.
Can we remove the evaluation here?

useNativeImplementationFF := config.GetBool(configuration.FF_CODE_NATIVE_IMPLEMENTATION)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we remove the evaluation here?
The snykCodeClientNativeImplementation is disabled in fedRAMP env.
https://github.com/snyk/registry/blob/4b930c34f61661b32e27d9d2ceb086a71337b58d/helm/values/fedramp-production.yaml#L83

reportEnabled := config.GetBool(code_workflow.ConfigurationReportFlag)

// SCLE no longer forces the legacy path: code-client-go honors the local
// engine URL from SAST settings (see codeClientConfig.SnykCodeApi), so the
// native implementation supports SCLE flows directly.
nativeImplementationEnabled := useConsistentIgnoresFF || useNativeImplementationFF

logger.Debug().Msgf("SAST Enabled: %v", sastEnabled)
logger.Debug().Msgf("Report enabled: %v", reportEnabled)
logger.Debug().Msgf("SLCE enabled: %v", scleEnabled)
logger.Debug().Msgf("FF consistent ignores: %v", useConsistentIgnoresFF)
logger.Debug().Msgf("FF native implementation: %v", useNativeImplementationFF)

return nativeImplementationEnabled
}

// Init initializes the code workflow before registering it with the engine.
func Init(engine workflow.Engine) error {
// register workflow with engine
Expand All @@ -199,8 +177,6 @@ func Init(engine workflow.Engine) error {
engine.GetConfiguration().AddDefaultValue(ConfigurationSastEnabled, getSastEnabled(engine))
engine.GetConfiguration().AddDefaultValue(ConfigurationSlceEnabled, getSlceEnabled(engine))
engine.GetConfiguration().AddDefaultValue(code_workflow.ConfigurationTestFLowName, configuration.StandardDefaultValueFunction("cli_test"))
config_utils.AddFeatureFlagToConfig(engine, configuration.FF_CODE_CONSISTENT_IGNORES, "snykCodeConsistentIgnores")
config_utils.AddFeatureFlagToConfig(engine, configuration.FF_CODE_NATIVE_IMPLEMENTATION, FfNameNativeImplementation)
config_utils.AddFeatureFlagsToConfig(engine, map[string]string{
code_workflow.ConfigurationUploadToFileUploadApi: "code-cli-upload-file-content-to-fua",
})
Expand All @@ -209,7 +185,7 @@ func Init(engine workflow.Engine) error {
}

// codeWorkflowEntryPoint is the entry point for the code workflow.
// it provides a wrapper for the legacycli workflow
// It always runs the native code-client-go workflow.
func codeWorkflowEntryPoint(invocationCtx workflow.InvocationContext, _ []workflow.Data) (result []workflow.Data, err error) {
// get necessary objects from invocation context
config := invocationCtx.GetConfiguration()
Expand All @@ -221,28 +197,17 @@ func codeWorkflowEntryPoint(invocationCtx workflow.InvocationContext, _ []workfl
}

scleEnabled := config.GetBool(ConfigurationSlceEnabled)
nativeImplementation := useNativeImplementation(config, logger, sastEnabled, scleEnabled)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Any chance that both flags would be set to false?


if !sastEnabled {
return result, code.NewFeatureIsNotEnabledError(fmt.Sprintf("Snyk Code is not supported for your current organization: `%s`.", config.GetString(configuration.ORGANIZATION_SLUG)))
}

implementationName := "legacy"
if nativeImplementation {
implementationName = "native"
}

analyticsClient := invocationCtx.GetAnalytics()
analyticsClient.AddExtensionStringValue("implementation", implementationName)
analyticsClient.AddExtensionStringValue("implementation", "native")
analyticsClient.AddExtensionBoolValue("isSCLE", scleEnabled)
logger.Debug().Msgf("Implementation: %s", implementationName)
logger.Debug().Msg("Implementation: native")

if nativeImplementation {
registerLocalEngineAuthURL(config, logger)
result, err = code_workflow.EntryPointNative(invocationCtx)
} else {
result, err = code_workflow.EntryPointLegacy(invocationCtx)
}
registerLocalEngineAuthURL(config, logger)
result, err = code_workflow.EntryPointNative(invocationCtx)

err = errorutils.DecorateTestError(err, config)

Expand Down
Loading