Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 45915ae

Browse files
committed
Add initial implementation of the hosts target type
1 parent ff6b1fd commit 45915ae

16 files changed

+750
-0
lines changed

operator/PROJECT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ resources:
1717
- group: execution
1818
kind: ScheduledScan
1919
version: v1
20+
- group: targets
21+
kind: Host
22+
version: v1
2023
version: "2"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2020 iteratec GmbH.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1 contains API Schema definitions for the targets v1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=targets.experimental.securecodebox.io
20+
package v1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects
29+
GroupVersion = schema.GroupVersion{Group: "targets.experimental.securecodebox.io", Version: "v1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
Copyright 2020 iteratec GmbH.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
executionv1 "github.com/secureCodeBox/secureCodeBox-v2-alpha/apis/execution/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
25+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
26+
27+
// HostSpec defines the desired state of Host
28+
type HostSpec struct {
29+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
30+
// Important: Run "make" to regenerate code after modifying this file
31+
32+
// Hostname contains the dns name of the host
33+
// TODO: Add an IPAddress Field
34+
Hostname string `json:"hostname"`
35+
36+
Ports []HostPort `json:"ports"`
37+
}
38+
39+
// HostPort describes a Port of a Host
40+
type HostPort struct {
41+
Type string `json:"type"`
42+
// The port number
43+
// +kubebuilder:validation:Minimum=0
44+
// +kubebuilder:validation:Maximun=65536
45+
Port int32 `json:"port" protobuf:"varint,2,opt,name=port"`
46+
}
47+
48+
// HostStatus defines the observed state of Host
49+
type HostStatus struct {
50+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
51+
// Important: Run "make" to regenerate code after modifying this file
52+
53+
Findings executionv1.FindingStats `json:"findings,omitempty"`
54+
}
55+
56+
// +kubebuilder:object:root=true
57+
// +kubebuilder:subresource:status
58+
// +kubebuilder:printcolumn:name="Hostname",type=string,JSONPath=`.spec.hostname`
59+
// +kubebuilder:printcolumn:name="Ports",type=string,JSONPath=`.spec.ports`,description="Ports of the Host"
60+
// +kubebuilder:printcolumn:name="Findings",type=string,JSONPath=`.status.findings.count`,description="Total Finding Count"
61+
62+
// Host is the Schema for the hosts API
63+
type Host struct {
64+
metav1.TypeMeta `json:",inline"`
65+
metav1.ObjectMeta `json:"metadata,omitempty"`
66+
67+
Spec HostSpec `json:"spec,omitempty"`
68+
Status HostStatus `json:"status,omitempty"`
69+
}
70+
71+
// +kubebuilder:object:root=true
72+
73+
// HostList contains a list of Host
74+
type HostList struct {
75+
metav1.TypeMeta `json:",inline"`
76+
metav1.ListMeta `json:"metadata,omitempty"`
77+
Items []Host `json:"items"`
78+
}
79+
80+
func init() {
81+
SchemeBuilder.Register(&Host{}, &HostList{})
82+
}

operator/apis/targets/v1/zz_generated.deepcopy.go

Lines changed: 135 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1beta1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.2.5
8+
creationTimestamp: null
9+
name: hosts.targets.experimental.securecodebox.io
10+
spec:
11+
additionalPrinterColumns:
12+
- JSONPath: .spec.hostname
13+
name: Hostname
14+
type: string
15+
- JSONPath: .spec.ports
16+
description: Ports of the Host
17+
name: Ports
18+
type: string
19+
- JSONPath: .status.findings.count
20+
description: Total Finding Count
21+
name: Findings
22+
type: string
23+
group: targets.experimental.securecodebox.io
24+
names:
25+
kind: Host
26+
listKind: HostList
27+
plural: hosts
28+
singular: host
29+
scope: Namespaced
30+
subresources:
31+
status: {}
32+
validation:
33+
openAPIV3Schema:
34+
description: Host is the Schema for the hosts API
35+
properties:
36+
apiVersion:
37+
description: 'APIVersion defines the versioned schema of this representation
38+
of an object. Servers should convert recognized schemas to the latest
39+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
40+
type: string
41+
kind:
42+
description: 'Kind is a string value representing the REST resource this
43+
object represents. Servers may infer this from the endpoint the client
44+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
45+
type: string
46+
metadata:
47+
type: object
48+
spec:
49+
description: HostSpec defines the desired state of Host
50+
properties:
51+
hostname:
52+
description: 'Hostname contains the dns name of the host TODO: Add an
53+
IPAddress Field'
54+
type: string
55+
ports:
56+
items:
57+
description: HostPort describes a Port of a Host
58+
properties:
59+
port:
60+
description: The port number
61+
format: int32
62+
minimum: 0
63+
type: integer
64+
type:
65+
type: string
66+
required:
67+
- port
68+
- type
69+
type: object
70+
type: array
71+
required:
72+
- hostname
73+
- ports
74+
type: object
75+
status:
76+
description: HostStatus defines the observed state of Host
77+
properties:
78+
findings:
79+
description: FindingStats contains the general stats about the results
80+
of the scan
81+
properties:
82+
categories:
83+
additionalProperties:
84+
format: int64
85+
type: integer
86+
description: FindingCategories indicates the count of finding broken
87+
down by their categories
88+
type: object
89+
count:
90+
description: Count indicates how many findings were identified in
91+
total
92+
format: int64
93+
type: integer
94+
severities:
95+
description: FindingSeverities indicates the count of finding with
96+
the respective severity
97+
properties:
98+
high:
99+
format: int64
100+
type: integer
101+
informational:
102+
format: int64
103+
type: integer
104+
low:
105+
format: int64
106+
type: integer
107+
medium:
108+
format: int64
109+
type: integer
110+
type: object
111+
type: object
112+
type: object
113+
type: object
114+
version: v1
115+
versions:
116+
- name: v1
117+
served: true
118+
storage: true
119+
status:
120+
acceptedNames:
121+
kind: ""
122+
plural: ""
123+
conditions: []
124+
storedVersions: []

0 commit comments

Comments
 (0)