UpdateSecurityPolicy
client.SecurityPolicies.Update(ctx, body) (*SecurityPolicyUpdateResponse, error)
POST/gitpod.v1.SecurityService/UpdateSecurityPolicy
Updates a security policy.
Use this method to:
- Rename a security policy
- Change enforcement rules
- Update auditing behavior
Examples
-
Update security policy:
Promotes one executable rule from audit to block while leaving unmatched executables allowed. Updating an assigned policy validates materializability; updating an unassigned policy only stores its spec.
securityPolicyId: "d2c94c27-3b76-4a42-b88c-95a85e392c68" spec: executables: defaultEffect: EFFECT_ALLOW rules: - path: "npx" effect: EFFECT_BLOCK - path: "/usr/bin/curl" effect: EFFECT_BLOCK
UpdateSecurityPolicy
package main
import (
"context"
"fmt"
"github.com/gitpod-io/gitpod-sdk-go"
"github.com/gitpod-io/gitpod-sdk-go/option"
)
func main() {
client := gitpod.NewClient(
option.WithBearerToken("My Bearer Token"),
)
securityPolicy, err := client.SecurityPolicies.Update(context.TODO(), gitpod.SecurityPolicyUpdateParams{
SecurityPolicyID: gitpod.F("d2c94c27-3b76-4a42-b88c-95a85e392c68"),
Spec: gitpod.F(gitpod.SecurityPolicyUpdateParamsSpec{
Executables: gitpod.F(gitpod.SecurityPolicyUpdateParamsSpecExecutables{
DefaultEffect: gitpod.F(gitpod.SecurityPolicyUpdateParamsSpecExecutablesDefaultEffectEffectAllow),
Rules: gitpod.F([]gitpod.SecurityPolicyUpdateParamsSpecExecutablesRule{gitpod.SecurityPolicyUpdateParamsSpecExecutablesRule{
Effect: gitpod.F(gitpod.SecurityPolicyUpdateParamsSpecExecutablesRulesEffectEffectBlock),
Path: gitpod.F("npx"),
}, gitpod.SecurityPolicyUpdateParamsSpecExecutablesRule{
Effect: gitpod.F(gitpod.SecurityPolicyUpdateParamsSpecExecutablesRulesEffectEffectBlock),
Path: gitpod.F("/usr/bin/curl"),
}}),
}),
}),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", securityPolicy.SecurityPolicy)
}
{
"securityPolicy": {
"metadata": {
"name": "x"
},
"spec": {
"blockDevices": {
"defaultEffect": "EFFECT_UNSPECIFIED"
},
"data": {
"defaultEffect": "EFFECT_UNSPECIFIED",
"rules": [
{
"destination": {
"host": "host"
},
"effect": "EFFECT_UNSPECIFIED",
"source": {
"file": "file",
"integration": "integration",
"selector": "selector"
}
}
]
},
"executables": {
"defaultEffect": "EFFECT_UNSPECIFIED",
"rules": [
{
"effect": "EFFECT_UNSPECIFIED",
"path": "path"
}
]
},
"files": {
"defaultActions": [
"ACTION_UNSPECIFIED"
],
"defaultEffect": "EFFECT_UNSPECIFIED",
"rules": [
{
"actions": [
"ACTION_UNSPECIFIED"
],
"effect": "EFFECT_UNSPECIFIED",
"path": "path"
}
]
},
"ports": {
"maxAdmissionLevel": "ADMISSION_LEVEL_UNSPECIFIED"
}
},
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"createdAt": "2019-12-27T18:11:19.117Z",
"organizationId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"updatedAt": "2019-12-27T18:11:19.117Z"
}
}Returns Examples
{
"securityPolicy": {
"metadata": {
"name": "x"
},
"spec": {
"blockDevices": {
"defaultEffect": "EFFECT_UNSPECIFIED"
},
"data": {
"defaultEffect": "EFFECT_UNSPECIFIED",
"rules": [
{
"destination": {
"host": "host"
},
"effect": "EFFECT_UNSPECIFIED",
"source": {
"file": "file",
"integration": "integration",
"selector": "selector"
}
}
]
},
"executables": {
"defaultEffect": "EFFECT_UNSPECIFIED",
"rules": [
{
"effect": "EFFECT_UNSPECIFIED",
"path": "path"
}
]
},
"files": {
"defaultActions": [
"ACTION_UNSPECIFIED"
],
"defaultEffect": "EFFECT_UNSPECIFIED",
"rules": [
{
"actions": [
"ACTION_UNSPECIFIED"
],
"effect": "EFFECT_UNSPECIFIED",
"path": "path"
}
]
},
"ports": {
"maxAdmissionLevel": "ADMISSION_LEVEL_UNSPECIFIED"
}
},
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"createdAt": "2019-12-27T18:11:19.117Z",
"organizationId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"updatedAt": "2019-12-27T18:11:19.117Z"
}
}