Skip to content

Commit 30f0622

Browse files
authored
Merge pull request #759 from jmpsec/fix-cicd-single-yaml
Adapt creation of deb packages to single YAML configuration
2 parents 40f2fed + 60bf592 commit 30f0622

File tree

6 files changed

+409
-57
lines changed

6 files changed

+409
-57
lines changed

deploy/cicd/deb/deb-conffiles

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/opt/osctrl/config/{{ OSCTRL_COMPONENT }}.json
1+
/opt/osctrl/config/{{ OSCTRL_COMPONENT }}.yml
22
/etc/systemd/system/osctrl-{{ OSCTRL_COMPONENT }}.service

deploy/cicd/deb/generate-deb-package.sh

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,9 @@ cp deploy/cicd/deb/deb-conffiles "${DEB_DIR}/DEBIAN/conffiles" && \
3434
sed -i "s#{{ OSCTRL_COMPONENT }}#${OSCTRL_COMPONENT}#g" "${DEB_DIR}/DEBIAN/conffiles"
3535

3636

37-
# Example configs
38-
cp deploy/config/db.json "${DEB_DIR}/tmp/osctrl-${OSCTRL_COMPONENT}/db.json.example" && \
39-
chmod 640 "${DEB_DIR}/tmp/osctrl-${OSCTRL_COMPONENT}/db.json.example"
40-
41-
cp deploy/config/redis.json "${DEB_DIR}/tmp/osctrl-${OSCTRL_COMPONENT}/redis.json.example" && \
42-
chmod 640 "${DEB_DIR}/tmp/osctrl-${OSCTRL_COMPONENT}/redis.json.example"
37+
# Example configuration
38+
cp deploy/config/${OSCTRL_COMPONENT}.yml "${DEB_DIR}/tmp/osctrl-${OSCTRL_COMPONENT}/${OSCTRL_COMPONENT}.yml.example" && \
39+
chmod 640 "${DEB_DIR}/tmp/osctrl-${OSCTRL_COMPONENT}/${OSCTRL_COMPONENT}.yml.example"
4340

4441

4542
# General components content
@@ -52,31 +49,7 @@ cp deploy/config/service.json "${DEB_DIR}/opt/osctrl/config/${OSCTRL_COMPONENT}.
5249
# Generate systemd config file
5350
EXECSTART="/opt/osctrl/bin/osctrl-${OSCTRL_COMPONENT} \\
5451
--config \\
55-
--config-file /opt/osctrl/config/${OSCTRL_COMPONENT}.json \\
56-
--redis \\
57-
--redis-file /opt/osctrl/config/redis.json \\
58-
--db \\
59-
--db-file /opt/osctrl/config/db.json"
60-
61-
if [ "$OSCTRL_COMPONENT" == "admin" ]
62-
then
63-
ADMIN_ARGS=" \\
64-
--jwt \\
65-
--jwt-file /opt/osctrl/config/jwt.json \\
66-
--carved /opt/osctrl/carves \\
67-
--templates /opt/osctrl/tmpl_admin \\
68-
--static /opt/osctrl/static \\
69-
--osquery-tables /opt/osctrl/data/osquery-${OSQUERY_VERSION}.json"
70-
EXECSTART+=${ADMIN_ARGS}
71-
fi
72-
73-
if [ "$OSCTRL_COMPONENT" == "api" ]
74-
then
75-
API_ARGS=" \\
76-
--jwt \\
77-
--jwt-file /opt/osctrl/config/jwt.json"
78-
EXECSTART+=${API_ARGS}
79-
fi
52+
--config-file /opt/osctrl/config/${OSCTRL_COMPONENT}.yml"
8053

8154
cat > "${DEB_DIR}/etc/systemd/system/osctrl-${OSCTRL_COMPONENT}.service" << EOF
8255
[Unit]
@@ -116,29 +89,14 @@ then
11689
mkdir -p "${DEB_DIR}/opt/osctrl/static"
11790
mkdir -p "${DEB_DIR}/opt/osctrl/tmpl_admin"
11891

119-
# Copy configs
120-
cp deploy/config/jwt.json "${DEB_DIR}/opt/osctrl/config/jwt.json" && \
121-
chmod 640 "${DEB_DIR}/opt/osctrl/config/jwt.json"
122-
123-
# Copy Osctrl-admin web assets
92+
# Copy osctrl-admin web assets
12493
cp -r cmd/admin/templates "${DEB_DIR}/opt/osctrl/tmpl_admin"
12594
cp -r cmd/admin/static "${DEB_DIR}/opt/osctrl/static"
12695

