-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insecure connection handling #38
Changes from 16 commits
231869d
2bf42db
36caeb6
960501f
86c4ba6
f860e05
624d711
88a5071
e0a0a45
125ea6a
2b19016
8f787f9
e64086e
bdea86e
56517ae
8931a58
102e238
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,9 @@ FROM alpine:latest | |
|
||
RUN apk --update add jq curl | ||
COPY entrypoint.sh . | ||
COPY curl_command.sh . | ||
|
||
# Grant execute permissions to the scripts | ||
RUN chmod +x entrypoint.sh curl_command.sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this RUN step. chmod +x entrypoint.sh curl_command.sh
git add entrypoint.sh curl_command.sh |
||
|
||
ENTRYPOINT ["/bin/sh", "entrypoint.sh"] |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove binary file |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ spec: | |
containers: | ||
- image: accuknox/accuknox-job:latest | ||
command: ["/bin/sh", "-c"] | ||
args: ['/bin/sh entrypoint.sh && curl --location --request POST "https://${URL}/api/v1/artifact/?tenant_id=${TENANT_ID}&data_type=KB&label_id=${LABEL_NAME}&save_to_s3=true" --header "Tenant-Id: ${TENANT_ID}" --header "Authorization: Bearer ${AUTH_TOKEN}" --form "file=@\"./data/report.json\"" && cat /data/report.json'] | ||
args: ['/bin/sh entrypoint.sh && ./curl_command.sh'] | ||
name: cis-k8s-cronjob | ||
resources: {} | ||
env: | ||
|
@@ -24,11 +24,19 @@ spec: | |
- name: LABEL_NAME | ||
value: {{ .Values.accuknox.label }} | ||
- name: CLUSTER_ID | ||
value: {{ .Values.accuknox.clusterId }} | ||
value: {{ .Values.accuknox.clusterID }} | ||
- name: TENANT_ID | ||
value: {{ .Values.accuknox.tenantId | quote}} | ||
value: {{ .Values.accuknox.tenantID | quote}} | ||
- name: URL | ||
value: {{ .Values.accuknox.url }} | ||
value: {{ .Values.accuknox.URL }} | ||
Comment on lines
-44
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix values. |
||
- name: CERT_BUNDLE_PATH | ||
value: {{ .Values.accuknox.certBundlePath | quote }} | ||
- name: CERT_BUNDLE_URL | ||
value: {{ .Values.accuknox.certBundleURL }} | ||
- name: USE_INSECURE_CONNECTION | ||
value: {{ .Values.accuknox.useInsecureConnection | quote }} | ||
- name: DATA_TYPE | ||
value: "KB" | ||
volumeMounts: | ||
- mountPath: /data | ||
name: datapath | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
# Initialize CURL_FLAGS to handle both insecure and certificate usage | ||
CURL_FLAGS="" | ||
|
||
# Always add --insecure if USE_INSECURE_CONNECTION is true | ||
if [ "$USE_INSECURE_CONNECTION" = "true" ]; then | ||
CURL_FLAGS="$CURL_FLAGS --insecure" | ||
fi | ||
|
||
# Add certificate flags if CERT_BUNDLE_PATH is provided | ||
if [ -n "$CERT_BUNDLE_PATH" ]; then | ||
echo "Using in-line certificate content from CERT_BUNDLE_PATH..." | ||
printf "%b" "$CERT_BUNDLE_PATH" > /tmp/cert.pem | ||
CURL_FLAGS="$CURL_FLAGS --cacert /tmp/cert.pem" | ||
elif [ -n "$CERT_BUNDLE_URL" ]; then | ||
echo "Attempting to download certificate from $CERT_BUNDLE_URL..." | ||
if curl -o /tmp/cert.pem "$CERT_BUNDLE_URL"; then | ||
CURL_FLAGS="$CURL_FLAGS --cacert /tmp/cert.pem" | ||
else | ||
echo "Certificate not available or failed to download." | ||
fi | ||
fi | ||
|
||
# main curl command | ||
curl --location --request POST "https://${URL}/api/v1/artifact/?tenant_id=${TENANT_ID}&data_type=${DATA_TYPE}&label_id=${LABEL_NAME}&save_to_s3=true" \ | ||
--header "Tenant-Id: ${TENANT_ID}" \ | ||
--header "Authorization: Bearer ${AUTH_TOKEN}" \ | ||
$CURL_FLAGS \ | ||
--form "file=@/data/report.json" | ||
|
||
SujithKasireddy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Print the report | ||
cat /data/report.json | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove binary file