Skip to content

Commit 6014951

Browse files
authored
feat(iac): add IaC to Prowler App (#8751)
1 parent 61a66f2 commit 6014951

File tree

40 files changed

+903
-128
lines changed

40 files changed

+903
-128
lines changed

api/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to the **Prowler API** are documented in this file.
55
## [1.15.0] (Prowler UNRELEASED)
66

77
### Added
8+
- IaC (Infrastructure as Code) provider support for remote repositories [(#8751)](https://github.com/prowler-cloud/prowler/pull/8751)
89
- Extend `GET /api/v1/providers` with provider-type filters and optional pagination disable to support the new Overview filters [(#8975)](https://github.com/prowler-cloud/prowler/pull/8975)
910
- New endpoint to retrieve the number of providers grouped by provider type [(#8975)](https://github.com/prowler-cloud/prowler/pull/8975)
1011
- Support for configuring multiple LLM providers [(#8772)](https://github.com/prowler-cloud/prowler/pull/8772)

api/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ LABEL maintainer="https://github.com/prowler-cloud/api"
55
ARG POWERSHELL_VERSION=7.5.0
66
ENV POWERSHELL_VERSION=${POWERSHELL_VERSION}
77

8+
ARG TRIVY_VERSION=0.66.0
9+
ENV TRIVY_VERSION=${TRIVY_VERSION}
10+
811
# hadolint ignore=DL3008
912
RUN apt-get update && apt-get install -y --no-install-recommends \
1013
wget \
@@ -36,6 +39,24 @@ RUN ARCH=$(uname -m) && \
3639
ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh && \
3740
rm /tmp/powershell.tar.gz
3841

42+
# Install Trivy for IaC scanning
43+
RUN ARCH=$(uname -m) && \
44+
if [ "$ARCH" = "x86_64" ]; then \
45+
TRIVY_ARCH="Linux-64bit" ; \
46+
elif [ "$ARCH" = "aarch64" ]; then \
47+
TRIVY_ARCH="Linux-ARM64" ; \
48+
else \
49+
echo "Unsupported architecture for Trivy: $ARCH" && exit 1 ; \
50+
fi && \
51+
wget --progress=dot:giga "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_${TRIVY_ARCH}.tar.gz" -O /tmp/trivy.tar.gz && \
52+
tar zxf /tmp/trivy.tar.gz -C /tmp && \
53+
mv /tmp/trivy /usr/local/bin/trivy && \
54+
chmod +x /usr/local/bin/trivy && \
55+
rm /tmp/trivy.tar.gz && \
56+
# Create trivy cache directory with proper permissions
57+
mkdir -p /tmp/.cache/trivy && \
58+
chmod 777 /tmp/.cache/trivy
59+
3960
# Add prowler user
4061
RUN addgroup --gid 1000 prowler && \
4162
adduser --uid 1000 --gid 1000 --disabled-password --gecos "" prowler
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Generated by Django 5.1.10 on 2025-09-09 09:25
2+
3+
from django.db import migrations
4+
5+
import api.db_utils
6+
7+
8+
class Migration(migrations.Migration):
9+
dependencies = [
10+
("api", "0053_lighthouse_bedrock_openai_compatible"),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name="provider",
16+
name="provider",
17+
field=api.db_utils.ProviderEnumField(
18+
choices=[
19+
("aws", "AWS"),
20+
("azure", "Azure"),
21+
("gcp", "GCP"),
22+
("kubernetes", "Kubernetes"),
23+
("m365", "M365"),
24+
("github", "GitHub"),
25+
("oci", "Oracle Cloud Infrastructure"),
26+
("iac", "IaC"),
27+
],
28+
default="aws",
29+
),
30+
),
31+
migrations.RunSQL(
32+
"ALTER TYPE provider ADD VALUE IF NOT EXISTS 'iac';",
33+
reverse_sql=migrations.RunSQL.noop,
34+
),
35+
]

api/src/backend/api/models.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ class ProviderChoices(models.TextChoices):
284284
KUBERNETES = "kubernetes", _("Kubernetes")
285285
M365 = "m365", _("M365")
286286
GITHUB = "github", _("GitHub")
287+
IAC = "iac", _("IaC")
287288
OCI = "oci", _("Oracle Cloud Infrastructure")
288289

289290
@staticmethod
@@ -355,6 +356,19 @@ def validate_github_uid(value):
355356
pointer="/data/attributes/uid",
356357
)
357358

359+
@staticmethod
360+
def validate_iac_uid(value):
361+
# Validate that it's a valid repository URL (git URL format)
362+
if not re.match(
363+
r"^(https?://|git@|ssh://)[^\s/]+[^\s]*\.git$|^(https?://)[^\s/]+[^\s]*$",
364+
value,
365+
):
366+
raise ModelValidationError(
367+
detail="IaC provider ID must be a valid repository URL (e.g., https://github.com/user/repo or https://github.com/user/repo.git).",
368+
code="iac-uid",
369+
pointer="/data/attributes/uid",
370+
)
371+
358372
@staticmethod
359373
def validate_oci_uid(value):
360374
if not re.match(

0 commit comments

Comments
 (0)