12796
# Copy osquery schema
12897
cp deploy/osquery/data/${OSQUERY_VERSION}.json "${DEB_DIR}/opt/osctrl/data/osquery-${OSQUERY_VERSION}.json"
12998

13099
# Define conffiles
131-
echo "/opt/osctrl/config/jwt.json" >> "${DEB_DIR}/DEBIAN/conffiles"
132100
echo "/opt/osctrl/data/osquery-${OSQUERY_VERSION}.json" >> "${DEB_DIR}/DEBIAN/conffiles"
133101

134102
fi
135-
136-
if [ "$OSCTRL_COMPONENT" == "api" ]
137-
then
138-
# Copy configs
139-
cp deploy/config/jwt.json "${DEB_DIR}/opt/osctrl/config/jwt.json" && \
140-
chmod 640 "${DEB_DIR}/opt/osctrl/config/jwt.json"
141-
142-
# Define conffiles
143-
echo "/opt/osctrl/config/jwt.json" >> "${DEB_DIR}/DEBIAN/conffiles"
144-
fi

deploy/cicd/deb/pre-install.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,13 @@ then
2828
chown root:osctrl -R /opt/osctrl/config
2929
fi
3030

31-
################### Copy needed configs ###################
32-
if [ ! -f /opt/osctrl/config/db.json ]
31+
################### Copy needed configuration ###################
32+
if [ ! -f /opt/osctrl/config/{{ OSCTRL_COMPONENT }}.yml ]
3333
then
34-
cp /tmp/osctrl-{{ OSCTRL_COMPONENT }}/db.json.example /opt/osctrl/config/db.json
35-
chown root:root /opt/osctrl/config/db.json.example
34+
cp /tmp/osctrl-{{ OSCTRL_COMPONENT }}/{{ OSCTRL_COMPONENT }}.yml.example /opt/osctrl/config/{{ OSCTRL_COMPONENT }}.yml
35+
chown root:root /opt/osctrl/config/{{ OSCTRL_COMPONENT }}.yml
3636
fi
3737

38-
if [ ! -f /opt/osctrl/config/redis.json ]
39-
then
40-
cp /tmp/osctrl-{{ OSCTRL_COMPONENT }}/redis.json.example /opt/osctrl/config/redis.json
41-
chown root:root /opt/osctrl/config/redis.json.example
42-
fi
4338
rm -rd /tmp/osctrl-{{ OSCTRL_COMPONENT }}
4439

4540
################### osctrl-admin web assets ###################

