From 2e404f64075f2d6cc56385d29dc80ad3d706f029 Mon Sep 17 00:00:00 2001 From: Anthony Gomez Date: Mon, 26 Oct 2026 10:58:37 -0400 Subject: [PATCH 1/3] feat(ngwaf): add autoEnableNewVirtualPatches workspace flag (CDTOOL-1858) Upgrade go-fastly to v18.1.0 and expose the new auto_enable_new_virtual_patches workspace setting via 'ngwaf workspace create' and 'ngwaf workspace update', and show it in 'ngwaf workspace get'. --- CHANGELOG.md | 3 +++ go.mod | 2 +- go.sum | 4 ++-- pkg/commands/ngwaf/workspace/create.go | 15 ++++++++----- pkg/commands/ngwaf/workspace/update.go | 21 ++++++++++++------- .../ngwaf/workspace/workspace_test.go | 14 +++++++++++++ pkg/text/workspace.go | 3 +++ 7 files changed, 46 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 514ae5ae1..9c404088b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,10 @@ ### Enhancements: +- feat(ngwaf): add `--autoEnableNewVirtualPatches` flag to `ngwaf workspace create` and `ngwaf workspace update` for Automated Virtual Patching, and show it in `ngwaf workspace get` + ### Dependencies: +- build(deps): `github.com/fastly/go-fastly` from v18.0.0 to v18.1.0 - build(deps): `github.com/fastly/go-fastly` from v17.8.0 to v18.0.0 ([#1949](https://github.com/fastly/cli/pull/1949)) - build(deps): `golang.org/x/term` from 0.46.0 to 0.47.0 ([#1944](https://github.com/fastly/cli/pull/1944)) - build(deps): `golang.org/x/crypto` from 0.57.0 to 0.58.0 ([#1944](https://github.com/fastly/cli/pull/1944)) diff --git a/go.mod b/go.mod index a0302baad..ed7debd98 100644 --- a/go.mod +++ b/go.mod @@ -85,7 +85,7 @@ require ( require ( 4d63.com/optional v0.2.0 github.com/creack/pty v1.1.24 - github.com/fastly/go-fastly/v18 v18.0.0 + github.com/fastly/go-fastly/v18 v18.1.0 github.com/mholt/archives v0.1.5 github.com/mitchellh/go-ps v1.0.0 ) diff --git a/go.sum b/go.sum index 5cc3ca3cc..28630b5fd 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,8 @@ github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707/go.mod h1:qssHWj6 github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 h1:aYo8nnk3ojoQkP5iErif5Xxv0Mo0Ga/FR5+ffl/7+Nk= github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0/go.mod h1:8AuBTZBRSFqEYBPYULd+NN474/zZBLP+6WeT5S9xlAc= -github.com/fastly/go-fastly/v18 v18.0.0 h1:M0EYF2yjLQevJIIIYqOx6zGSVZT8C6O3STShJ1Hz1Hw= -github.com/fastly/go-fastly/v18 v18.0.0/go.mod h1:xjf9UnxLNKSGA92dVlR9fH+2fUt0QBv61dPr0kwFwyw= +github.com/fastly/go-fastly/v18 v18.1.0 h1:2r+WfcmJtNnqckILaIPbksOQyhjQ55EPNX9SrUR6vDM= +github.com/fastly/go-fastly/v18 v18.1.0/go.mod h1:xjf9UnxLNKSGA92dVlR9fH+2fUt0QBv61dPr0kwFwyw= github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible h1:FhrXlfhgGCS+uc6YwyiFUt04alnjpoX7vgDKJxS6Qbk= github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible/go.mod h1:U8UynVoU1SQaqD2I4ZqgYd5lx3A1ipQYn4aSt2Y5h6c= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= diff --git a/pkg/commands/ngwaf/workspace/create.go b/pkg/commands/ngwaf/workspace/create.go index f177a58fe..78b4dbb50 100644 --- a/pkg/commands/ngwaf/workspace/create.go +++ b/pkg/commands/ngwaf/workspace/create.go @@ -27,11 +27,12 @@ type CreateCommand struct { name string // Optional. - attackThresholds argparser.OptionalString - defaultBlockingCode argparser.OptionalInt - defaultRedirectURL argparser.OptionalString - clientIPHeaders argparser.OptionalString - ipAnonymization argparser.OptionalString + attackThresholds argparser.OptionalString + defaultBlockingCode argparser.OptionalInt + defaultRedirectURL argparser.OptionalString + clientIPHeaders argparser.OptionalString + ipAnonymization argparser.OptionalString + autoEnableVirtualPatches argparser.OptionalBool } // NewCreateCommand returns a usable command registered under the parent. @@ -54,6 +55,7 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman c.CmdClause.Flag("defaultBlockingCode", "Default status code that is returned when a request to your web application is blocked.").Action(c.defaultBlockingCode.Set).IntVar(&c.defaultBlockingCode.Value) c.CmdClause.Flag("defaultRedirectURL", "Redirect url to be used if code 301 or 302 is used.").Action(c.defaultRedirectURL.Set).StringVar(&c.defaultRedirectURL.Value) c.CmdClause.Flag("ipAnonymization", "Agents will anonymize IP addresses according to the option selected.").Action(c.ipAnonymization.Set).StringVar(&c.ipAnonymization.Value) + c.CmdClause.Flag("autoEnableNewVirtualPatches", "Automatically enable, in block mode, virtual patches released after this setting is enabled. Virtual patches released before it was enabled are not changed. Use --no-autoEnableNewVirtualPatches to disable.").Action(c.autoEnableVirtualPatches.Set).BoolVar(&c.autoEnableVirtualPatches.Value) c.RegisterFlagBool(c.JSONFlag()) return &c @@ -88,6 +90,9 @@ func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { if c.ipAnonymization.WasSet { input.IPAnonymization = &c.ipAnonymization.Value } + if c.autoEnableVirtualPatches.WasSet { + input.AutoEnableNewVirtualPatches = &c.autoEnableVirtualPatches.Value + } fc, ok := c.Globals.APIClient.(*fastly.Client) if !ok { diff --git a/pkg/commands/ngwaf/workspace/update.go b/pkg/commands/ngwaf/workspace/update.go index 46d25d8c8..19f8ea7c2 100644 --- a/pkg/commands/ngwaf/workspace/update.go +++ b/pkg/commands/ngwaf/workspace/update.go @@ -25,14 +25,15 @@ type UpdateCommand struct { workspaceID string // Optional. - description argparser.OptionalString - blockingMode argparser.OptionalString - name argparser.OptionalString - attackThresholds argparser.OptionalString - defaultBlockingCode argparser.OptionalInt - defaultRedirectURL argparser.OptionalString - clientIPHeaders argparser.OptionalString - ipAnonymization argparser.OptionalString + description argparser.OptionalString + blockingMode argparser.OptionalString + name argparser.OptionalString + attackThresholds argparser.OptionalString + defaultBlockingCode argparser.OptionalInt + defaultRedirectURL argparser.OptionalString + clientIPHeaders argparser.OptionalString + ipAnonymization argparser.OptionalString + autoEnableVirtualPatches argparser.OptionalBool } // NewUpdateCommand returns a usable command registered under the parent. @@ -56,6 +57,7 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman c.CmdClause.Flag("defaultBlockingCode", "Default status code that is returned when a request to your web application is blocked.").Action(c.defaultBlockingCode.Set).IntVar(&c.defaultBlockingCode.Value) c.CmdClause.Flag("defaultRedirectURL", "Redirect url to be used if code 301 or 302 is used.").Action(c.defaultRedirectURL.Set).StringVar(&c.defaultRedirectURL.Value) c.CmdClause.Flag("ipAnonymization", "Agents will anonymize IP addresses according to the option selected.").Action(c.ipAnonymization.Set).StringVar(&c.ipAnonymization.Value) + c.CmdClause.Flag("autoEnableNewVirtualPatches", "Automatically enable, in block mode, virtual patches released after this setting is enabled. Virtual patches released before it was enabled are not changed. Use --no-autoEnableNewVirtualPatches to disable.").Action(c.autoEnableVirtualPatches.Set).BoolVar(&c.autoEnableVirtualPatches.Value) c.RegisterFlagBool(c.JSONFlag()) return &c @@ -99,6 +101,9 @@ func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { if c.ipAnonymization.WasSet { input.IPAnonymization = &c.ipAnonymization.Value } + if c.autoEnableVirtualPatches.WasSet { + input.AutoEnableNewVirtualPatches = &c.autoEnableVirtualPatches.Value + } fc, ok := c.Globals.APIClient.(*fastly.Client) if !ok { diff --git a/pkg/commands/ngwaf/workspace/workspace_test.go b/pkg/commands/ngwaf/workspace/workspace_test.go index 8c84f707d..1835c78fb 100644 --- a/pkg/commands/ngwaf/workspace/workspace_test.go +++ b/pkg/commands/ngwaf/workspace/workspace_test.go @@ -82,6 +82,20 @@ func TestWorkspacesCreate(t *testing.T) { }, WantOutput: fstfmt.Success("Created workspace '%s' (workspace-id: %s)", workspaceName, workspaceID), }, + { + Name: "validate --autoEnableNewVirtualPatches flag", + Args: fmt.Sprintf("--description %s --name %s --blockingMode %s --autoEnableNewVirtualPatches", workspaceDescription, workspaceName, workspaceMode), + Client: &http.Client{ + Transport: &testutil.MockRoundTripper{ + Response: &http.Response{ + StatusCode: http.StatusOK, + Status: http.StatusText(http.StatusOK), + Body: io.NopCloser(bytes.NewReader(testutil.GenJSON(workspace))), + }, + }, + }, + WantOutput: fstfmt.Success("Created workspace '%s' (workspace-id: %s)", workspaceName, workspaceID), + }, { Name: "validate optional --json flag", Args: fmt.Sprintf("--description %s --name %s --blockingMode %s --clientIPHeaders %s --json", workspaceDescription, workspaceName, workspaceMode, workspaceClientIPHeaders), diff --git a/pkg/text/workspace.go b/pkg/text/workspace.go index b672b14f1..d6c03d4d0 100644 --- a/pkg/text/workspace.go +++ b/pkg/text/workspace.go @@ -32,6 +32,9 @@ func PrintWorkspace(out io.Writer, workspaceToPrint *workspaces.Workspace) { if workspaceToPrint.IPAnonymization != "" { fmt.Fprintf(out, "IP Anonymization: %s\n", workspaceToPrint.IPAnonymization) } + if workspaceToPrint.AutoEnableNewVirtualPatches != nil { + fmt.Fprintf(out, "Auto Enable New Virtual Patches: %t\n", *workspaceToPrint.AutoEnableNewVirtualPatches) + } fmt.Fprintf(out, "Updated (UTC): %s\n", workspaceToPrint.UpdatedAt.UTC().Format(time.Format)) } From 1bf19cc0b0b3caf0b5ade8d029a81042808f7aa4 Mon Sep 17 00:00:00 2001 From: Anthony Gomez Date: Mon, 26 Oct 2026 11:00:01 -0400 Subject: [PATCH 2/3] add PR number --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c404088b..e8b207c0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,10 +13,10 @@ ### Enhancements: -- feat(ngwaf): add `--autoEnableNewVirtualPatches` flag to `ngwaf workspace create` and `ngwaf workspace update` for Automated Virtual Patching, and show it in `ngwaf workspace get` +- feat(ngwaf): add `--autoEnableNewVirtualPatches` flag to `ngwaf workspace create` and `ngwaf workspace update` for Automated Virtual Patching, and show it in `ngwaf workspace get` ([#1953](https://github.com/fastly/cli/pull/1953)) ### Dependencies: -- build(deps): `github.com/fastly/go-fastly` from v18.0.0 to v18.1.0 +- build(deps): `github.com/fastly/go-fastly` from v18.0.0 to v18.1.0 ([#1953](https://github.com/fastly/cli/pull/1953)) - build(deps): `github.com/fastly/go-fastly` from v17.8.0 to v18.0.0 ([#1949](https://github.com/fastly/cli/pull/1949)) - build(deps): `golang.org/x/term` from 0.46.0 to 0.47.0 ([#1944](https://github.com/fastly/cli/pull/1944)) - build(deps): `golang.org/x/crypto` from 0.57.0 to 0.58.0 ([#1944](https://github.com/fastly/cli/pull/1944)) From 294150abff5a025881050fda6f2efc6b45a4c0f1 Mon Sep 17 00:00:00 2001 From: Anthony Gomez Date: Mon, 26 Oct 2026 11:13:10 -0400 Subject: [PATCH 3/3] fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a86ddd0a4..0bf2e239c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ - feat(ngwaf): add `--autoEnableNewVirtualPatches` flag to `ngwaf workspace create` and `ngwaf workspace update` for Automated Virtual Patching, and show it in `ngwaf workspace get` ([#1953](https://github.com/fastly/cli/pull/1953)) ### Dependencies: -- build(deps): `github.com/fastly/go-fastly` from v18.0.0 to v18.1.0 ([#1953](https://github.com/fastly/cli/pull/1953)) + - build(deps): `github.com/fastly/go-fastly` from v17.8.0 to v18.0.0 ([#1949](https://github.com/fastly/cli/pull/1949)) - build(deps): `golang.org/x/term` from 0.46.0 to 0.47.0 ([#1944](https://github.com/fastly/cli/pull/1944)) - build(deps): `golang.org/x/crypto` from 0.57.0 to 0.58.0 ([#1944](https://github.com/fastly/cli/pull/1944))