Skip to content

Commit 957990a

Browse files
authored
feat: add setting to prevent implicit workflow creation (#2527)
Signed-off-by: Miguel Martinez <[email protected]>
1 parent 430af45 commit 957990a

39 files changed

+698
-326
lines changed

app/cli/cmd/organization_update.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ import (
2222

2323
func newOrganizationUpdateCmd() *cobra.Command {
2424
var (
25-
orgName string
26-
blockOnPolicyViolation bool
27-
policiesAllowedHostnames []string
25+
orgName string
26+
blockOnPolicyViolation bool
27+
policiesAllowedHostnames []string
28+
preventImplicitWorkflowCreation bool
2829
)
2930

3031
cmd := &cobra.Command{
@@ -40,6 +41,10 @@ func newOrganizationUpdateCmd() *cobra.Command {
4041
opts.PoliciesAllowedHostnames = &policiesAllowedHostnames
4142
}
4243

44+
if cmd.Flags().Changed("prevent-implicit-workflow-creation") {
45+
opts.PreventImplicitWorkflowCreation = &preventImplicitWorkflowCreation
46+
}
47+
4348
_, err := action.NewOrgUpdate(ActionOpts).Run(cmd.Context(), orgName, opts)
4449
if err != nil {
4550
return err
@@ -56,5 +61,6 @@ func newOrganizationUpdateCmd() *cobra.Command {
5661

5762
cmd.Flags().BoolVar(&blockOnPolicyViolation, "block", false, "set the default policy violation blocking strategy")
5863
cmd.Flags().StringSliceVar(&policiesAllowedHostnames, "policies-allowed-hostnames", []string{}, "set the allowed hostnames for the policy engine")
64+
cmd.Flags().BoolVar(&preventImplicitWorkflowCreation, "prevent-implicit-workflow-creation", false, "prevent workflows and projects from being created implicitly during attestation init")
5965
return cmd
6066
}

app/cli/documentation/cli-reference.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2765,6 +2765,7 @@ Options
27652765
-h, --help help for update
27662766
--name string organization name
27672767
--policies-allowed-hostnames strings set the allowed hostnames for the policy engine
2768+
--prevent-implicit-workflow-creation prevent workflows and projects from being created implicitly during attestation init
27682769
```
27692770

27702771
Options inherited from parent commands

app/cli/pkg/action/config_current_context.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ func NewConfigCurrentContext(cfg *ActionsOpts) *ConfigCurrentContext {
3131
}
3232

3333
type ConfigContextItem struct {
34-
CurrentUser *UserItem
35-
CurrentMembership *MembershipItem
36-
CurrentCASBackend *CASBackendItem
34+
CurrentUser *UserItem `json:"currentUser"`
35+
CurrentMembership *MembershipItem `json:"currentMembership"`
36+
CurrentCASBackend *CASBackendItem `json:"currentCASBackend"`
3737
}
3838

3939
type UserItem struct {
40-
ID, Email, FirstName, LastName string
41-
CreatedAt *time.Time
40+
ID string `json:"id"`
41+
Email string `json:"email"`
42+
FirstName string `json:"firstName"`
43+
LastName string `json:"lastName"`
44+
CreatedAt *time.Time `json:"createdAt"`
4245
}
4346

4447
// PrintUserProfileWithEmail formats the user's profile with their email.

app/cli/pkg/action/membership_list.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,22 @@ type MembershipList struct {
2929
}
3030

3131
type OrgItem struct {
32-
ID, Name string
33-
CreatedAt *time.Time
34-
PolicyViolationBlockingStrategy string
35-
PolicyAllowedHostnames []string `json:"policyAllowedHostnames,omitempty"`
32+
ID string `json:"id"`
33+
Name string `json:"name"`
34+
CreatedAt *time.Time `json:"createdAt"`
35+
PolicyViolationBlockingStrategy string `json:"policyViolationBlockingStrategy"`
36+
PolicyAllowedHostnames []string `json:"policyAllowedHostnames,omitempty"`
37+
PreventImplicitWorkflowCreation bool `json:"preventImplicitWorkflowCreation"`
3638
}
3739

3840
type MembershipItem struct {
3941
ID string `json:"id"`
4042
Default bool `json:"current"`
4143
CreatedAt *time.Time `json:"joinedAt"`
4244
UpdatedAt *time.Time `json:"updatedAt"`
43-
Org *OrgItem
44-
User *UserItem
45-
Role Role `json:"role"`
45+
Org *OrgItem `json:"org"`
46+
User *UserItem `json:"user"`
47+
Role Role `json:"role"`
4648
}
4749

4850
type ListMembersOpts struct {
@@ -130,10 +132,11 @@ func (action *MembershipList) ListMembers(ctx context.Context, page int, pageSiz
130132

131133
func pbOrgItemToAction(in *pb.OrgItem) *OrgItem {
132134
i := &OrgItem{
133-
ID: in.Id,
134-
Name: in.Name,
135-
CreatedAt: toTimePtr(in.CreatedAt.AsTime()),
136-
PolicyAllowedHostnames: in.PolicyAllowedHostnames,
135+
ID: in.Id,
136+
Name: in.Name,
137+
CreatedAt: toTimePtr(in.CreatedAt.AsTime()),
138+
PolicyAllowedHostnames: in.PolicyAllowedHostnames,
139+
PreventImplicitWorkflowCreation: in.PreventImplicitWorkflowCreation,
137140
}
138141

139142
if in.DefaultPolicyViolationStrategy == pb.OrgItem_POLICY_VIOLATION_BLOCKING_STRATEGY_BLOCK {

app/cli/pkg/action/org_update.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ func NewOrgUpdate(cfg *ActionsOpts) *OrgUpdate {
3030
}
3131

3232
type NewOrgUpdateOpts struct {
33-
BlockOnPolicyViolation *bool
34-
PoliciesAllowedHostnames *[]string
33+
BlockOnPolicyViolation *bool
34+
PoliciesAllowedHostnames *[]string
35+
PreventImplicitWorkflowCreation *bool
3536
}
3637

3738
func (action *OrgUpdate) Run(ctx context.Context, name string, opts *NewOrgUpdateOpts) (*OrgItem, error) {
3839
client := pb.NewOrganizationServiceClient(action.cfg.CPConnection)
3940

4041
payload := &pb.OrganizationServiceUpdateRequest{
41-
Name: name,
42-
BlockOnPolicyViolation: opts.BlockOnPolicyViolation,
42+
Name: name,
43+
BlockOnPolicyViolation: opts.BlockOnPolicyViolation,
44+
PreventImplicitWorkflowCreation: opts.PreventImplicitWorkflowCreation,
4345
}
4446

4547
if opts.PoliciesAllowedHostnames != nil {

0 commit comments

Comments
 (0)