Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions charts/osac/values-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ aap:
hostname: ""

configAsCode:
# Secret names for AAP config-as-code. These are created by
# scripts/aap-configuration.sh during post-install setup.
# Secret names for AAP config-as-code. These must exist before the
# bootstrap job runs. scripts/setup.sh creates them automatically in
# Helm mode; see docs/helm-deployment-guide.md for manual creation.
manifestSecret: "config-as-code-manifest-ig"
secret: "config-as-code-ig"

Expand Down
14 changes: 13 additions & 1 deletion docs/helm-deployment-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,14 @@ The AAP bootstrap job requires a subscription manifest (license.zip). Obtain
it from the [Red Hat Customer Portal](https://access.redhat.com/) under
**Subscriptions > Subscription Allocations > Export Manifest**.

> **Note:** `scripts/setup.sh` creates this secret automatically when
> `DEPLOY_MODE=helm`. Place `license.zip` in
> `overlays/<overlay>/files/license.zip` or set the `AAP_LICENSE_FILE`
> environment variable to its path. The manual command below is only needed
> if you are not using `setup.sh`.

```bash
# Create the license secret
# Create the license secret (manual method)
oc create secret generic config-as-code-manifest-ig \
--from-file=license.zip=/path/to/your/license.zip \
-n ${NAMESPACE}
Expand All @@ -476,7 +482,13 @@ oc create secret generic config-as-code-manifest-ig \
This tells the AAP bootstrap job which execution environment image and git
repository to use for configuration playbooks.

> **Note:** `scripts/setup.sh` creates this secret automatically when
> `DEPLOY_MODE=helm`, using sensible defaults. Override via `AAP_EE_IMAGE`,
> `AAP_PROJECT_GIT_URI`, and `AAP_PROJECT_GIT_BRANCH` environment variables.
> The manual command below is only needed if you are not using `setup.sh`.

```bash
# Create the config-as-code secret (manual method)
oc create secret generic config-as-code-ig \
--from-literal=AAP_EE_IMAGE=ghcr.io/osac-project/osac-aap:latest \
--from-literal=AAP_PROJECT_GIT_URI=https://github.com/osac-project/osac-aap \
Expand Down
36 changes: 35 additions & 1 deletion scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,42 @@ EOF
-n "${INSTALLER_NAMESPACE}" \
--dry-run=client -o yaml | oc apply -f -

# Create AAP license secret (required by the bootstrap job).
# In kustomize mode this is handled by secretGenerator; in Helm mode we
# must create it explicitly. The license.zip can be provided via:
# 1. AAP_LICENSE_FILE env var (absolute path)
# 2. overlays/<overlay>/files/license.zip (default convention)
AAP_LICENSE_FILE=${AAP_LICENSE_FILE:-"overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/license.zip"}
if [[ -f "${AAP_LICENSE_FILE}" ]]; then
echo "Creating config-as-code-manifest-ig secret from ${AAP_LICENSE_FILE}..."
oc create secret generic config-as-code-manifest-ig \
--from-file=license.zip="${AAP_LICENSE_FILE}" \
-n "${INSTALLER_NAMESPACE}" \
--dry-run=client -o yaml | oc apply -f -
oc label secret config-as-code-manifest-ig \
osac.openshift.io/project=osac-aap \
-n "${INSTALLER_NAMESPACE}" --overwrite
else
echo "WARNING: AAP license file not found at ${AAP_LICENSE_FILE}"
echo "The AAP bootstrap job will fail without it."
echo "Set AAP_LICENSE_FILE or place license.zip in overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/"
Comment on lines +341 to +344

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid a false failure warning when the secret already exists.

Line 342/343 states the bootstrap job will fail whenever AAP_LICENSE_FILE is missing, but that is incorrect if config-as-code-manifest-ig is already present in the namespace from a prior run.

Suggested fix
-    else
-        echo "WARNING: AAP license file not found at ${AAP_LICENSE_FILE}"
-        echo "The AAP bootstrap job will fail without it."
-        echo "Set AAP_LICENSE_FILE or place license.zip in overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/"
-    fi
+    elif oc get secret config-as-code-manifest-ig -n "${INSTALLER_NAMESPACE}" &>/dev/null; then
+        echo "AAP license file not found at ${AAP_LICENSE_FILE}; using existing config-as-code-manifest-ig secret."
+    else
+        echo "WARNING: AAP license file not found at ${AAP_LICENSE_FILE}"
+        echo "The AAP bootstrap job will fail without it."
+        echo "Set AAP_LICENSE_FILE or place license.zip in overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/"
+    fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
else
echo "WARNING: AAP license file not found at ${AAP_LICENSE_FILE}"
echo "The AAP bootstrap job will fail without it."
echo "Set AAP_LICENSE_FILE or place license.zip in overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/"
elif oc get secret config-as-code-manifest-ig -n "${INSTALLER_NAMESPACE}" &>/dev/null; then
echo "AAP license file not found at ${AAP_LICENSE_FILE}; using existing config-as-code-manifest-ig secret."
else
echo "WARNING: AAP license file not found at ${AAP_LICENSE_FILE}"
echo "The AAP bootstrap job will fail without it."
echo "Set AAP_LICENSE_FILE or place license.zip in overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/"
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/setup.sh` around lines 341 - 344, The warning message on lines
342-343 in the setup.sh script incorrectly states that the AAP bootstrap job
will always fail without the AAP_LICENSE_FILE, but this is not true if the
config-as-code-manifest-ig secret already exists in the namespace from a prior
run. Update the warning messages to clarify that the job will only fail if the
license file is missing AND the secret does not already exist in the namespace,
so users understand when the warning is actually actionable versus when the
bootstrap can proceed with an existing secret.

fi
Comment on lines +326 to +345

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Path traversal risk in license file handling.

The AAP_LICENSE_FILE variable defaults to a path constructed from the user-controlled INSTALLER_KUSTOMIZE_OVERLAY environment variable. An attacker who controls this environment variable can set AAP_LICENSE_FILE to an arbitrary path (e.g., /etc/passwd or ../../../sensitive-file), causing the script to read that file's content and embed it in the config-as-code-manifest-ig secret. While oc create secret --from-file does not execute commands, this enables information disclosure of arbitrary files readable by the script's user.

Risk severity: Medium
Impact: Information disclosure; attacker can exfiltrate file contents from the deployment environment into a Kubernetes secret.

🛡️ Recommended mitigation

Validate that AAP_LICENSE_FILE points to an expected location before using it:

 AAP_LICENSE_FILE=${AAP_LICENSE_FILE:-"overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/license.zip"}
+# Validate license file path to prevent path traversal
+if [[ "${AAP_LICENSE_FILE}" =~ \.\. ]] || [[ "${AAP_LICENSE_FILE}" == /* && ! "${AAP_LICENSE_FILE}" =~ ^/tmp/ ]]; then
+    echo "ERROR: AAP_LICENSE_FILE path is invalid or potentially unsafe: ${AAP_LICENSE_FILE}"
+    exit 1
+fi
 if [[ -f "${AAP_LICENSE_FILE}" ]]; then

Alternatively, enforce that the file must be within the repository:

 AAP_LICENSE_FILE=${AAP_LICENSE_FILE:-"overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/license.zip"}
+# Resolve to canonical path and ensure it's under the repo root
+CANONICAL_LICENSE=$(realpath -m "${AAP_LICENSE_FILE}" 2>/dev/null || echo "")
+REPO_ROOT=$(realpath "${SCRIPT_DIR}/..")
+if [[ -z "${CANONICAL_LICENSE}" ]] || [[ ! "${CANONICAL_LICENSE}" =~ ^"${REPO_ROOT}" ]]; then
+    echo "ERROR: AAP_LICENSE_FILE must be within the repository directory"
+    exit 1
+fi
+AAP_LICENSE_FILE="${CANONICAL_LICENSE}"
 if [[ -f "${AAP_LICENSE_FILE}" ]]; then
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Create AAP license secret (required by the bootstrap job).
# In kustomize mode this is handled by secretGenerator; in Helm mode we
# must create it explicitly. The license.zip can be provided via:
# 1. AAP_LICENSE_FILE env var (absolute path)
# 2. overlays/<overlay>/files/license.zip (default convention)
AAP_LICENSE_FILE=${AAP_LICENSE_FILE:-"overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/license.zip"}
if [[ -f "${AAP_LICENSE_FILE}" ]]; then
echo "Creating config-as-code-manifest-ig secret from ${AAP_LICENSE_FILE}..."
oc create secret generic config-as-code-manifest-ig \
--from-file=license.zip="${AAP_LICENSE_FILE}" \
-n "${INSTALLER_NAMESPACE}" \
--dry-run=client -o yaml | oc apply -f -
oc label secret config-as-code-manifest-ig \
osac.openshift.io/project=osac-aap \
-n "${INSTALLER_NAMESPACE}" --overwrite
else
echo "WARNING: AAP license file not found at ${AAP_LICENSE_FILE}"
echo "The AAP bootstrap job will fail without it."
echo "Set AAP_LICENSE_FILE or place license.zip in overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/"
fi
# Create AAP license secret (required by the bootstrap job).
# In kustomize mode this is handled by secretGenerator; in Helm mode we
# must create it explicitly. The license.zip can be provided via:
# 1. AAP_LICENSE_FILE env var (absolute path)
# 2. overlays/<overlay>/files/license.zip (default convention)
AAP_LICENSE_FILE=${AAP_LICENSE_FILE:-"overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/license.zip"}
# Validate license file path to prevent path traversal
if [[ "${AAP_LICENSE_FILE}" =~ \.\. ]] || [[ "${AAP_LICENSE_FILE}" == /* && ! "${AAP_LICENSE_FILE}" =~ ^/tmp/ ]]; then
echo "ERROR: AAP_LICENSE_FILE path is invalid or potentially unsafe: ${AAP_LICENSE_FILE}"
exit 1
fi
if [[ -f "${AAP_LICENSE_FILE}" ]]; then
echo "Creating config-as-code-manifest-ig secret from ${AAP_LICENSE_FILE}..."
oc create secret generic config-as-code-manifest-ig \
--from-file=license.zip="${AAP_LICENSE_FILE}" \
-n "${INSTALLER_NAMESPACE}" \
--dry-run=client -o yaml | oc apply -f -
oc label secret config-as-code-manifest-ig \
osac.openshift.io/project=osac-aap \
-n "${INSTALLER_NAMESPACE}" --overwrite
else
echo "WARNING: AAP license file not found at ${AAP_LICENSE_FILE}"
echo "The AAP bootstrap job will fail without it."
echo "Set AAP_LICENSE_FILE or place license.zip in overlays/${INSTALLER_KUSTOMIZE_OVERLAY}/files/"
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/setup.sh` around lines 326 - 345, The AAP_LICENSE_FILE variable can
be set to an arbitrary path through environment control, enabling information
disclosure of any file readable by the script. Add validation before the file
existence check to ensure AAP_LICENSE_FILE points to a safe location within the
expected repository structure. Specifically, add a check that validates the
resolved path does not escape the overlays directory (e.g., using realpath to
resolve symlinks and normalize paths, then verify it stays within overlays/),
and reject paths containing traversal sequences like ../. This validation must
occur before the existing if [[ -f "${AAP_LICENSE_FILE}" ]] check to prevent
unauthorized file reads.


# Create AAP config-as-code secret (EE image, git URI, git branch).
# Values can be overridden via environment variables.
AAP_EE_IMAGE=${AAP_EE_IMAGE:-"ghcr.io/osac-project/osac-aap:latest"}
AAP_PROJECT_GIT_URI=${AAP_PROJECT_GIT_URI:-"https://github.com/osac-project/osac-aap"}
AAP_PROJECT_GIT_BRANCH=${AAP_PROJECT_GIT_BRANCH:-"main"}
echo "Creating config-as-code-ig secret..."
oc create secret generic config-as-code-ig \
--from-literal=AAP_EE_IMAGE="${AAP_EE_IMAGE}" \
--from-literal=AAP_PROJECT_GIT_URI="${AAP_PROJECT_GIT_URI}" \
--from-literal=AAP_PROJECT_GIT_BRANCH="${AAP_PROJECT_GIT_BRANCH}" \
-n "${INSTALLER_NAMESPACE}" \
--dry-run=client -o yaml | oc apply -f -
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

echo "Deploying OSAC using Helm..."
helm dependency build charts/osac/
helm dependency update charts/osac/
helm upgrade --install osac charts/osac/ \
--namespace "${INSTALLER_NAMESPACE}" \
--values "${VALUES_FILE}" \
Expand Down
Loading