deploy/config/admin.yml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# YAML configuration for osctrl-admin
2+
3+
service:
4+
listener: 0.0.0.0
5+
port: 9000
6+
# Valid values: "debug", "info", "warn", "error"
7+
logLevel: info
8+
# Valid values: "json", "console"
9+
logFormat: json
10+
host: 0.0.0.0
11+
# Valid values: "none", "json", "db", "saml", "oidc", "oauth"
12+
auth: none
13+
auditLog: false
14+
15+
# Database configuration
16+
db:
17+
type: postgres
18+
host: 127.0.0.1
19+
port: 5432
20+
name: osctrl
21+
username: postgres
22+
password: postgres
23+
sslmode: disable
24+
maxIdleConns: 20
25+
maxOpenConns: 100
26+
connMaxLifetime: 30
27+
connRetry: 10
28+
filePath: ./osctrl.db
29+
30+
# Redis cache configuration
31+
redis:
32+
host: 127.0.0.1
33+
port: 6379
34+
password: ""
35+
connectionString: ""
36+
db: 0
37+
connRetry: 10
38+
39+
# Osquery nodes configuration
40+
osquery:
41+
version: 5.20.0
42+
tablesFile: data/5.20.0.json
43+
logger: true
44+
config: true
45+
query: true
46+
carve: true
47+
48+
# Osctrl daemon configuration
49+
osctrld:
50+
enabled: false
51+
52+
# SAML authentication configuration
53+
saml:
54+
certPath: ""
55+
keyPath: ""
56+
metadataUrl: ""
57+
rootUrl: ""
58+
loginUrl: ""
59+
logoutUrl: ""
60+
jitProvision: false
61+
spInitiated: false
62+
63+
# JWT authentication configuration
64+
jwt:
65+
jwtSecret: ""
66+
hoursToExpire: 3
67+
68+
# TLS termination configuration
69+
tls:
70+
termination: false
71+
certificateFile: config/tls.crt
72+
keyFile: config/tls.key
73+
74+
# Logger configuration to handle received logs from osquery nodes
75+
logger:
76+
# Valid values: "none", "stdout", "file", "db", "graylog", "splunk", "logstash", "kinesis", "s3", "kafka", "elastic"
77+
type: db
78+
loggerDBSame: false
79+
alwaysLog: false
80+
db:
81+
type: ""
82+
host: ""
83+
port: 0
84+
name: ""
85+
username: ""
86+
password: ""
87+
sslmode: ""
88+
maxIdleConns: 0
89+
maxOpenConns: 0
90+
connMaxLifetime: 0
91+
connRetry: 0
92+
filePath: ""
93+
s3:
94+
bucket: ""
95+
region: ""
96+
accessKey: ""
97+
secretAccessKey: ""
98+
graylog:
99+
url: ""
100+
host: ""
101+
queries: ""
102+
status: ""
103+
results: ""
104+
elastic:
105+
host: ""
106+
port: ""
107+
indexPrefix: ""
108+
dateSeparator: ""
109+
indexSeparator: ""
110+
splunk:
111+
url: ""
112+
token: ""
113+
host: ""
114+
index: ""
115+
logstash:
116+
host: ""
117+
port: ""
118+
protocol: ""
119+
path: ""
120+
kinesis:
121+
stream: ""
122+
region: ""
123+
endpoint: ""
124+
accessKey: ""
125+
secretKey: ""
126+
sessionToken: ""
127+
kafka:
128+
bootstrapServers: ""
129+
sslCALocation: ""
130+
connectionTimeout: 0s
131+
sasl:
132+
mechanism: ""
133+
username: ""
134+
password: ""
135+
topic: ""
136+
local:
137+
filePath: ""
138+
maxSize: 0
139+
maxBackups: 0
140+
maxAge: 0
141+
compress: false
142+
143+
# Carver configuration to handle file carves from osquery nodes
144+
carver:
145+
# Valid values: "none", "local", "db", "s3"
146+
type: db
147+
s3:
148+
bucket: ""
149+
region: ""
150+
accessKey: ""
151+
secretAccessKey: ""
152+
local:
153+
carvesDir: ./carved_files/
154+
155+
admin:
156+
sessionKey: ""
157+
staticDir: ./static
158+
keyFile: false
159+
templatesDir: ./tmpl_admin
160+
brandingImage: ./static/img/brand.png
161+
backgroundImage: ./static/img/circuit.svg
162+
163+
# Debug configuration
164+
debug:
165+
enableHttp: false
166+
httpFile: debug-http-admin.log
167+
showBody: false

deploy/config/api.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# YAML configuration for osctrl-api
2+
3+
service:
4+
listener: 0.0.0.0
5+
port: 9000
6+
# Valid values: "debug", "info", "warn", "error"
7+
logLevel: info
8+
# Valid values: "json", "console"
9+
logFormat: json
10+
host: 0.0.0.0
11+
auth: none
12+
auditLog: false
13+
14+
# Database configuration
15+
db:
16+
type: postgres
17+
host: 127.0.0.1
18+
port: 5432
19+
name: osctrl
20+
username: postgres
21+
password: postgres
22+
sslmode: disable
23+
maxIdleConns: 20
24+
maxOpenConns: 100
25+
connMaxLifetime: 30
26+
connRetry: 10
27+
filePath: ./osctrl.db
28+
29+
# Redis cache configuration
30+
redis:
31+
host: 127.0.0.1
32+
port: 6379
33+
password: ""
34+
connectionString: ""
35+
db: 0
36+
connRetry: 10
37+
38+
# Osquery nodes configuration
39+
osquery:
40+
version: 5.20.0
41+
tablesFile: data/5.20.0.json
42+
logger: true
43+
config: true
44+
query: true
45+
carve: true
46+
47+
# JWT authentication configuration
48+
jwt:
49+
jwtSecret: ""
50+
hoursToExpire: 3
51+
52+
# TLS termination configuration
53+
tls:
54+
termination: false
55+
certificateFile: config/tls.crt
56+
keyFile: config/tls.key
57+
58+
# Logger configuration to handle received logs from osquery nodes
59+
logger:
60+
type: db
61+
loggerDBSame: false
62+
alwaysLog: false
63+
db: null
64+
s3: null
65+
graylog: null
66+
elastic: null
67+
splunk: null
68+
logstash: null
69+
kinesis: null
70+
kafka: null
71+
local: null
72+
73+
# Debug configuration
74+
debug:
75+
enableHttp: false
76+
httpFile: debug-http-api.log
77+
showBody: false

0 commit comments

Comments
 (0)