Skip to content

chore: iaw uses org setting insted of feature flag #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

CatalinSnyk
Copy link
Contributor

@CatalinSnyk CatalinSnyk commented Aug 5, 2025

Previously, the IAW create workflow was gated behind a feature flag check. For EA, customers should be able to opt in/out of using the ignore approval, so a new org setting was added for them to toggle on/off.

This PR just swaps out the feature flag check with an fetching the org settings and checking whether IAW is enabled for the current org before proceeding with the ignore create workflow.

Ref: CLI-1006

Copy link

snyk-io bot commented Aug 5, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

code/snyk check is complete. No issues have been found. (View Details)

Copy link

snyk-io bot commented Aug 5, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

code/snyk check is complete. No issues have been found. (View Details)

@CatalinSnyk CatalinSnyk marked this pull request as ready for review August 5, 2025 12:23
@CatalinSnyk CatalinSnyk requested review from a team as code owners August 5, 2025 12:23
if !config.GetBool(configuration.FF_IAW_ENABLED) {
return nil, cli.NewFeatureUnderDevelopmentError("")
if !config.GetBool(configIgnoreApprovalEnabled) {
return nil, snyk_errors.Error{
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'll change this to an error coming from the Error Catalog before merging.

cursor[bot]

This comment was marked as outdated.

}

type OrgSettingsResponse struct {
Ignores OrgIgnoreSettings `json:"ignores"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why only Ignores? Are there not more fields? If we add them now, we don't have to touch the implementation again, when we need a different org setting :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the only other field there was.

A question for the audience from my side now:

  • Should I be marking the fields as pointers since they are marked as optional, even if all of them are boolean values? I was thinking that if a field is not specified then it should be handled as false, but I'm wondering if that's a good assumption.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should I be marking the fields as pointers since they are marked as optional, even if all of them are boolean values? I was thinking that if a field is not specified then it should be handled as false, but I'm wondering if that's a good assumption.

I think so, pointers along with the omitempty tag suffix seem to be the accepted pattern in the codebase.

@@ -43,6 +44,28 @@ func addCreateIgnoreDefaultConfigurationValues(invocationCtx workflow.Invocation
})
}

func getOrgIgnoreApprovalEnabled(engine workflow.Engine) configuration.DefaultValueFunction {
return func(existingValue interface{}) (interface{}, error) {
if existingValue != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

this should probably be backed by a cache - after xy time (e.g. 30min), it should not use the previous value. This is important for long-running CLIs, e.g. for Language Server.

Copy link
Contributor

Choose a reason for hiding this comment

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

The config uses a cache and how long things are cached is based on the a setting for the configuration. Caching is transparent for the default function and it just needs to handle the business logic itself.

@@ -247,6 +248,28 @@ func (a *snykApiClient) GetSastSettings(orgId string) (*sast_contract.SastRespon
return &response, err
}

func (a *snykApiClient) GetOrgSettings(orgId string) (*contract.OrgSettingsResponse, error) {
endpoint := fmt.Sprintf("%s/v1/org/%s/settings", a.url, url.QueryEscape(orgId))
res, err := a.client.Get(endpoint)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: use clientGet() instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants