Skip to content

Commit

Permalink
Merge pull request kubearmor#643 from daemon1024/fix-crd-validation
Browse files Browse the repository at this point in the history
pkg: update path and dir validation regex
  • Loading branch information
nyrahul authored Mar 8, 2022
2 parents db1779e + 391e396 commit 0a98271
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 70 deletions.
20 changes: 10 additions & 10 deletions deployments/CRD/KubeArmorHostPolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -121,13 +121,13 @@ spec:
- Block
type: string
dir:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
pattern: ^\/$|^\/.*\/$
type: string
fromSource:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -164,7 +164,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand All @@ -173,7 +173,7 @@ spec:
ownerOnly:
type: boolean
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
readOnly:
type: boolean
Expand Down Expand Up @@ -252,7 +252,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -312,13 +312,13 @@ spec:
- Block
type: string
dir:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
pattern: ^\/$|^\/.*\/$
type: string
fromSource:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -353,7 +353,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand All @@ -362,7 +362,7 @@ spec:
ownerOnly:
type: boolean
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
severity:
maximum: 10
Expand Down
24 changes: 12 additions & 12 deletions deployments/CRD/KubeArmorPolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -119,13 +119,13 @@ spec:
- Block
type: string
dir:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
pattern: ^\/$|^\/.*\/$
type: string
fromSource:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -162,7 +162,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand All @@ -171,7 +171,7 @@ spec:
ownerOnly:
type: boolean
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
readOnly:
type: boolean
Expand Down Expand Up @@ -250,7 +250,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -302,13 +302,13 @@ spec:
- Block
type: string
dir:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
pattern: ^\/$|^\/.*\/$
type: string
fromSource:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -343,7 +343,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand All @@ -352,7 +352,7 @@ spec:
ownerOnly:
type: boolean
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
severity:
maximum: 10
Expand Down Expand Up @@ -429,12 +429,12 @@ spec:
- Block
type: string
dir:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
pattern: ^\/$|^\/.*\/$
type: string
message:
type: string
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
readOnly:
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type NodeSelectorType struct {
MatchLabels map[string]string `json:"matchLabels,omitempty"`
}

// +kubebuilder:validation:Pattern=^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
// +kubebuilder:validation:Pattern=^\/+.*[^\/]$
type MatchPathType string

// +kubebuilder:validation:Pattern=^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
// +kubebuilder:validation:Pattern=^\/$|^\/.*\/$
type MatchDirectoryType string

type MatchSourceType struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -121,13 +121,13 @@ spec:
- Block
type: string
dir:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
pattern: ^\/$|^\/.*\/$
type: string
fromSource:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -164,7 +164,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand All @@ -173,7 +173,7 @@ spec:
ownerOnly:
type: boolean
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
readOnly:
type: boolean
Expand Down Expand Up @@ -252,7 +252,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -312,13 +312,13 @@ spec:
- Block
type: string
dir:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
pattern: ^\/$|^\/.*\/$
type: string
fromSource:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -353,7 +353,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand All @@ -362,7 +362,7 @@ spec:
ownerOnly:
type: boolean
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
severity:
maximum: 10
Expand Down
20 changes: 10 additions & 10 deletions pkg/KubeArmorHostPolicy/crd/KubeArmorHostPolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -121,13 +121,13 @@ spec:
- Block
type: string
dir:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
pattern: ^\/$|^\/.*\/$
type: string
fromSource:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -164,7 +164,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand All @@ -173,7 +173,7 @@ spec:
ownerOnly:
type: boolean
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
readOnly:
type: boolean
Expand Down Expand Up @@ -252,7 +252,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -312,13 +312,13 @@ spec:
- Block
type: string
dir:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
pattern: ^\/$|^\/.*\/$
type: string
fromSource:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand Down Expand Up @@ -353,7 +353,7 @@ spec:
items:
properties:
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
type: object
type: array
Expand All @@ -362,7 +362,7 @@ spec:
ownerOnly:
type: boolean
path:
pattern: ^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
pattern: ^\/+.*[^\/]$
type: string
severity:
maximum: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type SelectorType struct {
MatchLabels map[string]string `json:"matchLabels,omitempty"`
}

// +kubebuilder:validation:Pattern=^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)$
// +kubebuilder:validation:Pattern=^\/+.*[^\/]$
type MatchPathType string

// +kubebuilder:validation:Pattern=^\/([A-z0-9-_.]+\/)*([A-z0-9-_.]+)+\/$
// +kubebuilder:validation:Pattern=^\/$|^\/.*\/$
type MatchDirectoryType string

type MatchSourceType struct {
Expand Down
Loading

0 comments on commit 0a98271

Please sign in to comment.