Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40ecbd035e | ||
|
|
14bc94a402 | ||
|
|
7391798e8d | ||
|
|
f17916c7c2 | ||
|
|
c6d95e22fa | ||
|
|
6a4df430c6 | ||
|
|
725b0060f1 | ||
|
|
f3d2e51aab | ||
|
|
544ff1cdc1 | ||
|
|
1bb6b3cb39 |
@@ -158,7 +158,7 @@ SENTRY_RELEASE=local
|
||||
# REO_DEV_CLIENT_ID=
|
||||
|
||||
#### Prowler release version ####
|
||||
NEXT_PUBLIC_PROWLER_RELEASE_VERSION=v5.40.0
|
||||
NEXT_PUBLIC_PROWLER_RELEASE_VERSION=v5.39.1
|
||||
|
||||
# Social login credentials
|
||||
SOCIAL_GOOGLE_OAUTH_CALLBACK_URL="${AUTH_URL}/api/auth/callback/google"
|
||||
|
||||
@@ -199,7 +199,7 @@ You MUST structure your response using this EXACT format. Do NOT include anythin
|
||||
|
||||
### For Check Logic Bug
|
||||
|
||||
```markdown
|
||||
```
|
||||
### AI Assessment [Experimental]: Check Logic Bug
|
||||
|
||||
**Component**: {component from issue template}
|
||||
@@ -297,7 +297,7 @@ Write tests FIRST (TDD). The skills contain all testing conventions and patterns
|
||||
|
||||
### For Bug (non-check)
|
||||
|
||||
```markdown
|
||||
```
|
||||
### AI Assessment [Experimental]: Bug
|
||||
|
||||
**Component**: {CLI/SDK | API | UI | Dashboard | MCP Server | Other}
|
||||
@@ -378,7 +378,7 @@ Write tests FIRST (TDD). The skills contain all testing conventions and patterns
|
||||
|
||||
### For Already Fixed
|
||||
|
||||
```markdown
|
||||
```
|
||||
### AI Assessment [Experimental]: Already Fixed
|
||||
|
||||
**Component**: {component}
|
||||
@@ -401,7 +401,7 @@ Upgrade to the latest version. Close the issue as resolved.
|
||||
|
||||
### For Feature Request
|
||||
|
||||
```markdown
|
||||
```
|
||||
### AI Assessment [Experimental]: Feature Request
|
||||
|
||||
**Component**: {component}
|
||||
@@ -419,7 +419,7 @@ Upgrade to the latest version. Close the issue as resolved.
|
||||
|
||||
### For Not a Bug
|
||||
|
||||
```markdown
|
||||
```
|
||||
### AI Assessment [Experimental]: Not a Bug
|
||||
|
||||
**Component**: {component}
|
||||
@@ -440,7 +440,7 @@ Upgrade to the latest version. Close the issue as resolved.
|
||||
|
||||
### For Needs More Information
|
||||
|
||||
```markdown
|
||||
```
|
||||
### AI Assessment [Experimental]: Needs More Information
|
||||
|
||||
**Component**: {component or "Unknown"}
|
||||
|
||||
@@ -52,16 +52,6 @@ provider/alibabacloud:
|
||||
- any-glob-to-any-file: "prowler/providers/alibabacloud/**"
|
||||
- any-glob-to-any-file: "tests/providers/alibabacloud/**"
|
||||
|
||||
provider/huaweicloud:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "prowler/providers/huaweicloud/**"
|
||||
- any-glob-to-any-file: "tests/providers/huaweicloud/**"
|
||||
|
||||
provider/image:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "prowler/providers/image/**"
|
||||
- any-glob-to-any-file: "tests/providers/image/**"
|
||||
|
||||
provider/cloudflare:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "prowler/providers/cloudflare/**"
|
||||
@@ -92,11 +82,6 @@ provider/linode:
|
||||
- any-glob-to-any-file: "prowler/providers/linode/**"
|
||||
- any-glob-to-any-file: "tests/providers/linode/**"
|
||||
|
||||
provider/stackit:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "prowler/providers/stackit/**"
|
||||
- any-glob-to-any-file: "tests/providers/stackit/**"
|
||||
|
||||
github_actions:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ".github/workflows/*"
|
||||
|
||||
@@ -8,11 +8,11 @@ These JSON templates are used with the `slackapi/slack-github-action` using the
|
||||
|
||||
### Available Templates
|
||||
|
||||
#### Container Releases
|
||||
**Container Releases**
|
||||
- `container-release-started.json`: Simple one-line notification when container push starts
|
||||
- `container-release-completed.json`: Simple one-line notification when container release completes
|
||||
|
||||
#### Deployments
|
||||
**Deployments**
|
||||
- `deployment-started.json`: Deployment start notification with Block Kit formatting
|
||||
- `deployment-completed.json`: Deployment completion notification (updates the start message)
|
||||
|
||||
@@ -416,17 +416,17 @@ For deployments that start with one message and update it with the final status:
|
||||
### Container Release (Simple One-Line)
|
||||
|
||||
**Start message:**
|
||||
```text
|
||||
```
|
||||
API container release 4.5.0 push started... View run
|
||||
```
|
||||
|
||||
**Completion message (success):**
|
||||
```text
|
||||
```
|
||||
[✓] API container release 4.5.0 push completed successfully! View run
|
||||
```
|
||||
|
||||
**Completion message (failure):**
|
||||
```text
|
||||
```
|
||||
[✗] API container release 4.5.0 push failed View run
|
||||
```
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ jobs:
|
||||
api.github.com:443
|
||||
github.com:443
|
||||
objects.githubusercontent.com:443
|
||||
release-assets.githubusercontent.com:443
|
||||
pypi.org:443
|
||||
files.pythonhosted.org:443
|
||||
|
||||
|
||||
@@ -55,10 +55,6 @@ jobs:
|
||||
# Pin must match .pre-commit-config.yaml so prek and CI behave identically.
|
||||
# pnpm dlx doesn't accept --ignore-scripts as a flag; the env var
|
||||
# disables postinstall scripts on transitives the same way.
|
||||
#
|
||||
# Files come from `git ls-files` because markdownlint doesn't traverse
|
||||
# dot-directories, so `.github/**/*.md` went unlinted.
|
||||
# `.markdownlintignore` still applies to the listed paths.
|
||||
env:
|
||||
pnpm_config_ignore_scripts: 'true'
|
||||
run: git ls-files -z '*.md' | xargs -0 -r pnpm dlx markdownlint-cli@0.45.0 --
|
||||
run: pnpm dlx markdownlint-cli@0.45.0 '**/*.md'
|
||||
|
||||
@@ -35,7 +35,6 @@ jobs:
|
||||
api.github.com:443
|
||||
github.com:443
|
||||
objects.githubusercontent.com:443
|
||||
release-assets.githubusercontent.com:443
|
||||
pypi.org:443
|
||||
files.pythonhosted.org:443
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ jobs:
|
||||
egress-policy: block
|
||||
allowed-endpoints: >
|
||||
github.com:443
|
||||
release-assets.githubusercontent.com:443
|
||||
pypi.org:443
|
||||
files.pythonhosted.org:443
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ dependencies = [
|
||||
"gunicorn==26.0.0",
|
||||
"uvloop==0.22.1",
|
||||
"lxml==6.1.0",
|
||||
"prowler @ git+https://github.com/prowler-cloud/prowler.git@master",
|
||||
"prowler @ git+https://github.com/prowler-cloud/prowler.git@v5.39",
|
||||
"psycopg2-binary==2.9.9",
|
||||
"pytest-celery[redis] (==1.3.0)",
|
||||
"sentry-sdk[django] (==2.56.0)",
|
||||
@@ -71,7 +71,7 @@ name = "prowler-api"
|
||||
package-mode = false
|
||||
# Needed for the SDK compatibility
|
||||
requires-python = ">=3.11,<3.13"
|
||||
version = "1.41.0"
|
||||
version = "1.40.1"
|
||||
|
||||
# Shared ruff baseline (kept in sync with mcp_server/pyproject.toml).
|
||||
# target-version tracks this project's lowest supported Python.
|
||||
@@ -491,6 +491,12 @@ override-dependencies = [
|
||||
# deployed from this lock with `uv sync --locked`, so the override applies to what runs.
|
||||
# Remove when azure-cli-core pins msal>=1.37.0 and workos is on 10.x.
|
||||
"cryptography==50.0.0",
|
||||
# prowler@master hard-pins alibabacloud-tea-openapi and oci in [project.dependencies];
|
||||
# the SDK bumped both to lift their cryptography caps. A constraint cannot satisfy the
|
||||
# new pins against the older master rev locked here, so override until the SDK bump
|
||||
# propagates to the pinned master rev, then drop these two.
|
||||
"alibabacloud-tea-openapi==0.4.6",
|
||||
"oci==2.184.1",
|
||||
"azure-mgmt-containerservice==34.1.0",
|
||||
"microsoft-kiota-abstractions==1.9.10",
|
||||
"microsoft-kiota-authentication-azure==1.9.10",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: Prowler API
|
||||
version: 1.41.0
|
||||
version: 1.40.1
|
||||
description: |-
|
||||
Prowler API specification.
|
||||
|
||||
|
||||
@@ -376,6 +376,7 @@ constraints = [
|
||||
{ name = "zstd", specifier = "==1.5.7.2" },
|
||||
]
|
||||
overrides = [
|
||||
{ name = "alibabacloud-tea-openapi", specifier = "==0.4.6" },
|
||||
{ name = "azure-mgmt-containerservice", specifier = "==34.1.0" },
|
||||
{ name = "cryptography", specifier = "==50.0.0" },
|
||||
{ name = "dulwich", specifier = "==1.2.5" },
|
||||
@@ -386,6 +387,7 @@ overrides = [
|
||||
{ name = "microsoft-kiota-serialization-json", specifier = "==1.9.10" },
|
||||
{ name = "microsoft-kiota-serialization-multipart", specifier = "==1.9.10" },
|
||||
{ name = "microsoft-kiota-serialization-text", specifier = "==1.9.10" },
|
||||
{ name = "oci", specifier = "==2.184.1" },
|
||||
{ name = "okta", specifier = "==3.4.2" },
|
||||
{ name = "pyjwt", extras = ["crypto"], specifier = "==2.13.0" },
|
||||
]
|
||||
@@ -4835,8 +4837,8 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "prowler"
|
||||
version = "5.40.0"
|
||||
source = { git = "https://github.com/prowler-cloud/prowler.git?rev=master#b6e9967da6bebd6c7b8b237317a2a95e2e0c65bc" }
|
||||
version = "5.39.0"
|
||||
source = { git = "https://github.com/prowler-cloud/prowler.git?rev=v5.39#7391798e8dfb1ea0f496846d6b4796a547b316f5" }
|
||||
dependencies = [
|
||||
{ name = "alibabacloud-actiontrail20200706" },
|
||||
{ name = "alibabacloud-credentials" },
|
||||
@@ -4935,7 +4937,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "prowler-api"
|
||||
version = "1.41.0"
|
||||
version = "1.40.1"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "cartography" },
|
||||
@@ -5035,7 +5037,7 @@ requires-dist = [
|
||||
{ name = "matplotlib", specifier = "==3.10.8" },
|
||||
{ name = "neo4j", specifier = "==6.1.0" },
|
||||
{ name = "openai", specifier = "==1.109.1" },
|
||||
{ name = "prowler", git = "https://github.com/prowler-cloud/prowler.git?rev=master" },
|
||||
{ name = "prowler", git = "https://github.com/prowler-cloud/prowler.git?rev=v5.39" },
|
||||
{ name = "psycopg2-binary", specifier = "==2.9.9" },
|
||||
{ name = "pytest-celery", extras = ["redis"], specifier = "==1.3.0" },
|
||||
{ name = "reportlab", specifier = "==4.4.10" },
|
||||
|
||||
@@ -4,117 +4,6 @@ description: "New features and improvements in each Prowler release"
|
||||
rss: true
|
||||
---
|
||||
|
||||
<Update label="v5.39.0" description="August 13, 2026">
|
||||
### 🤖 Lighthouse AI — Finding Skills
|
||||
|
||||
<Note>
|
||||
This feature is available exclusively in **Prowler Cloud** and **Prowler Private Cloud** with a [subscription](https://prowler.com/pricing).
|
||||
</Note>
|
||||
|
||||
Lighthouse AI now embeds a Skills menu on every finding, answering the questions an analyst actually asks. **Contextual Fix** produces the fix for the finding, **Triage Decision** judges whether it is real and closes it out when it is not, and **Systemic Scope** determines whether the problem is a one-off or everywhere. A free-form "Ask Lighthouse anything" prompt sits in the same menu, and each run shows its progress and offers follow-up actions such as creating a Jira issue or muting the finding.
|
||||
|
||||

|
||||
|
||||
Read more in the [Lighthouse AI documentation](https://docs.prowler.com/getting-started/products/prowler-cloud-lighthouse).
|
||||
|
||||
### ☁️ Azure Management Group Onboarding
|
||||
|
||||
<Note>
|
||||
This feature is available exclusively in **Prowler Cloud** and **Prowler Private Cloud** with a [subscription](https://prowler.com/pricing).
|
||||
</Note>
|
||||
|
||||
Azure subscriptions no longer onboard one at a time. Choose "Add Multiple Subscriptions With Azure Management Group" in the add-provider wizard, enter the Microsoft Entra tenant ID, and authenticate once with a single tenant-wide service principal: Prowler discovers the entire management-group hierarchy under the tenant root, lets you select the subscriptions to onboard, and creates their providers with the management-group structure preserved. Azure now matches the one-step onboarding that AWS Organizations and GCP organizations already have.
|
||||
|
||||

|
||||
|
||||
Read more in the [Azure Management Groups documentation](https://docs.prowler.com/user-guide/tutorials/prowler-cloud-azure-management-groups).
|
||||
|
||||
### ✅ Findings Triage — Verify MANUAL Findings as PASS
|
||||
|
||||
<Note>
|
||||
This feature is available exclusively in **Prowler Cloud** and **Prowler Private Cloud** with a [subscription](https://prowler.com/pricing).
|
||||
</Note>
|
||||
|
||||
Checks that require human judgment report `MANUAL` findings. For these findings, and only for them, the triage status selector now offers **Resolved**: choosing it asks for the required written evidence and verifies the finding as passing. The finding then reports an effective `PASS` while preserving the raw `MANUAL` scan result, across findings, finding groups, compliance reports, and scans, with the attestation's author, evidence, and validity always visible. Attestations expire automatically after 90 days, or as soon as a new scan reports a real failure, returning the finding to the review queue.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Read more in the [Findings Triage documentation](https://docs.prowler.com/user-guide/tutorials/prowler-app-findings-triage#verify-a-manual-finding-as-pass).
|
||||
|
||||
### ☁️ Prowler Cloud MCP — Organizations Management and Grouped Jira Dispatch
|
||||
|
||||
<Note>
|
||||
This feature is available exclusively in **Prowler Cloud** and **Prowler Private Cloud** with a [subscription](https://prowler.com/pricing).
|
||||
</Note>
|
||||
|
||||
The hosted Prowler Cloud MCP server adds eight organization tools, so an agent can onboard and manage entire cloud organizations end to end: create the organization, discover its accounts, subscriptions, and projects, apply the selection, and manage the resulting providers. The tools cover AWS Organizations, GCP organizations, and Azure tenant root management groups, and they are available to Lighthouse AI.
|
||||
|
||||
`prowler_send_findings_to_jira` also gains Cloud-only dispatch capabilities: select failed findings by check IDs against the latest completed scan, and send them in grouped mode, one Jira work item per check listing up to 50 affected resources, with per-group error reporting.
|
||||
|
||||
Read more in the [Prowler MCP tools documentation](https://docs.prowler.com/getting-started/basic-usage/prowler-mcp-tools) and its [Jira operations reference](https://docs.prowler.com/getting-started/basic-usage/prowler-mcp-tools#jira-operations).
|
||||
|
||||
### 🕸️ Attack Paths — Grouped Graph with Outcome Destinations
|
||||
|
||||
<Note>
|
||||
This feature is available exclusively in **Prowler Cloud** and **Prowler Private Cloud** with a [subscription](https://prowler.com/pricing).
|
||||
</Note>
|
||||
|
||||
The Attack Paths graph now reads from source to destination. Resources of the same class collapse into a single expandable node with a count, clicking reveals its members, and every path terminates in an explicit outcome node naming the destination impact: code execution, privilege escalation, public exposure, or resource inventory. The per-account hub node is gone, and the clicked resource stays highlighted while its findings are expanded.
|
||||
|
||||

|
||||
|
||||
Explore the full Attack Paths query catalog at [Prowler Hub](https://hub.prowler.com/attack-paths).
|
||||
|
||||
Read more in the [Attack Paths documentation](https://docs.prowler.com/user-guide/tutorials/prowler-app-attack-paths).
|
||||
|
||||
### 📚 New Compliance Framework — CMMC 2.0
|
||||
|
||||
The Cybersecurity Maturity Model Certification (CMMC) is the certification the US Department of Defense requires from contractors and suppliers that handle federal contract data. Prowler now includes CMMC 2.0 as a universal framework with all 149 requirements defined by the CMMC Program rule (32 CFR Part 170), organized in its three levels:
|
||||
|
||||
- **Level 1 (Foundational):** 15 requirements for the basic safeguarding of Federal Contract Information, from FAR 52.204-21.
|
||||
- **Level 2 (Advanced):** 110 requirements from NIST SP 800-171 Rev 2, protecting Controlled Unclassified Information.
|
||||
- **Level 3 (Expert):** 24 enhanced requirements from NIST SP 800-172 for the most sensitive programs.
|
||||
|
||||
Requirements map to Prowler checks across AWS, Azure, GCP, Alibaba Cloud, Oracle Cloud, and Microsoft 365, so one framework reports the compliance posture of the whole estate.
|
||||
|
||||
Read more in the [Compliance documentation](https://docs.prowler.com/user-guide/compliance/tutorials/compliance).
|
||||
|
||||
### 🔍 Checks
|
||||
|
||||
#### Microsoft 365
|
||||
|
||||
Twenty new Entra ID checks expand the coverage of CIS Microsoft 365 Foundations Benchmark v7.0.0:
|
||||
|
||||
- **Password protection:** custom banned password list, on-premises enforcement, and lockout threshold and duration.
|
||||
- **Default user permissions:** security group and Microsoft 365 group creation restricted, and guest invitations limited to allowed domains.
|
||||
- **Conditional Access:** high and medium sign-in risk blocked, authentication transfer blocked, untrusted locations blocked, trusted named locations defined, sign-in frequency enforced, and token protection enforced.
|
||||
- **Sessions and authentication methods:** idle session timeout configured, email one-time passcodes disabled, and Microsoft Authenticator context shown.
|
||||
- **PIM and access reviews:** approval required to activate the Global Administrator and Privileged Role Administrator roles, and access reviews configured for guest users and privileged roles.
|
||||
|
||||
Explore all Microsoft 365 checks at [Prowler Hub](https://hub.prowler.com/check?provider=m365).
|
||||
|
||||
#### AWS
|
||||
|
||||
Two new checks detect hardcoded secrets:
|
||||
|
||||
- `batch_job_definition_no_secrets` scans Batch job definition environment variables and command parameters. Thanks to @praneetrajv!
|
||||
- `awslambda_layer_no_secrets_in_content` scans Lambda layer package content. Thanks to @ganiganesh25!
|
||||
|
||||
Explore all AWS checks at [Prowler Hub](https://hub.prowler.com/check?provider=aws).
|
||||
|
||||
### 🙌 External Contributors
|
||||
|
||||
Thank you to our community contributors for this release!
|
||||
|
||||
- @praneetrajv: AWS `batch_job_definition_no_secrets` check ([#12117](https://github.com/prowler-cloud/prowler/pull/12117))
|
||||
- @ganiganesh25: AWS `awslambda_layer_no_secrets_in_content` check ([#12233](https://github.com/prowler-cloud/prowler/pull/12233))
|
||||
- @andoniaf: GitHub `organization_repository_creation_limited` now reports low severity when repository creation is limited to private or internal visibility ([#12164](https://github.com/prowler-cloud/prowler/pull/12164))
|
||||
|
||||
See the [full release notes on GitHub](https://github.com/prowler-cloud/prowler/releases/tag/5.39.0) for the complete list of changes.
|
||||
</Update>
|
||||
|
||||
<Update label="v5.38.0" description="August 6, 2026">
|
||||
### 📌 Compliance Watchlist
|
||||
|
||||
|
||||
@@ -224,9 +224,9 @@ Each check **must** populate the report with a unique identifier for the audited
|
||||
- `resource_name`: Description of the configuration (e.g., "SharePoint Settings")
|
||||
- GitHub
|
||||
- Resource ID — `report.resource_id`.
|
||||
- The ID of the GitHub resource. This is a system-generated integer that uniquely identifies the resource within the GitHub platform.
|
||||
- The ID of the Github resource. This is a system-generated integer that uniquely identifies the resource within the Github platform.
|
||||
- Resource Name — `report.resource_name`.
|
||||
- The name of the GitHub resource. In the case of a repository, this is just the repository name. For full repository names use the resource `full_name`.
|
||||
- The name of the Github resource. In the case of a repository, this is just the repository name. For full repository names use the resource `full_name`.
|
||||
|
||||
### Configurable Checks in Prowler
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ Once you have decided the provider you want or need to add to Prowler, the next
|
||||
- **SDK Providers**: Low complexity. You have mature examples like AWS, Azure, GCP, Kubernetes, etc. that you can leverage to implement your provider.
|
||||
- **API Providers**: Medium complexity. You need to implement the authentication and session management, and the API calls to the provider. You now have NHN and MongoDB Atlas as example to follow.
|
||||
- **Tool/Wrapper Providers**: High complexity. You need to implement the argument/output mapping to the provider and handle problems that the tool/wrapper may have. You now have IAC and the PowerShell wrapper as example to follow.
|
||||
- **Hybrid Providers**: High complexity. You need to "customize" your provider, mixing the other types of providers in order to achieve the desired result. You have M365 (msgraph SDK + PowerShell wrapper) and GitHub (PyGithub SDK + graphql API requests) as examples.
|
||||
- **Hybrid Providers**: High complexity. You need to "customize" your provider, mixing the other types of providers in order to achieve the desired result. You have M365 (msgraph SDK + PowerShell wrapper) and Github (PyGithub SDK + graphql API requests) as examples.
|
||||
|
||||
### Determining Regional vs Non-Regional Architecture
|
||||
|
||||
@@ -814,7 +814,7 @@ class YourProviderMutelist(Mutelist):
|
||||
Region management is essential for cloud providers that operate across multiple geographic locations. This component handles region validation and provides region-specific functionality.
|
||||
|
||||
<Note>
|
||||
Regions are optional, only if the provider has regions, for example GitHub does not have regions, but AWS does.
|
||||
Regions are optional, only if the provider has regions, for example Github does not have regions, but AWS does.
|
||||
</Note>
|
||||
|
||||
**File:** `prowler/providers/<provider_name>/lib/regions/<provider_name>_regions.py`
|
||||
@@ -1773,7 +1773,7 @@ The implementation of the mutelist is the same as the [SDK providers](#step-5-im
|
||||
Region management is essential for cloud providers that operate across multiple geographic locations. This component handles region validation and provides region-specific functionality.
|
||||
|
||||
<Note>
|
||||
Regions are optional, only if the provider has regions, for example GitHub does not have regions, but AWS does.
|
||||
Regions are optional, only if the provider has regions, for example Github does not have regions, but AWS does.
|
||||
</Note>
|
||||
|
||||
**File:** `prowler/providers/<provider_name>/lib/regions/<provider_name>_regions.py`
|
||||
|
||||
@@ -128,12 +128,12 @@ To update the environment file:
|
||||
Edit the `.env` file and change version values:
|
||||
|
||||
```env
|
||||
PROWLER_UI_VERSION="5.39.0"
|
||||
PROWLER_API_VERSION="5.39.0"
|
||||
PROWLER_UI_VERSION="5.38.0"
|
||||
PROWLER_API_VERSION="5.38.0"
|
||||
```
|
||||
|
||||
<Note>
|
||||
You can find the latest versions of Prowler Local Server in the [Releases GitHub section](https://github.com/prowler-cloud/prowler/releases) or in the [Container Versions](#container-versions) section of this documentation.
|
||||
You can find the latest versions of Prowler Local Server in the [Releases Github section](https://github.com/prowler-cloud/prowler/releases) or in the [Container Versions](#container-versions) section of this documentation.
|
||||
</Note>
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 210 KiB |
|
Before Width: | Height: | Size: 182 KiB |
|
Before Width: | Height: | Size: 563 KiB |
|
Before Width: | Height: | Size: 401 KiB |
|
Before Width: | Height: | Size: 374 KiB |
|
Before Width: | Height: | Size: 286 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 252 KiB After Width: | Height: | Size: 97 KiB |
|
Before Width: | Height: | Size: 366 KiB |
|
Before Width: | Height: | Size: 269 KiB After Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 107 KiB |
@@ -495,7 +495,7 @@ aws:
|
||||
|
||||
# AWS CloudTrail Configuration
|
||||
# aws.cloudtrail_threat_detection_privilege_escalation
|
||||
threat_detection_privilege_escalation_threshold: 0.2 # Percentage of actions found to decide if it is a privilege_escalation attack event, by default is 0.2 (20%)
|
||||
threat_detection_privilege_escalation_threshold: 0.2 # Percentage of actions found to decide if it is an privilege_escalation attack event, by default is 0.2 (20%)
|
||||
threat_detection_privilege_escalation_minutes: 1440 # Past minutes to search from now for privilege_escalation attacks, by default is 1440 minutes (24 hours)
|
||||
threat_detection_privilege_escalation_actions:
|
||||
[
|
||||
|
||||
@@ -16,24 +16,26 @@ Attack Paths analyzes relationships between cloud resources, permissions, and se
|
||||
By mapping these relationships as a graph, Attack Paths reveals risks that individual security checks cannot detect on their own, such as an IAM role that can escalate its own permissions, or a chain of policies that grants unintended access to sensitive resources.
|
||||
|
||||
<Note>
|
||||
Attack Paths is currently available for **AWS** providers. Support for additional providers is planned.
|
||||
Attack Paths is currently available for **AWS** providers. Support for
|
||||
additional providers is planned.
|
||||
</Note>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
The following prerequisites are required for Attack Paths:
|
||||
|
||||
- **An AWS provider is configured** with valid credentials. For setup instructions, see [Getting Started with AWS](/user-guide/providers/aws/getting-started-aws).
|
||||
- **An AWS provider is configured** with valid credentials in Prowler Cloud. For setup instructions, see [Getting Started with AWS](/user-guide/providers/aws/getting-started-aws).
|
||||
- **At least one scan has completed** on the configured AWS provider and produced graph data. Attack Paths scans run automatically alongside regular security scans, no separate configuration is required.
|
||||
|
||||
## How Attack Paths Scans Work
|
||||
|
||||
Attack Paths scans are generated automatically when a security scan runs on an AWS provider. When a scan produces graph data, it maps relationships between IAM principals, policies, trust configurations, and other resources. A scan can complete without producing graph data.
|
||||
Attack Paths scans are generated automatically when a security scan runs on an AWS provider. Each completed scan produces graph data that maps relationships between IAM principals, policies, trust configurations, and other resources.
|
||||
|
||||
When graph data is ready, the scan appears in the Attack Paths scan table with a check in the **Graph** column and can be selected regardless of its current status. Scans without graph data remain visible but cannot be selected. If a new scan cycle starts after graph data is available, the previous cycle remains available while the new scan runs.
|
||||
Once the scan finishes and graph data is ready, the scan appears in the Attack Paths scan table with a **Completed** status and a check in the **Graph** column. Scans that are still queued or running remain visible, but they cannot be selected until graph data is ready.
|
||||
|
||||
<Note>
|
||||
Prowler Cloud and Prowler Private Cloud scan configured providers every **24 hours** by default, so Attack Paths data stays up to date automatically.
|
||||
Since Prowler scans all configured providers every **24 hours** by default,
|
||||
Attack Paths data stays up to date automatically.
|
||||
</Note>
|
||||
|
||||
## Accessing Attack Paths
|
||||
@@ -64,7 +66,7 @@ The scans table displays all Attack Paths scans with the following columns:
|
||||
- **Graph:** Whether Attack Paths graph data is available for the scan.
|
||||
- **Duration:** Total scan time.
|
||||
|
||||
To select a scan for analysis, click any row with a check in the **Graph** column. A row can remain selectable while a new scan cycle runs because Attack Paths keeps the graph from the previous completed cycle available.
|
||||
To select a scan for analysis, click the radio button on any row with a **Completed** status and available graph data.
|
||||
|
||||
<img
|
||||
src="/images/prowler-app/attack-paths/scan-list-table.png"
|
||||
@@ -73,7 +75,8 @@ To select a scan for analysis, click any row with a check in the **Graph** colum
|
||||
/>
|
||||
|
||||
<Note>
|
||||
Only scans with graph data can be selected. Disabled rows include a tooltip that explains why the graph is not available yet.
|
||||
Only scans with graph data can be selected. Disabled rows include a tooltip
|
||||
that explains why the graph is not available yet.
|
||||
</Note>
|
||||
|
||||
## Choosing a Query
|
||||
@@ -94,7 +97,9 @@ To choose a query, click the dropdown and select from the available options. Eac
|
||||
Once selected, a description panel appears below the dropdown with more context about the query.
|
||||
|
||||
<Note>
|
||||
In Prowler Cloud and Prowler Private Cloud, the query selector hides built-in queries confirmed empty for the selected scan. Built-in queries without a confirmed empty result and the **Custom openCypher query** remain visible. See [Active Queries](/user-guide/tutorials/prowler-app-attack-paths-active-queries).
|
||||
In Prowler Cloud and Prowler Private Cloud, the query selector hides queries
|
||||
confirmed empty for the selected scan, so only queries that return data remain
|
||||
visible. See [Active Queries](/user-guide/tutorials/prowler-app-attack-paths-active-queries).
|
||||
</Note>
|
||||
|
||||
## Configuring Query Parameters
|
||||
@@ -115,7 +120,7 @@ For example, **Internet-Exposed EC2 with Sensitive S3 Access** uses **Tag key**
|
||||
|
||||
## Writing Custom openCypher Queries
|
||||
|
||||
In addition to the built-in queries, Attack Paths supports custom read-only [openCypher](https://opencypher.org/) queries. Custom queries provide direct access to the underlying graph so security teams can answer ad-hoc questions, prototype detections, or extend coverage beyond the built-in catalog.
|
||||
In addition to the built-in queries, Attack Paths supports custom read-only [openCypher](https://opencypher.org/) queries. Custom queries provide direct access to the underlying graph so security teams can answer ad-hoc questions, prototype detections, or extend coverage beyond the built-in catalogue.
|
||||
|
||||
To write a custom query, select **Custom openCypher query** from the query dropdown. A code editor with syntax highlighting and line numbers appears, ready to receive the query.
|
||||
|
||||
@@ -187,7 +192,11 @@ Custom queries traverse the same Cartography graph the built-in queries use. Nod
|
||||
For the complete reference, including the graph model, list-typed and JSON-encoded properties, performance guidance, and openCypher compatibility rules, see [Attack Paths Queries](/developer-guide/attack-paths-queries) in the Developer Guide.
|
||||
|
||||
<Note>
|
||||
AI assistants connected through Prowler MCP Server can fetch the exact Cartography schema for the active scan via the `prowler_get_attack_paths_cartography_schema` tool. This guarantees that generated queries match the schema version pinned by the running Prowler release.
|
||||
AI assistants connected through Prowler MCP Server can fetch the exact
|
||||
Cartography schema for the active scan via the
|
||||
`prowler_get_attack_paths_cartography_schema` tool. This guarantees that
|
||||
generated queries match the schema version pinned by the running Prowler
|
||||
release.
|
||||
</Note>
|
||||
|
||||
## Executing a Query
|
||||
@@ -212,22 +221,12 @@ If the query returns no results, an informational message appears. Common reason
|
||||
|
||||
After a successful execution, the graph visualization renders below the query builder. The graph maps relationships between cloud resources, IAM entities, public exposure, and security findings.
|
||||
|
||||
### Grouped Graphs and Query Outcomes
|
||||
|
||||
<VersionBadge version="5.39.0" />
|
||||
|
||||
Prowler Cloud and Prowler Private Cloud group resources of the same class and graph level into expandable nodes. Built-in query graphs also end with a query outcome, which states the result that the path can lead to.
|
||||
|
||||
Prowler Local Server keeps the flat graph view, including the provider root. Custom openCypher queries do not have a catalog outcome, so their graphs do not include an outcome node.
|
||||
|
||||
### Node Types
|
||||
|
||||
- **Grouped resource nodes:** Represent multiple resources of the same class in Prowler Cloud and Prowler Private Cloud. A number in the upper-right corner shows how many resources the node contains. A red outline indicates that one or more resources in the group have findings.
|
||||
- **Resource nodes:** Represent individual cloud resources such as IAM roles, policies, EC2 instances, security groups, and S3 buckets. A class with one resource remains an individual node.
|
||||
- **Provider root nodes:** Represent the AWS account or provider root for the selected scan.
|
||||
- **Resource nodes:** Represent cloud resources such as IAM roles, policies, EC2 instances, security groups, and S3 buckets.
|
||||
- **Internet nodes:** Represent exposure from the public internet.
|
||||
- **Finding nodes:** Represent Prowler findings linked to resources. Finding colors indicate risk level, such as critical, high, medium, or low.
|
||||
- **Outcome nodes:** Mark the terminal result of a built-in query in Prowler Cloud and Prowler Private Cloud. The orange node displays outcomes such as **Code execution**, **Privilege escalation**, **Public exposure**, or **Resource inventory**. A dashed ring and the label **Latent outcome** indicate an inventory or another partial outcome.
|
||||
- **Provider root nodes:** Represent the AWS account or provider root in the Prowler Local Server flat graph.
|
||||
|
||||
### Edge Types
|
||||
|
||||
@@ -235,7 +234,7 @@ Prowler Local Server keeps the flat graph view, including the provider root. Cus
|
||||
- **Finding edges:** Dashed relationships between resources and their associated findings.
|
||||
- **Highlighted paths:** Green edges that show the active path when you hover a node or focus a finding.
|
||||
|
||||
The standard graph view includes a minimap and a legend below the canvas. The legend shows the visible node types, finding risk levels, node states, and edge types present in the current view. Prowler Local Server also displays the provider root in the legend.
|
||||
The standard graph view includes a minimap and a legend below the canvas. The legend shows the provider roots, visible node types, finding risk levels, node states, and edge types present in the current view.
|
||||
|
||||
<img
|
||||
src="/images/prowler-app/attack-paths/graph-visualization.png"
|
||||
@@ -245,32 +244,17 @@ The standard graph view includes a minimap and a legend below the canvas. The le
|
||||
|
||||
## Interacting with the Graph
|
||||
|
||||
The graph supports these interactions:
|
||||
The graph banner describes the main interactions:
|
||||
|
||||
- Click a node with a number in the upper-right corner to expand its resource group.
|
||||
- Click a finding to focus its connected path.
|
||||
- Click a resource with findings to show or hide its related findings.
|
||||
- Hover a node to highlight its connected path.
|
||||
|
||||
### Expanding Resource Groups
|
||||
|
||||
In Prowler Cloud and Prowler Private Cloud, a node with a number in its upper-right corner represents a resource group. The number is the total number of resources in the group.
|
||||
|
||||
- Click the group node to display its resources. Multiple groups can remain expanded, and the graph automatically fits the visible nodes to the canvas.
|
||||
- Double-click any resource revealed from a group to collapse that group.
|
||||
- Click **Collapse all groups** in the graph toolbar to close every expanded group. This control appears only while at least one group is expanded.
|
||||
|
||||
<img
|
||||
src="/images/prowler-app/attack-paths/graph-visualization-expanded.png"
|
||||
alt="Attack Paths graph showing an expanded AWS Role group and remaining numbered resource groups"
|
||||
width="700"
|
||||
/>
|
||||
|
||||
### Showing Related Findings
|
||||
|
||||
Resource nodes with related findings are clickable. Click one of these resources to show its finding nodes. Click the resource again to hide them.
|
||||
|
||||
The selected resource is highlighted in green while its findings are visible. The graph automatically fits the selected resource and its related findings when the findings are shown.
|
||||
The graph automatically fits the selected resource and its related findings when the findings are shown.
|
||||
|
||||
### Focusing a Finding Path
|
||||
|
||||
@@ -295,12 +279,12 @@ The toolbar in the top-right corner of the graph provides:
|
||||
|
||||
- **Zoom in / Zoom out:** Adjust the zoom level
|
||||
- **Fit graph to view:** Reset the view to fit the visible graph
|
||||
- **Collapse all groups:** Close every expanded resource group. This control appears only when a group is expanded
|
||||
- **Export graph:** Download the current graph, including its grouped or expanded state and outcome, as a PNG file
|
||||
- **Export graph:** Download the current graph as a PNG file
|
||||
- **Fullscreen:** Open the graph in a full-size modal
|
||||
|
||||
<Note>
|
||||
Use **Ctrl + Scroll** (or **Cmd + Scroll** on macOS) to zoom directly within the graph area.
|
||||
Use **Ctrl + Scroll** (or **Cmd + Scroll** on macOS) to zoom directly within
|
||||
the graph area.
|
||||
</Note>
|
||||
|
||||
## Viewing Finding Details
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
"ec2:GetInstanceMetadataDefaults",
|
||||
"ecr:Describe*",
|
||||
"ecr:GetRegistryScanningConfiguration",
|
||||
"ecr:BatchGetImage",
|
||||
"ecr:GetDownloadUrlForLayer",
|
||||
"elasticfilesystem:DescribeBackupPolicy",
|
||||
"glue:GetConnections",
|
||||
"glue:GetSecurityConfiguration*",
|
||||
@@ -44,7 +42,6 @@
|
||||
"lightsail:GetRelationalDatabases",
|
||||
"macie2:GetMacieSession",
|
||||
"macie2:GetAutomatedDiscoveryConfiguration",
|
||||
"rolesanywhere:ListProfiles",
|
||||
"rolesanywhere:ListTagsForResource",
|
||||
"rolesanywhere:ListTrustAnchors",
|
||||
"s3:GetAccountPublicAccessBlock",
|
||||
|
||||
@@ -203,8 +203,6 @@ Resources:
|
||||
- "ec2:GetInstanceMetadataDefaults"
|
||||
- "ecr:Describe*"
|
||||
- "ecr:GetRegistryScanningConfiguration"
|
||||
- "ecr:BatchGetImage"
|
||||
- "ecr:GetDownloadUrlForLayer"
|
||||
- "elasticfilesystem:DescribeBackupPolicy"
|
||||
- "glue:GetConnections"
|
||||
- "glue:GetSecurityConfiguration*"
|
||||
@@ -215,7 +213,6 @@ Resources:
|
||||
- "lightsail:GetRelationalDatabases"
|
||||
- "macie2:GetMacieSession"
|
||||
- "macie2:GetAutomatedDiscoveryConfiguration"
|
||||
- "rolesanywhere:ListProfiles"
|
||||
- "rolesanywhere:ListTagsForResource"
|
||||
- "rolesanywhere:ListTrustAnchors"
|
||||
- "s3:GetAccountPublicAccessBlock"
|
||||
@@ -472,8 +469,6 @@ Resources:
|
||||
- "ec2:GetInstanceMetadataDefaults"
|
||||
- "ecr:Describe*"
|
||||
- "ecr:GetRegistryScanningConfiguration"
|
||||
- "ecr:BatchGetImage"
|
||||
- "ecr:GetDownloadUrlForLayer"
|
||||
- "elasticfilesystem:DescribeBackupPolicy"
|
||||
- "glue:GetConnections"
|
||||
- "glue:GetSecurityConfiguration*"
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
`ecr_repository_image_no_secrets` check for AWS provider, scanning the latest ECR repository image's configuration and filesystem layers for hardcoded secrets
|
||||
@@ -1 +0,0 @@
|
||||
Add the `iam_workload_identity_pool_provider_attribute_condition` check to flag GCP Workload Identity Federation providers that trust a multi-tenant issuer without an attribute condition restricting which external identities can impersonate federated principals
|
||||
@@ -1 +0,0 @@
|
||||
Add the `rolesanywhere_profile_restricts_session_permissions` check to flag AWS IAM Roles Anywhere profiles that reference an administrative role without scoping down the vended session with a session policy or managed policies
|
||||
@@ -1 +0,0 @@
|
||||
`vpc_security_group_open_egress` check for Huawei Cloud provider: VPC security groups do not allow open egress to the internet
|
||||
@@ -49,7 +49,7 @@ class _MutableTimestamp:
|
||||
|
||||
timestamp = _MutableTimestamp(datetime.today())
|
||||
timestamp_utc = _MutableTimestamp(datetime.now(timezone.utc))
|
||||
prowler_version = "5.40.0"
|
||||
prowler_version = "5.39.1"
|
||||
html_logo_url = "https://github.com/prowler-cloud/prowler/"
|
||||
square_logo_img = "https://raw.githubusercontent.com/prowler-cloud/prowler/dc7d2d5aeb92fdf12e8604f42ef6472cd3e8e889/docs/img/prowler-logo-black.png"
|
||||
aws_logo = "https://user-images.githubusercontent.com/38561120/235953920-3e3fba08-0795-41dc-b480-9bea57db9f2e.png"
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"Provider": "aws",
|
||||
"CheckID": "ecr_repository_image_no_secrets",
|
||||
"CheckTitle": "ECR repository image contains no hardcoded secrets",
|
||||
"CheckType": [
|
||||
"Software and Configuration Checks/AWS Security Best Practices",
|
||||
"Sensitive Data Identifications/Passwords",
|
||||
"Effects/Data Exposure"
|
||||
],
|
||||
"ServiceName": "ecr",
|
||||
"SubServiceName": "",
|
||||
"ResourceIdTemplate": "",
|
||||
"Severity": "high",
|
||||
"ResourceType": "AwsEcrRepository",
|
||||
"ResourceGroup": "container",
|
||||
"Description": "The **latest image** pushed to each **Amazon ECR repository** is analyzed for **embedded secrets**: environment variables and build history (Dockerfile instructions) recorded in the image configuration, plus the file contents of every filesystem layer. Findings reference the variable, build step, or file, never the secret value.",
|
||||
"Risk": "Anyone able to pull the image obtains any **credentials, tokens, or keys** embedded at build time via `ENV`, `ARG`, inline `RUN` commands, or files copied into the image (e.g. `COPY .env .`).\n\nLeaked credentials enable unauthorized access to databases, APIs, or cloud resources, and rotation is harder once secrets are baked into distributed image artifacts.",
|
||||
"RelatedUrl": "",
|
||||
"AdditionalURLs": [
|
||||
"https://docs.aws.amazon.com/AmazonECR/latest/userguide/security-best-practices.html",
|
||||
"https://docs.aws.amazon.com/secretsmanager/latest/userguide/best-practices.html",
|
||||
"https://docs.docker.com/build/building/secrets/"
|
||||
],
|
||||
"Remediation": {
|
||||
"Code": {
|
||||
"CLI": "aws ecr batch-delete-image --repository-name <repository-name> --image-ids imageDigest=<image-digest>",
|
||||
"NativeIaC": "",
|
||||
"Other": "1. Remove the secret from the Dockerfile (ENV/ARG/RUN) or from any file copied into the build context, and rebuild the image without it.\n2. Provide the secret at runtime instead: reference AWS Secrets Manager or SSM Parameter Store from your ECS task definition, EKS pod (Secrets Store CSI driver), or application code.\n3. Push the rebuilt image and delete the compromised image versions from the repository.\n4. Rotate the exposed credential immediately.",
|
||||
"Terraform": ""
|
||||
},
|
||||
"Recommendation": {
|
||||
"Text": "Never bake secrets into images with `ENV`, `ARG`, inline `RUN` commands, or copied files. Use **BuildKit build secrets** (`--mount=type=secret`) at build time and **AWS Secrets Manager**/Parameter Store at runtime. Add secret scanning to CI/CD before pushing images.",
|
||||
"Url": "https://hub.prowler.com/check/ecr_repository_image_no_secrets"
|
||||
}
|
||||
},
|
||||
"Categories": [
|
||||
"secrets"
|
||||
],
|
||||
"DependsOn": [],
|
||||
"RelatedTo": [],
|
||||
"Notes": "Only the most recently pushed image in each repository is scanned; older tagged images are not scanned. The latest scannable image is evaluated in every repository regardless of whether scan-on-push is enabled. The scanned image's configuration (environment variables and build history) plus every filesystem layer's file contents are analyzed. A multi-architecture image resolves to a single platform's manifest; other architectures in the same manifest list are not scanned. To bound cost, a single layer over 100 MB (compressed) is not downloaded, an individual file over 1 MB is not scanned, and scanning of an image stops after 5000 files or 500 MB (decompressed). When part of an image cannot be scanned this way, a clean result is reported as MANUAL (coverage was incomplete) rather than PASS, and a FAIL still discloses that some content was skipped. Requires the ecr:BatchGetImage and ecr:GetDownloadUrlForLayer permissions in addition to SecurityAudit."
|
||||
}
|
||||
@@ -1,244 +0,0 @@
|
||||
import re
|
||||
|
||||
from prowler.lib.check.models import Check, Check_Report_AWS
|
||||
from prowler.lib.utils.utils import (
|
||||
SecretsScanError,
|
||||
annotate_verified_secrets,
|
||||
detect_secrets_scan_batch,
|
||||
)
|
||||
from prowler.providers.aws.services.ecr.ecr_client import ecr_client
|
||||
|
||||
_SAFE_ENVIRONMENT_VARIABLE_NAME = re.compile(r"[A-Za-z_][A-Za-z0-9_]*")
|
||||
|
||||
|
||||
class ecr_repository_image_no_secrets(Check):
|
||||
"""Ensure the latest ECR repository image embeds no hardcoded secrets.
|
||||
|
||||
The most recently pushed image in every ECR repository is resolved to a
|
||||
single scannable manifest (a multi-arch image resolves to one platform's
|
||||
manifest; other architectures in the same manifest list are not
|
||||
scanned) and scanned for plaintext secrets in its configuration
|
||||
(environment variables, build history) and every filesystem layer's
|
||||
file contents. Older tagged images are not scanned.
|
||||
- PASS: no secrets detected and the whole image was scanned.
|
||||
- FAIL: a potential secret was detected; the variable, build step, or
|
||||
file is reported, never the secret value.
|
||||
- MANUAL: the image could not be scanned in full, so a clean result would
|
||||
be misleading -- the manifest could not be retrieved or resolved, the
|
||||
scan itself failed, or part of the image exceeded configured size limits
|
||||
or could not be retrieved.
|
||||
"""
|
||||
|
||||
def execute(self) -> list[Check_Report_AWS]:
|
||||
"""Execute the check logic.
|
||||
|
||||
Returns:
|
||||
A list of reports containing the result of the check.
|
||||
"""
|
||||
findings = []
|
||||
secrets_ignore_patterns = ecr_client.audit_config.get(
|
||||
"secrets_ignore_patterns", []
|
||||
)
|
||||
validate = ecr_client.audit_config.get("secrets_validate", False)
|
||||
|
||||
# Phase 1: collect. The service yields (repository, image, scan_data)
|
||||
# lazily, downloading each image's manifest, config, and layers; each
|
||||
# image contributes an env/history/file payload per scannable unit so
|
||||
# a finding's key maps back to a variable, build step, or file.
|
||||
scanned = []
|
||||
|
||||
def image_payloads():
|
||||
"""Yield keyed scan payloads, recording each image into `scanned`."""
|
||||
for repository, image, scan_data in ecr_client._get_image_scan_data():
|
||||
index = len(scanned)
|
||||
scanned.append((repository, image, scan_data))
|
||||
if scan_data is None or isinstance(scan_data, Exception):
|
||||
continue
|
||||
for env_index, entry in enumerate(scan_data.env):
|
||||
yield (index, f"environment:{env_index}"), entry
|
||||
for history_index, entry in enumerate(scan_data.history):
|
||||
yield (index, f"history:{history_index}"), entry
|
||||
for file_index, scanned_file in enumerate(scan_data.files):
|
||||
yield (index, f"file:{file_index}"), scanned_file.content
|
||||
# Free the file's contents once handed to the scanner. The
|
||||
# report phase needs only its path and layer digest, so
|
||||
# retained memory stays flat instead of growing with the
|
||||
# number of repositories scanned.
|
||||
scanned_file.content = ""
|
||||
|
||||
# Phase 2: batch — one call, chunked Kingfisher subprocesses. This
|
||||
# must fully consume image_payloads() so every image is appended to
|
||||
# `scanned` before Phase 3 runs; detect_secrets_scan_batch does so
|
||||
# today, but a future short-circuit there would silently drop images
|
||||
# from the report loop.
|
||||
scan_error = None
|
||||
try:
|
||||
batch_results = detect_secrets_scan_batch(
|
||||
image_payloads(),
|
||||
excluded_secrets=secrets_ignore_patterns,
|
||||
validate=validate,
|
||||
)
|
||||
except SecretsScanError as error:
|
||||
batch_results = {}
|
||||
scan_error = error
|
||||
|
||||
if scan_error:
|
||||
# The scan failed and the payload generator may not have been
|
||||
# consumed, so build the MANUAL reports from the repositories
|
||||
# themselves rather than risk a false PASS or a missing finding.
|
||||
for registry in ecr_client.registries.values():
|
||||
for repository in registry.repositories:
|
||||
image = ecr_client._get_scan_target_image(repository)
|
||||
if isinstance(image, Exception):
|
||||
findings.append(
|
||||
self._build_scan_error_report(repository, image)
|
||||
)
|
||||
elif image is not None:
|
||||
report = self._build_report(repository, image)
|
||||
report.status = "MANUAL"
|
||||
report.status_extended = (
|
||||
f"Could not scan image '{image.latest_tag}' "
|
||||
f"({image.latest_digest}) of ECR repository "
|
||||
f"{repository.name} for secrets: {scan_error}; "
|
||||
f"manual review is required."
|
||||
)
|
||||
findings.append(report)
|
||||
return findings
|
||||
|
||||
# Phase 3: report — one finding per scanned image.
|
||||
for index, (repository, image, scan_data) in enumerate(scanned):
|
||||
if isinstance(scan_data, Exception):
|
||||
findings.append(self._build_scan_error_report(repository, scan_data))
|
||||
continue
|
||||
report = self._build_report(repository, image)
|
||||
image_reference = (
|
||||
f"image '{image.latest_tag}' ({image.latest_digest}) of ECR "
|
||||
f"repository {repository.name}"
|
||||
)
|
||||
|
||||
if scan_data is None:
|
||||
report.status = "MANUAL"
|
||||
report.status_extended = (
|
||||
f"Could not resolve or retrieve the manifest of the "
|
||||
f"{image_reference} to scan it for secrets; manual "
|
||||
f"review is required."
|
||||
)
|
||||
findings.append(report)
|
||||
continue
|
||||
|
||||
env_findings_by_index = {
|
||||
int(key[1].split(":", 1)[1]): entry_secrets
|
||||
for key, entry_secrets in batch_results.items()
|
||||
if key[0] == index and key[1].startswith("environment:")
|
||||
}
|
||||
history_findings_by_index = {
|
||||
int(key[1].split(":", 1)[1]): entry_secrets
|
||||
for key, entry_secrets in batch_results.items()
|
||||
if key[0] == index and key[1].startswith("history:")
|
||||
}
|
||||
file_findings_by_index = {
|
||||
int(key[1].split(":", 1)[1]): file_secrets
|
||||
for key, file_secrets in batch_results.items()
|
||||
if key[0] == index and key[1].startswith("file:")
|
||||
}
|
||||
|
||||
if (
|
||||
env_findings_by_index
|
||||
or history_findings_by_index
|
||||
or file_findings_by_index
|
||||
):
|
||||
secrets_found = []
|
||||
all_secrets = []
|
||||
|
||||
for env_index, env_findings in env_findings_by_index.items():
|
||||
variable = None
|
||||
if 0 <= env_index < len(scan_data.env):
|
||||
entry = scan_data.env[env_index]
|
||||
# Only a well-formed "NAME=value" entry has a name safe
|
||||
# to report; an entry with no "=" may itself be the
|
||||
# secret, so it is never echoed back.
|
||||
if "=" in entry:
|
||||
candidate = entry.split("=", 1)[0]
|
||||
if _SAFE_ENVIRONMENT_VARIABLE_NAME.fullmatch(candidate):
|
||||
variable = candidate
|
||||
all_secrets.extend(env_findings)
|
||||
for secret in env_findings:
|
||||
if variable is not None:
|
||||
secrets_found.append(
|
||||
f"{secret['type']} in environment variable {variable}"
|
||||
)
|
||||
else:
|
||||
secrets_found.append(
|
||||
f"{secret['type']} in image environment variables"
|
||||
)
|
||||
for (
|
||||
history_index,
|
||||
history_findings,
|
||||
) in history_findings_by_index.items():
|
||||
all_secrets.extend(history_findings)
|
||||
for secret in history_findings:
|
||||
secrets_found.append(
|
||||
f"{secret['type']} in image history step {history_index + 1}"
|
||||
)
|
||||
for file_index, file_secrets in file_findings_by_index.items():
|
||||
scanned_file = scan_data.files[file_index]
|
||||
all_secrets.extend(file_secrets)
|
||||
for secret in file_secrets:
|
||||
secrets_found.append(
|
||||
f"{secret['type']} in file {scanned_file.path} "
|
||||
f"(layer {scanned_file.layer_digest})"
|
||||
)
|
||||
|
||||
report.status = "FAIL"
|
||||
report.status_extended = (
|
||||
f"Potential {'secrets' if len(secrets_found) > 1 else 'secret'} "
|
||||
f"found in the {image_reference} -> {', '.join(secrets_found)}."
|
||||
)
|
||||
if scan_data.truncated:
|
||||
report.status_extended += (
|
||||
" Some of the image could not be retrieved or exceeded "
|
||||
"configured size limits and was not scanned."
|
||||
)
|
||||
annotate_verified_secrets(report, all_secrets)
|
||||
elif scan_data.truncated:
|
||||
# No secrets in what was scanned, but coverage was incomplete
|
||||
# (size/count limits, or the config could not be retrieved), so
|
||||
# a clean result would be misleading.
|
||||
report.status = "MANUAL"
|
||||
report.status_extended = (
|
||||
f"No secrets were found in the scanned portion of the "
|
||||
f"{image_reference}, but part of it could not be retrieved "
|
||||
f"or exceeded configured size limits and was not scanned; "
|
||||
f"manual review is required."
|
||||
)
|
||||
else:
|
||||
report.status = "PASS"
|
||||
report.status_extended = f"No secrets found in the {image_reference}."
|
||||
|
||||
findings.append(report)
|
||||
|
||||
return findings
|
||||
|
||||
def _build_scan_error_report(self, repository, error) -> Check_Report_AWS:
|
||||
"""Build a repository-level report for a latest-image lookup failure."""
|
||||
report = Check_Report_AWS(metadata=self.metadata(), resource=repository)
|
||||
report.status = "MANUAL"
|
||||
report.status_extended = (
|
||||
f"Could not determine the latest image of ECR repository "
|
||||
f"{repository.name}: {error}; manual review is required."
|
||||
)
|
||||
return report
|
||||
|
||||
def _build_report(self, repository, image) -> Check_Report_AWS:
|
||||
"""Build a report scoped to a single image within a repository.
|
||||
|
||||
ECR images have no ARN of their own, so the repository's ARN is
|
||||
reused with the image digest appended as a synthetic suffix,
|
||||
mirroring how other sub-resource checks (e.g. CodeArtifact packages
|
||||
within a repository) identify per-item findings.
|
||||
"""
|
||||
report = Check_Report_AWS(metadata=self.metadata(), resource=repository)
|
||||
digest_short = image.latest_digest.split(":")[-1][:12]
|
||||
report.resource_id = f"{repository.name}:{image.latest_tag}@{digest_short}"
|
||||
report.resource_arn = f"{repository.arn}/image/{digest_short}"
|
||||
return report
|
||||
@@ -1,4 +1,3 @@
|
||||
from concurrent.futures import FIRST_COMPLETED, Future, ThreadPoolExecutor, wait
|
||||
from datetime import datetime
|
||||
from json import loads
|
||||
from typing import Optional
|
||||
@@ -9,21 +8,10 @@ from pydantic.v1 import BaseModel
|
||||
from prowler.lib.logger import logger
|
||||
from prowler.lib.scan_filters.scan_filters import is_resource_filtered
|
||||
from prowler.providers.aws.lib.service.service import AWSService
|
||||
from prowler.providers.aws.services.ecr.image_inspection import ImageInspector
|
||||
|
||||
# Concurrency for the image-scan pipeline (_get_image_scan_data). Kept smaller
|
||||
# than the shared MAX_WORKERS metadata pool because each task can retain up to
|
||||
# MAX_LAYER_DOWNLOAD_BYTES compressed plus MAX_TOTAL_BYTES_PER_IMAGE decompressed
|
||||
# content (see image_inspection), so a high worker count would multiply peak
|
||||
# memory into several GB.
|
||||
IMAGE_SCAN_MAX_WORKERS = 4
|
||||
|
||||
|
||||
class ECR(AWSService):
|
||||
"""AWS Elastic Container Registry service."""
|
||||
|
||||
def __init__(self, provider):
|
||||
"""Discover registries, repositories, policies, and image metadata."""
|
||||
# Call AWSService's __init__
|
||||
super().__init__(__class__.__name__, provider)
|
||||
self.registry_id = self.audited_account
|
||||
@@ -36,7 +24,6 @@ class ECR(AWSService):
|
||||
self.__threading_call__(self._list_tags_for_resource)
|
||||
|
||||
def _describe_registries_and_repositories(self, regional_client):
|
||||
"""Populate the registry and its repositories for one region."""
|
||||
logger.info("ECR - Describing registries and repositories...")
|
||||
regional_registry_repositories = []
|
||||
try:
|
||||
@@ -81,7 +68,6 @@ class ECR(AWSService):
|
||||
)
|
||||
|
||||
def _describe_repository_policies(self, regional_client):
|
||||
"""Fetch and attach each repository's resource policy, if any."""
|
||||
logger.info("ECR - Describing repository policies...")
|
||||
try:
|
||||
if regional_client.region in self.registries:
|
||||
@@ -110,7 +96,6 @@ class ECR(AWSService):
|
||||
)
|
||||
|
||||
def _get_repository_lifecycle_policy(self, regional_client):
|
||||
"""Fetch and attach each repository's lifecycle policy, if any."""
|
||||
logger.info("ECR - Getting repository lifecycle policy...")
|
||||
try:
|
||||
if regional_client.region in self.registries:
|
||||
@@ -139,7 +124,6 @@ class ECR(AWSService):
|
||||
)
|
||||
|
||||
def _get_image_details(self, regional_client):
|
||||
"""Populate each scan-on-push repository's scannable, tagged images."""
|
||||
logger.info("ECR - Getting images details...")
|
||||
try:
|
||||
if regional_client.region in self.registries:
|
||||
@@ -174,7 +158,12 @@ class ECR(AWSService):
|
||||
image_scan_findings_field_name = (
|
||||
"imageScanFindingsSummary"
|
||||
)
|
||||
type = ECR._artifact_type(artifact_media_type)
|
||||
if "docker" in artifact_media_type:
|
||||
type = "Docker"
|
||||
elif "oci" in artifact_media_type:
|
||||
type = "OCI"
|
||||
else:
|
||||
type = ""
|
||||
|
||||
# If imageScanStatus is not present or imageScanFindingsSummary is missing,
|
||||
# we need to call DescribeImageScanFindings because AWS' new version of
|
||||
@@ -263,7 +252,6 @@ class ECR(AWSService):
|
||||
)
|
||||
|
||||
def _list_tags_for_resource(self, regional_client):
|
||||
"""Fetch and attach each repository's resource tags."""
|
||||
logger.info("ECR - List Tags...")
|
||||
try:
|
||||
if regional_client.region in self.registries:
|
||||
@@ -292,7 +280,6 @@ class ECR(AWSService):
|
||||
)
|
||||
|
||||
def _get_registry_scanning_configuration(self, regional_client):
|
||||
"""Fetch and attach the registry's image-scanning configuration."""
|
||||
logger.info("ECR - Getting Registry Scanning Configuration...")
|
||||
try:
|
||||
if regional_client.region in self.registries:
|
||||
@@ -328,155 +315,6 @@ class ECR(AWSService):
|
||||
f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
|
||||
def _get_image_scan_data(self):
|
||||
"""Lazily fetch manifest, config, and layer file contents for the latest image.
|
||||
|
||||
Only the most recently pushed scannable image in each repository is
|
||||
scanned (resolved via _get_scan_target_image, which also covers
|
||||
scan-on-push-disabled repositories) to bound cost on repositories
|
||||
with many tags.
|
||||
|
||||
Not called from __init__: this is only invoked by the
|
||||
ecr_repository_image_no_secrets check, since it downloads and
|
||||
decompresses image layers and is significantly more expensive than
|
||||
the metadata gathered above. A dedicated, smaller thread pool bounds
|
||||
the concurrency (and therefore the peak memory) of this heavy
|
||||
pipeline independently of the shared metadata pool.
|
||||
|
||||
Yields:
|
||||
Tuple of repository, optional image, and scan data. The third item
|
||||
is an exception when the authoritative image lookup failed.
|
||||
"""
|
||||
logger.info("ECR - Fetching image manifests, configs, and layers...")
|
||||
inspector = ImageInspector()
|
||||
|
||||
def images_to_fetch():
|
||||
for registry in self.registries.values():
|
||||
for repository in registry.repositories:
|
||||
image = self._get_scan_target_image(repository)
|
||||
if isinstance(image, Exception):
|
||||
yield repository, None, image
|
||||
elif image is not None:
|
||||
yield repository, image, None
|
||||
|
||||
with ThreadPoolExecutor(max_workers=IMAGE_SCAN_MAX_WORKERS) as executor:
|
||||
pending = {}
|
||||
targets = iter(images_to_fetch())
|
||||
|
||||
def submit_next():
|
||||
try:
|
||||
repository, image, error = next(targets)
|
||||
except StopIteration:
|
||||
return False
|
||||
if error:
|
||||
future = Future()
|
||||
future.set_result(error)
|
||||
else:
|
||||
client = self.regional_clients[repository.region]
|
||||
registry_id = self.registries[repository.region].id
|
||||
future = executor.submit(
|
||||
inspector.fetch_image_scan_data,
|
||||
client,
|
||||
registry_id,
|
||||
repository.name,
|
||||
image.latest_digest,
|
||||
)
|
||||
pending[future] = (repository, image)
|
||||
return True
|
||||
|
||||
for _ in range(IMAGE_SCAN_MAX_WORKERS):
|
||||
if not submit_next():
|
||||
break
|
||||
|
||||
while pending:
|
||||
completed, _ = wait(pending, return_when=FIRST_COMPLETED)
|
||||
for future in completed:
|
||||
repository, image = pending.pop(future)
|
||||
scan_data = None
|
||||
try:
|
||||
scan_data = future.result()
|
||||
except Exception as error:
|
||||
logger.error(
|
||||
f"{repository.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
yield repository, image, scan_data
|
||||
submit_next()
|
||||
|
||||
@staticmethod
|
||||
def _artifact_type(artifact_media_type: Optional[str]) -> str:
|
||||
"""Map an image's artifact media type to a short image type label.
|
||||
|
||||
Returns:
|
||||
"Docker", "OCI", or "" for an unrecognized/absent media type.
|
||||
"""
|
||||
if artifact_media_type:
|
||||
if "docker" in artifact_media_type:
|
||||
return "Docker"
|
||||
if "oci" in artifact_media_type:
|
||||
return "OCI"
|
||||
return ""
|
||||
|
||||
def _get_scan_target_image(self, repository) -> Optional["ImageDetails"]:
|
||||
"""Resolve the latest scannable image to scan for secrets.
|
||||
|
||||
Secret scanning is independent of ECR's vulnerability scanning
|
||||
configuration, but `_get_image_details` only populates
|
||||
`images_details` for scan-on-push-enabled repositories. For a
|
||||
repository with scan-on-push disabled (empty `images_details`), this
|
||||
performs a dedicated `describe_images` lookup to find the most
|
||||
recently pushed scannable image, so those repositories are not
|
||||
silently skipped.
|
||||
|
||||
The synthesized ImageDetails is deliberately NOT appended to
|
||||
`repository.images_details`: other checks (e.g.
|
||||
ecr_repositories_scan_vulnerabilities_in_latest_image) treat any
|
||||
entry there as a scanned image and would FAIL scan-on-push-disabled
|
||||
repositories that currently produce no finding.
|
||||
|
||||
Returns:
|
||||
The latest scannable ImageDetails, or None if the repository has
|
||||
no scannable image; an exception if the lookup failed.
|
||||
"""
|
||||
latest = repository.images_details[-1] if repository.images_details else None
|
||||
try:
|
||||
client = self.regional_clients[repository.region]
|
||||
describe_images_paginator = client.get_paginator("describe_images")
|
||||
for page in describe_images_paginator.paginate(
|
||||
registryId=self.registries[repository.region].id,
|
||||
repositoryName=repository.name,
|
||||
PaginationConfig={"PageSize": 1000},
|
||||
):
|
||||
for image in page["imageDetails"]:
|
||||
if image is None:
|
||||
continue
|
||||
artifact_media_type = image.get("artifactMediaType", None)
|
||||
tags = image.get("imageTags", [])
|
||||
if not ECR._is_artifact_scannable(artifact_media_type, tags):
|
||||
continue
|
||||
image_pushed_at = image.get("imagePushedAt")
|
||||
if image_pushed_at is None:
|
||||
continue
|
||||
# Match _get_image_details' "sort ascending, take last"
|
||||
# selection: on equal push dates the later-listed image
|
||||
# wins, so `<` (not `<=`) is used to replace on ties.
|
||||
if latest is not None and image_pushed_at < latest.image_pushed_at:
|
||||
continue
|
||||
latest = ImageDetails(
|
||||
latest_tag=image.get("imageTags", ["None"])[0],
|
||||
image_pushed_at=image_pushed_at,
|
||||
latest_digest=image.get("imageDigest"),
|
||||
scan_findings_status=None,
|
||||
scan_findings_severity_count=None,
|
||||
artifact_media_type=artifact_media_type,
|
||||
type=ECR._artifact_type(artifact_media_type),
|
||||
)
|
||||
return latest
|
||||
except Exception as error:
|
||||
logger.error(
|
||||
f"{repository.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
return error
|
||||
|
||||
@staticmethod
|
||||
def _is_artifact_scannable(artifact_media_type: str, tags: list[str] = []) -> bool:
|
||||
"""
|
||||
@@ -517,16 +355,12 @@ class ECR(AWSService):
|
||||
|
||||
|
||||
class FindingSeverityCounts(BaseModel):
|
||||
"""Count of an image's vulnerability scan findings by severity."""
|
||||
|
||||
critical: int
|
||||
high: int
|
||||
medium: int
|
||||
|
||||
|
||||
class ImageDetails(BaseModel):
|
||||
"""A single scannable, tagged image within an ECR repository."""
|
||||
|
||||
latest_tag: str
|
||||
latest_digest: str
|
||||
image_pushed_at: datetime
|
||||
@@ -537,8 +371,6 @@ class ImageDetails(BaseModel):
|
||||
|
||||
|
||||
class Repository(BaseModel):
|
||||
"""An ECR repository and its policies, images, and tags."""
|
||||
|
||||
name: str
|
||||
arn: str
|
||||
region: str
|
||||
@@ -552,15 +384,11 @@ class Repository(BaseModel):
|
||||
|
||||
|
||||
class ScanningRule(BaseModel):
|
||||
"""A registry-level image-scanning rule and its repository filters."""
|
||||
|
||||
scan_frequency: str
|
||||
scan_filters: list[dict]
|
||||
|
||||
|
||||
class Registry(BaseModel):
|
||||
"""An ECR registry: its repositories and scanning configuration."""
|
||||
|
||||
id: str
|
||||
arn: str
|
||||
region: str
|
||||
|
||||
@@ -1,494 +0,0 @@
|
||||
import gzip
|
||||
import tarfile
|
||||
from contextlib import contextmanager
|
||||
from json import loads
|
||||
from typing import Optional
|
||||
|
||||
import requests
|
||||
import zstandard
|
||||
from pydantic.v1 import BaseModel
|
||||
|
||||
from prowler.lib.logger import logger
|
||||
|
||||
# Manifest media types that wrap several per-architecture manifests (a "fat
|
||||
# manifest") rather than a single scannable image.
|
||||
_MANIFEST_LIST_MEDIA_TYPES = {
|
||||
"application/vnd.docker.distribution.manifest.list.v2+json",
|
||||
"application/vnd.oci.image.index.v1+json",
|
||||
}
|
||||
|
||||
# Compressed size of a single layer, checked against the manifest-declared
|
||||
# size before downloading, and re-checked against actual bytes received.
|
||||
MAX_LAYER_DOWNLOAD_BYTES = 100 * 1024 * 1024
|
||||
# Size of a single extracted file considered for scanning.
|
||||
MAX_FILE_BYTES = 1 * 1024 * 1024
|
||||
# Hard cap on the number of files scanned per image, across all its layers.
|
||||
MAX_FILES_PER_IMAGE = 5000
|
||||
# Hard cap on total decompressed bytes read per image, across all its layers.
|
||||
MAX_TOTAL_BYTES_PER_IMAGE = 500 * 1024 * 1024
|
||||
LAYER_DOWNLOAD_TIMEOUT_SECONDS = 30
|
||||
|
||||
|
||||
class _LayerTooLargeError(Exception):
|
||||
"""Raised when a streamed layer exceeds MAX_LAYER_DOWNLOAD_BYTES."""
|
||||
|
||||
|
||||
class _ImageTooLargeError(Exception):
|
||||
"""Raised when decompressed image streams exceed their shared budget."""
|
||||
|
||||
|
||||
class _CappedLayerReader:
|
||||
"""A minimal read-only file object that caps the bytes it will yield.
|
||||
|
||||
Wraps a streaming HTTP body (urllib3's ``response.raw``) so ``tarfile`` can
|
||||
read a gzip/uncompressed layer incrementally while enforcing an upper bound
|
||||
on the compressed bytes consumed. A manifest that under-declares a layer's
|
||||
size (the declared size is pre-checked separately) cannot make this buffer
|
||||
an unbounded amount of untrusted data: once ``max_bytes`` is exceeded the
|
||||
read raises ``_LayerTooLargeError`` instead of continuing.
|
||||
"""
|
||||
|
||||
def __init__(self, raw, max_bytes: int):
|
||||
"""Store the underlying raw stream and the remaining byte budget."""
|
||||
self._raw = raw
|
||||
self._remaining = max_bytes
|
||||
|
||||
def read(self, size: int = -1) -> bytes:
|
||||
"""Read up to ``size`` bytes, never exceeding the remaining budget.
|
||||
|
||||
A negative/None ``size`` (``read all``) is treated as "read what's left
|
||||
of the budget, plus one" so a lying stream can never pull an unbounded
|
||||
amount into memory and an over-cap layer is still detected.
|
||||
"""
|
||||
if size is None or size < 0:
|
||||
size = self._remaining + 1
|
||||
to_read = min(size, self._remaining + 1)
|
||||
chunk = self._raw.read(to_read)
|
||||
self._remaining -= len(chunk)
|
||||
if self._remaining < 0:
|
||||
raise _LayerTooLargeError()
|
||||
return chunk
|
||||
|
||||
|
||||
class _DecompressedByteBudget:
|
||||
"""Track every decompressed byte consumed across an image's tar streams."""
|
||||
|
||||
def __init__(self, max_bytes: int):
|
||||
"""Set the shared decompressed-byte allowance."""
|
||||
self.remaining = max_bytes
|
||||
|
||||
def wrap(self, raw):
|
||||
"""Return a reader that charges bytes consumed from ``raw``."""
|
||||
return _BudgetedReader(raw, self)
|
||||
|
||||
|
||||
class _BudgetedReader:
|
||||
"""Charge all stream reads against a shared decompressed-byte budget."""
|
||||
|
||||
def __init__(self, raw, budget: _DecompressedByteBudget):
|
||||
self._raw = raw
|
||||
self._budget = budget
|
||||
|
||||
def read(self, size: int = -1) -> bytes:
|
||||
"""Read without allowing the shared budget to be exceeded."""
|
||||
if size is None or size < 0:
|
||||
size = self._budget.remaining + 1
|
||||
chunk = self._raw.read(min(size, self._budget.remaining + 1))
|
||||
self._budget.remaining -= len(chunk)
|
||||
if self._budget.remaining < 0:
|
||||
raise _ImageTooLargeError()
|
||||
return chunk
|
||||
|
||||
|
||||
class ImageScanFile(BaseModel):
|
||||
"""A single file extracted from an image layer for secret scanning."""
|
||||
|
||||
path: str
|
||||
layer_digest: str
|
||||
content: str
|
||||
|
||||
|
||||
class ImageScanData(BaseModel):
|
||||
"""An image's scannable content: config env/history and layer files."""
|
||||
|
||||
env: list[str] = []
|
||||
history: list[str] = []
|
||||
files: list[ImageScanFile] = []
|
||||
# True when part of the image was not scanned -- a layer/file exceeded a
|
||||
# configured size or count limit, or the config blob could not be
|
||||
# retrieved/parsed -- so a clean result can be reported as MANUAL
|
||||
# (coverage incomplete) rather than a false PASS.
|
||||
truncated: bool = False
|
||||
|
||||
|
||||
class ImageInspector:
|
||||
"""Bounded, opt-in extraction of an ECR image's scannable content.
|
||||
|
||||
Given a boto3 ECR client and an image digest, resolves the image's
|
||||
manifest (handling multi-arch manifest lists and skipping attestation
|
||||
manifests) and returns its configuration (environment variables, build
|
||||
history) and every filesystem layer's file contents, subject to this
|
||||
module's size and count limits.
|
||||
|
||||
This is deliberately isolated from the ECR service so a future check can
|
||||
reuse the bounded extraction without the service downloading and
|
||||
decompressing image layers by default: the service only pays this cost
|
||||
when a check explicitly drives the inspector.
|
||||
"""
|
||||
|
||||
def fetch_image_scan_data(
|
||||
self, client, registry_id, repository_name, image_digest
|
||||
) -> Optional[ImageScanData]:
|
||||
"""Resolve one image's manifest and return its scannable content.
|
||||
|
||||
Downloads the config blob (environment variables, build history)
|
||||
and every filesystem layer's file contents, bounded by the module's
|
||||
size/count limits.
|
||||
|
||||
Returns:
|
||||
An ImageScanData, or None if the manifest could not be resolved.
|
||||
"""
|
||||
manifest, truncated = self._resolve_image_manifest(
|
||||
client, registry_id, repository_name, image_digest
|
||||
)
|
||||
if manifest is None:
|
||||
return None
|
||||
|
||||
env = []
|
||||
history = []
|
||||
|
||||
config_digest = (manifest.get("config") or {}).get("digest")
|
||||
if config_digest:
|
||||
config_bytes = self._download_layer(
|
||||
client,
|
||||
registry_id,
|
||||
repository_name,
|
||||
config_digest,
|
||||
max_bytes=MAX_FILE_BYTES,
|
||||
)
|
||||
if config_bytes is None:
|
||||
# The config blob (env vars, build history) could not be
|
||||
# retrieved. Empty env/history would be indistinguishable
|
||||
# from a clean config, so mark coverage incomplete instead
|
||||
# of risking a false PASS.
|
||||
truncated = True
|
||||
else:
|
||||
try:
|
||||
config_json = loads(config_bytes)
|
||||
env = config_json.get("config", {}).get("Env", []) or []
|
||||
history = [
|
||||
step.get("created_by", "")
|
||||
for step in config_json.get("history", [])
|
||||
if step.get("created_by")
|
||||
]
|
||||
except Exception as error:
|
||||
logger.warning(
|
||||
f"{repository_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
truncated = True
|
||||
|
||||
files = []
|
||||
decompressed_budget = _DecompressedByteBudget(MAX_TOTAL_BYTES_PER_IMAGE)
|
||||
for layer in manifest.get("layers", []):
|
||||
if len(files) >= MAX_FILES_PER_IMAGE or decompressed_budget.remaining <= 0:
|
||||
truncated = True
|
||||
break
|
||||
|
||||
layer_digest = layer.get("digest")
|
||||
layer_size = layer.get("size", 0)
|
||||
if layer_size and layer_size > MAX_LAYER_DOWNLOAD_BYTES:
|
||||
truncated = True
|
||||
continue
|
||||
|
||||
try:
|
||||
with self._open_layer_tar_stream(
|
||||
client,
|
||||
registry_id,
|
||||
repository_name,
|
||||
layer_digest,
|
||||
layer.get("mediaType", ""),
|
||||
decompressed_budget,
|
||||
) as tar_stream:
|
||||
if tar_stream is None:
|
||||
truncated = True
|
||||
continue
|
||||
for member in tar_stream:
|
||||
if len(files) >= MAX_FILES_PER_IMAGE:
|
||||
truncated = True
|
||||
break
|
||||
if not member.isfile():
|
||||
continue
|
||||
base_name = member.name.rsplit("/", 1)[-1]
|
||||
if base_name.startswith(".wh."):
|
||||
# Whiteout marker: a deletion recorded by the union
|
||||
# filesystem, not real file content.
|
||||
continue
|
||||
if member.size > MAX_FILE_BYTES:
|
||||
truncated = True
|
||||
continue
|
||||
try:
|
||||
content = (
|
||||
tar_stream.extractfile(member).read().decode("latin-1")
|
||||
)
|
||||
except _LayerTooLargeError:
|
||||
# Over-cap while reading this member: truncate the
|
||||
# whole layer rather than silently skipping one file.
|
||||
raise
|
||||
except Exception:
|
||||
continue
|
||||
files.append(
|
||||
ImageScanFile(
|
||||
path=member.name,
|
||||
layer_digest=layer_digest,
|
||||
content=content,
|
||||
)
|
||||
)
|
||||
except _LayerTooLargeError:
|
||||
# The layer streamed more bytes than MAX_LAYER_DOWNLOAD_BYTES
|
||||
# (a manifest under-declaring its size); skip it and disclose
|
||||
# the partial coverage rather than buffer unbounded data.
|
||||
truncated = True
|
||||
continue
|
||||
except _ImageTooLargeError:
|
||||
truncated = True
|
||||
break
|
||||
|
||||
return ImageScanData(env=env, history=history, files=files, truncated=truncated)
|
||||
|
||||
def _resolve_image_manifest(
|
||||
self, client, registry_id, repository_name, image_digest
|
||||
) -> tuple[Optional[dict], bool]:
|
||||
"""Resolve an image digest to a single scannable image manifest.
|
||||
|
||||
Multi-arch images are stored as a manifest list/image index pointing
|
||||
at one manifest per platform (plus, often, an attestation manifest
|
||||
that isn't a real image). This picks one real platform manifest to
|
||||
scan; the other architectures in the same list are not scanned.
|
||||
"""
|
||||
try:
|
||||
manifest, media_type = self._batch_get_manifest(
|
||||
client, registry_id, repository_name, image_digest
|
||||
)
|
||||
if manifest is None:
|
||||
return None, False
|
||||
|
||||
truncated = False
|
||||
if media_type in _MANIFEST_LIST_MEDIA_TYPES:
|
||||
truncated = True
|
||||
child_digest = self._select_child_manifest_digest(manifest)
|
||||
if not child_digest:
|
||||
return None, truncated
|
||||
manifest, _ = self._batch_get_manifest(
|
||||
client, registry_id, repository_name, child_digest
|
||||
)
|
||||
if manifest is not None and not (
|
||||
manifest.get("config") or manifest.get("layers")
|
||||
):
|
||||
# A resolved manifest with neither a config nor layers has
|
||||
# nothing to scan (e.g. a nested manifest list, or an
|
||||
# unsupported manifest shape) -- treat it as unresolvable so
|
||||
# the caller reports MANUAL instead of a false PASS.
|
||||
return None, truncated
|
||||
return manifest, truncated
|
||||
except Exception as error:
|
||||
logger.error(
|
||||
f"{client.meta.region_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
return None, False
|
||||
|
||||
@staticmethod
|
||||
def _batch_get_manifest(client, registry_id, repository_name, image_digest):
|
||||
"""Fetch and parse the raw manifest JSON for a single image digest.
|
||||
|
||||
Returns:
|
||||
A (manifest, media_type) tuple, or (None, None) if not found.
|
||||
"""
|
||||
response = client.batch_get_image(
|
||||
registryId=registry_id,
|
||||
repositoryName=repository_name,
|
||||
imageIds=[{"imageDigest": image_digest}],
|
||||
)
|
||||
images = response.get("images", [])
|
||||
if not images:
|
||||
return None, None
|
||||
manifest = loads(images[0]["imageManifest"])
|
||||
media_type = manifest.get("mediaType") or images[0].get(
|
||||
"imageManifestMediaType"
|
||||
)
|
||||
return manifest, media_type
|
||||
|
||||
@staticmethod
|
||||
def _select_child_manifest_digest(manifest_list: dict) -> Optional[str]:
|
||||
"""Pick one real platform manifest's digest from a manifest list.
|
||||
|
||||
Prefers linux/amd64, falling back to the first remaining candidate
|
||||
once attestation manifests (platform "unknown/unknown", or
|
||||
annotated as an attestation manifest) are excluded.
|
||||
|
||||
Returns:
|
||||
The chosen manifest's digest, or None if no candidate remains.
|
||||
"""
|
||||
candidates = []
|
||||
for entry in manifest_list.get("manifests", []):
|
||||
platform = entry.get("platform", {}) or {}
|
||||
annotations = entry.get("annotations", {}) or {}
|
||||
if (
|
||||
platform.get("architecture") == "unknown"
|
||||
or platform.get("os") == "unknown"
|
||||
):
|
||||
# Attestation manifests (SBOMs, provenance, signatures) are
|
||||
# attached to the index as "unknown/unknown" platform entries.
|
||||
continue
|
||||
if annotations.get("vnd.docker.reference.type") == "attestation-manifest":
|
||||
continue
|
||||
candidates.append(entry)
|
||||
|
||||
for entry in candidates:
|
||||
platform = entry.get("platform", {}) or {}
|
||||
if (
|
||||
platform.get("architecture") == "amd64"
|
||||
and platform.get("os") == "linux"
|
||||
):
|
||||
return entry.get("digest")
|
||||
|
||||
return candidates[0].get("digest") if candidates else None
|
||||
|
||||
@staticmethod
|
||||
def _get_layer_download_url(
|
||||
client, registry_id, repository_name, layer_digest
|
||||
) -> Optional[str]:
|
||||
"""Resolve the presigned download URL for one layer or config blob.
|
||||
|
||||
Returns:
|
||||
The presigned URL, or None if ECR did not return one.
|
||||
"""
|
||||
response = client.get_download_url_for_layer(
|
||||
registryId=registry_id,
|
||||
repositoryName=repository_name,
|
||||
layerDigest=layer_digest,
|
||||
)
|
||||
return response.get("downloadUrl")
|
||||
|
||||
@staticmethod
|
||||
def _download_layer(
|
||||
client, registry_id, repository_name, layer_digest, max_bytes=None
|
||||
) -> Optional[bytes]:
|
||||
"""Download one layer or config blob via its presigned URL.
|
||||
|
||||
Streams the response, aborting once `max_bytes` is exceeded, so a
|
||||
lying or oversized blob is never buffered in full. Used for the config
|
||||
blob and for zstd layers (which cannot be streamed into tarfile);
|
||||
gzip/uncompressed layers are streamed by `_open_layer_tar_stream`.
|
||||
|
||||
Returns:
|
||||
The blob's bytes, or None if it could not be downloaded or
|
||||
exceeded `max_bytes`.
|
||||
"""
|
||||
try:
|
||||
download_url = ImageInspector._get_layer_download_url(
|
||||
client, registry_id, repository_name, layer_digest
|
||||
)
|
||||
if not download_url:
|
||||
return None
|
||||
|
||||
downloaded = bytearray()
|
||||
with requests.get(
|
||||
download_url,
|
||||
stream=True,
|
||||
timeout=LAYER_DOWNLOAD_TIMEOUT_SECONDS,
|
||||
allow_redirects=False,
|
||||
) as http_response:
|
||||
http_response.raise_for_status()
|
||||
for chunk in http_response.iter_content(chunk_size=1024 * 1024):
|
||||
downloaded.extend(chunk)
|
||||
if max_bytes and len(downloaded) > max_bytes:
|
||||
return None
|
||||
return bytes(downloaded)
|
||||
except Exception as error:
|
||||
logger.warning(
|
||||
f"{repository_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
return None
|
||||
|
||||
@contextmanager
|
||||
def _open_layer_tar_stream(
|
||||
self,
|
||||
client,
|
||||
registry_id,
|
||||
repository_name,
|
||||
layer_digest,
|
||||
media_type: str,
|
||||
decompressed_budget: _DecompressedByteBudget,
|
||||
):
|
||||
"""Yield an open TarFile for one layer, streamed from the download.
|
||||
|
||||
gzip, zstd, and uncompressed tar layers are all streamed straight from
|
||||
the download into `tarfile` (streaming mode reads a file-like object
|
||||
sequentially), so neither the compressed blob nor a decompressed copy is
|
||||
ever buffered in full. A `_CappedLayerReader` enforces
|
||||
`MAX_LAYER_DOWNLOAD_BYTES` on the compressed bytes (guarding a manifest
|
||||
that under-declares the layer size); zstd is decompressed incrementally
|
||||
via `zstandard`'s streaming reader, so a crafted frame can no longer
|
||||
expand unbounded in memory, and the decompressed side is bounded by the
|
||||
caller's per-image budget as it iterates members.
|
||||
|
||||
Yields:
|
||||
An open TarFile, or None for an unrecognized media type or a
|
||||
download/decompression failure. Raises `_LayerTooLargeError` if a
|
||||
streamed layer's compressed bytes exceed `MAX_LAYER_DOWNLOAD_BYTES`.
|
||||
"""
|
||||
if media_type.endswith("gzip"):
|
||||
decompress = "gzip"
|
||||
elif media_type.endswith("zstd"):
|
||||
decompress = "zstd"
|
||||
elif media_type.endswith("tar"):
|
||||
decompress = None
|
||||
else:
|
||||
yield None
|
||||
return
|
||||
|
||||
# Only the setup (URL resolution, connection, tar-header parse) is
|
||||
# guarded here; a failure yields None. The `yield tar_stream` below is
|
||||
# kept out of this try so exceptions raised while the caller iterates
|
||||
# members (e.g. _LayerTooLargeError) propagate instead of triggering a
|
||||
# forbidden second yield.
|
||||
try:
|
||||
download_url = ImageInspector._get_layer_download_url(
|
||||
client, registry_id, repository_name, layer_digest
|
||||
)
|
||||
if not download_url:
|
||||
yield None
|
||||
return
|
||||
http_response = requests.get(
|
||||
download_url,
|
||||
stream=True,
|
||||
timeout=LAYER_DOWNLOAD_TIMEOUT_SECONDS,
|
||||
allow_redirects=False,
|
||||
)
|
||||
try:
|
||||
http_response.raise_for_status()
|
||||
# Cap the compressed bytes read from the network; for zstd,
|
||||
# decompress that capped stream incrementally so the decompressed
|
||||
# data is never materialized in full.
|
||||
source = _CappedLayerReader(http_response.raw, MAX_LAYER_DOWNLOAD_BYTES)
|
||||
if decompress == "gzip":
|
||||
source = gzip.GzipFile(fileobj=source)
|
||||
elif decompress == "zstd":
|
||||
source = zstandard.ZstdDecompressor().stream_reader(source)
|
||||
source = decompressed_budget.wrap(source)
|
||||
tar_stream = tarfile.open(fileobj=source, mode="r|")
|
||||
except (_LayerTooLargeError, _ImageTooLargeError):
|
||||
http_response.close()
|
||||
raise
|
||||
except Exception:
|
||||
http_response.close()
|
||||
raise
|
||||
except Exception as error:
|
||||
logger.warning(
|
||||
f"{repository_name} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
yield None
|
||||
return
|
||||
|
||||
with http_response, tar_stream:
|
||||
yield tar_stream
|
||||
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"Provider": "aws",
|
||||
"CheckID": "rolesanywhere_profile_restricts_session_permissions",
|
||||
"CheckTitle": "IAM Roles Anywhere profiles scope down the vended session permissions",
|
||||
"CheckType": [
|
||||
"Software and Configuration Checks/AWS Security Best Practices"
|
||||
],
|
||||
"ServiceName": "rolesanywhere",
|
||||
"SubServiceName": "",
|
||||
"ResourceIdTemplate": "",
|
||||
"Severity": "medium",
|
||||
"ResourceType": "AwsRolesAnywhereProfile",
|
||||
"ResourceGroup": "security",
|
||||
"Description": "**IAM Roles Anywhere profiles** that reference an administrative role are assessed for **session scoping**. A profile defining neither an inline `sessionPolicy` nor `managedPolicyArns` vends credentials with the full permissions of its roles. It is flagged only when a referenced role is administrative, since an unscoped session on a least-privilege role is already constrained.",
|
||||
"Risk": "Roles Anywhere profiles bind X.509 certificates to IAM roles. When a profile references an administrative role and does not scope the session, vended credentials carry full administrative permissions. An attacker presenting a valid certificate - or planting a rogue trust anchor and profile - gains durable privileged access that rotating IAM keys does not revoke.",
|
||||
"RelatedUrl": "",
|
||||
"AdditionalURLs": [
|
||||
"https://docs.aws.amazon.com/rolesanywhere/latest/userguide/introduction.html",
|
||||
"https://docs.aws.amazon.com/rolesanywhere/latest/APIReference/API_CreateProfile.html",
|
||||
"https://docs.aws.amazon.com/rolesanywhere/latest/userguide/security-best-practices.html"
|
||||
],
|
||||
"Remediation": {
|
||||
"Code": {
|
||||
"CLI": "aws rolesanywhere update-profile --profile-id <profile_id> --session-policy '{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"<least_privilege_actions>\"],\"Resource\":[\"<scoped_resources>\"]}]}'",
|
||||
"NativeIaC": "```yaml\nResources:\n <example_resource_name>:\n Type: AWS::RolesAnywhere::Profile\n Properties:\n Name: scoped-profile\n Enabled: true\n RoleArns:\n - <role_arn>\n SessionPolicy: '{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"<least_privilege_actions>\"],\"Resource\":[\"<scoped_resources>\"]}]}' # FIX: scope down the vended session\n```",
|
||||
"Other": "1. Identify the least-privilege actions the workload actually needs\n2. Attach a sessionPolicy or managedPolicyArns to the Roles Anywhere profile that grants only those actions\n3. Prefer purpose-built roles per workload over broad roles referenced by many profiles\n4. Review trust anchors and profiles regularly for entries you did not create",
|
||||
"Terraform": "```hcl\nresource \"aws_rolesanywhere_profile\" \"<example_resource_name>\" {\n name = \"scoped-profile\"\n enabled = true\n role_arns = [<role_arn>]\n session_policy = jsonencode({\n Version = \"2012-10-17\"\n Statement = [{\n Effect = \"Allow\"\n Action = [<least_privilege_actions>]\n Resource = [<scoped_resources>]\n }]\n }) # FIX: scope down the vended session\n}\n```"
|
||||
},
|
||||
"Recommendation": {
|
||||
"Text": "Attach a session policy or managed policies to every enabled IAM Roles Anywhere profile so the vended credentials are scoped below the referenced role's permissions. Pair each profile with a purpose-built least-privilege role and audit trust anchors and profiles regularly for unexpected entries.",
|
||||
"Url": "https://hub.prowler.com/check/rolesanywhere_profile_restricts_session_permissions"
|
||||
}
|
||||
},
|
||||
"Categories": [
|
||||
"identity-access",
|
||||
"trust-boundaries"
|
||||
],
|
||||
"DependsOn": [],
|
||||
"RelatedTo": [],
|
||||
"Notes": "A profile is failed only when it is enabled, its session is unscoped, and a referenced role effectively grants administrative (*:*) access. The session-policy set (inline sessionPolicy plus every managedPolicyArns entry, resolved to its policy document) is evaluated as a union: any member granting *:* leaves the session unrestricted. Role classification merges all attached and inline identity-policy documents so explicit denies negate allows across policies, excludes condition-guarded statements (not statically provable), and intersects the result with the role's permissions boundary: a role whose boundary does not grant *:* - or whose boundary document cannot be resolved - is not classified as administrative. Disabled profiles, scoped profiles, and profiles with no role identified as administrative are reported as PASS. Referenced roles absent from the IAM inventory (for example cross-account roles or denied ListRoles) and policy documents that could not be collected are treated as non-administrative to avoid false positives."
|
||||
}
|
||||
@@ -1,272 +0,0 @@
|
||||
import json
|
||||
|
||||
from prowler.lib.check.models import Check, Check_Report_AWS
|
||||
from prowler.lib.logger import logger
|
||||
from prowler.providers.aws.services.iam.iam_client import iam_client
|
||||
from prowler.providers.aws.services.iam.lib.policy import check_full_service_access
|
||||
from prowler.providers.aws.services.rolesanywhere.rolesanywhere_client import (
|
||||
rolesanywhere_client,
|
||||
)
|
||||
|
||||
# AWS-managed AdministratorAccess ARN suffix, partition-agnostic
|
||||
# (arn:aws:..., arn:aws-cn:..., arn:aws-us-gov:...).
|
||||
ADMIN_POLICY_ARN_SUFFIX = ":iam::aws:policy/AdministratorAccess"
|
||||
|
||||
# Synthetic statement equivalent to the AWS-managed AdministratorAccess
|
||||
# document, used when a policy is identified by that ARN but its document was
|
||||
# not collected by the IAM service.
|
||||
_ADMIN_STATEMENT = {"Effect": "Allow", "Action": "*", "Resource": "*"}
|
||||
|
||||
|
||||
def _grants_full_access(document) -> bool:
|
||||
"""Return True when a policy document grants administrative (``*:*``) access.
|
||||
|
||||
Args:
|
||||
document: Decoded IAM policy document, or None when unavailable.
|
||||
"""
|
||||
if not document:
|
||||
return False
|
||||
try:
|
||||
return check_full_service_access("*", document)
|
||||
except Exception as error:
|
||||
logger.error(
|
||||
f"{error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
def _full_access_status(documents) -> bool | None:
|
||||
"""Return whether a policy-document set grants ``*:*``, or None when unknown.
|
||||
|
||||
Merges every condition-free statement across the given documents into a
|
||||
single evaluation so an explicit deny in one document negates an allow in
|
||||
another (Deny > Allow via the shared policy-evaluation helpers).
|
||||
|
||||
Unresolved or malformed documents and context-dependent semantics cannot
|
||||
produce a definitive classification and propagate as None:
|
||||
|
||||
- a document that is missing or not a well-formed statement container;
|
||||
- a ``Condition``-guarded Deny that could negate an otherwise proven
|
||||
full-access grant;
|
||||
- a ``Condition``-guarded Allow that could grant full access not proven
|
||||
by the unconditional statements.
|
||||
|
||||
Args:
|
||||
documents: Iterable of decoded IAM policy documents (None members mark
|
||||
documents that could not be resolved).
|
||||
"""
|
||||
statements = []
|
||||
conditional_effects = set()
|
||||
|
||||
for document in documents:
|
||||
if not isinstance(document, dict) or "Statement" not in document:
|
||||
return None
|
||||
|
||||
document_statements = document.get("Statement", [])
|
||||
if not isinstance(document_statements, list):
|
||||
document_statements = [document_statements]
|
||||
|
||||
for statement in document_statements:
|
||||
if not isinstance(statement, dict):
|
||||
return None
|
||||
|
||||
effect = str(statement.get("Effect", "")).lower()
|
||||
if (
|
||||
effect not in {"allow", "deny"}
|
||||
or not ("Action" in statement or "NotAction" in statement)
|
||||
or not ("Resource" in statement or "NotResource" in statement)
|
||||
):
|
||||
return None
|
||||
|
||||
if statement.get("Condition"):
|
||||
conditional_effects.add(effect)
|
||||
else:
|
||||
statements.append(statement)
|
||||
|
||||
grants_full_access = _grants_full_access({"Statement": statements})
|
||||
if (grants_full_access and "deny" in conditional_effects) or (
|
||||
not grants_full_access and "allow" in conditional_effects
|
||||
):
|
||||
return None
|
||||
|
||||
return grants_full_access
|
||||
|
||||
|
||||
def _role_is_privileged(role, policies) -> bool | None:
|
||||
"""Return whether an IAM role is administrative, or None when unknown.
|
||||
|
||||
Effective permissions are the intersection of the role's identity policies
|
||||
(attached and inline, evaluated together) and its permissions boundary.
|
||||
Unresolved policy documents, malformed policies, and condition-guarded
|
||||
statements that could change the outcome propagate as None instead of
|
||||
being collapsed into a definitive classification.
|
||||
|
||||
Args:
|
||||
role: An ``iam_service.Role`` referenced by a Roles Anywhere profile.
|
||||
policies: Mapping of policy ARN to ``iam_service.Policy`` from iam_client.
|
||||
"""
|
||||
documents = []
|
||||
for attached in role.attached_policies:
|
||||
policy_arn = attached.get("PolicyArn", "")
|
||||
document = getattr(policies.get(policy_arn), "document", None)
|
||||
if policy_arn.endswith(ADMIN_POLICY_ARN_SUFFIX) and not document:
|
||||
documents.append({"Statement": [_ADMIN_STATEMENT]})
|
||||
else:
|
||||
documents.append(document)
|
||||
for inline_name in role.inline_policies:
|
||||
policy = policies.get(f"{role.arn}:policy/{inline_name}")
|
||||
documents.append(getattr(policy, "document", None))
|
||||
|
||||
identity_status = _full_access_status(documents)
|
||||
if identity_status is False:
|
||||
# Identity policies provably do not grant *:*; no boundary can widen them.
|
||||
return False
|
||||
|
||||
boundary = getattr(role, "permissions_boundary", None)
|
||||
if not boundary:
|
||||
return identity_status
|
||||
boundary_arn = (
|
||||
boundary.get("PermissionsBoundaryArn", "") if isinstance(boundary, dict) else ""
|
||||
)
|
||||
if boundary_arn.endswith(ADMIN_POLICY_ARN_SUFFIX):
|
||||
# An AdministratorAccess boundary restricts nothing.
|
||||
return identity_status
|
||||
|
||||
boundary_status = _full_access_status(
|
||||
[getattr(policies.get(boundary_arn), "document", None)]
|
||||
)
|
||||
if boundary_status is False:
|
||||
# The boundary provably does not grant *:*: the intersection cannot be
|
||||
# administrative regardless of the identity policies.
|
||||
return False
|
||||
if boundary_status is None:
|
||||
return None
|
||||
return identity_status
|
||||
|
||||
|
||||
def _session_is_scoped(profile, policies) -> bool | None:
|
||||
"""Return whether session policies restrict permissions, or None when unknown.
|
||||
|
||||
AWS evaluates the inline ``sessionPolicy`` and every ``managedPolicyArns``
|
||||
entry together as a single session-policy category, so the complete set is
|
||||
merged into one evaluation: the session is scoped only when at least one
|
||||
session policy exists and the set does not grant ``*:*``. Managed entries
|
||||
are resolved through the collected IAM policies. An invalid inline policy
|
||||
or an unresolved managed policy does not prove that the session is
|
||||
restricted and propagates as None.
|
||||
|
||||
Args:
|
||||
profile: A ``rolesanywhere_service.Profile``.
|
||||
policies: Mapping of policy ARN to ``iam_service.Policy`` from iam_client.
|
||||
"""
|
||||
if not profile.session_policy and not profile.managed_policy_arns:
|
||||
return False
|
||||
|
||||
documents = []
|
||||
if profile.session_policy:
|
||||
try:
|
||||
documents.append(json.loads(profile.session_policy))
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
for arn in profile.managed_policy_arns or []:
|
||||
if arn.endswith(ADMIN_POLICY_ARN_SUFFIX):
|
||||
documents.append({"Statement": [_ADMIN_STATEMENT]})
|
||||
else:
|
||||
documents.append(getattr(policies.get(arn), "document", None))
|
||||
|
||||
grants_full_access = _full_access_status(documents)
|
||||
return None if grants_full_access is None else not grants_full_access
|
||||
|
||||
|
||||
class rolesanywhere_profile_restricts_session_permissions(Check):
|
||||
"""Flag Roles Anywhere profiles that vend an unscoped session on a privileged role.
|
||||
|
||||
A Roles Anywhere profile that does not restrict the session with an inline
|
||||
``sessionPolicy`` or ``managedPolicyArns`` vends temporary credentials
|
||||
carrying the full permissions of every role it references. This is only a
|
||||
real risk when a referenced role is itself administrative: any certificate
|
||||
accepted by the trust anchor then wields administrative permissions, turning
|
||||
the profile into a durable privileged-access path that surviving key rotation
|
||||
does not remove. Profiles that scope the session, whose referenced roles were
|
||||
proven not administrative, or that are disabled are reported as PASS. When
|
||||
session scoping or role permissions cannot be evaluated (unresolved or
|
||||
invalid policy documents, condition-guarded grants, unknown roles), the
|
||||
report is MANUAL rather than a proven outcome.
|
||||
"""
|
||||
|
||||
def execute(self) -> list[Check_Report_AWS]:
|
||||
"""Evaluate session-permission scoping for Roles Anywhere profiles.
|
||||
|
||||
Returns:
|
||||
list[Check_Report_AWS]: One report per Roles Anywhere profile. FAIL
|
||||
for enabled, unscoped profiles that reference a proven administrative
|
||||
role; MANUAL when session scoping or role permissions could not be
|
||||
evaluated; PASS for scoped profiles, profiles whose roles were proven
|
||||
not administrative, and disabled profiles.
|
||||
"""
|
||||
findings = []
|
||||
roles_by_arn = {role.arn: role for role in iam_client.roles}
|
||||
for profile in rolesanywhere_client.profiles.values():
|
||||
report = Check_Report_AWS(metadata=self.metadata(), resource=profile)
|
||||
role_statuses = {
|
||||
arn: (
|
||||
_role_is_privileged(roles_by_arn[arn], iam_client.policies)
|
||||
if arn in roles_by_arn
|
||||
else None
|
||||
)
|
||||
for arn in profile.role_arns
|
||||
}
|
||||
privileged_role_arns = [
|
||||
arn for arn, status in role_statuses.items() if status is True
|
||||
]
|
||||
unknown_role_arns = [
|
||||
arn for arn, status in role_statuses.items() if status is None
|
||||
]
|
||||
session_scoped = _session_is_scoped(profile, iam_client.policies)
|
||||
|
||||
if not profile.enabled:
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
f"IAM Roles Anywhere profile {profile.name} is disabled and "
|
||||
"cannot vend session credentials."
|
||||
)
|
||||
elif session_scoped is True:
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
f"IAM Roles Anywhere profile {profile.name} restricts vended "
|
||||
"session permissions with a session policy or managed policies."
|
||||
)
|
||||
elif session_scoped is None:
|
||||
report.status = "MANUAL"
|
||||
report.status_extended = (
|
||||
f"IAM Roles Anywhere profile {profile.name} session scoping "
|
||||
"could not be evaluated because an inline or managed session "
|
||||
"policy was invalid or unresolved."
|
||||
)
|
||||
elif privileged_role_arns:
|
||||
report.status = "FAIL"
|
||||
report.status_extended = (
|
||||
f"IAM Roles Anywhere profile {profile.name} does not scope down "
|
||||
"sessions and references administrative role(s) "
|
||||
f"{', '.join(privileged_role_arns)}; certificates authenticated "
|
||||
"through it inherit administrative permissions, enabling durable "
|
||||
"privileged access."
|
||||
)
|
||||
elif unknown_role_arns:
|
||||
report.status = "MANUAL"
|
||||
report.status_extended = (
|
||||
f"IAM Roles Anywhere profile {profile.name} does not scope down "
|
||||
"sessions, and the effective permissions of referenced role(s) "
|
||||
f"{', '.join(unknown_role_arns)} could not be evaluated."
|
||||
)
|
||||
else:
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
f"IAM Roles Anywhere profile {profile.name} does not scope down "
|
||||
"sessions, but no referenced role was identified as "
|
||||
"administrative; scoping the session is recommended as "
|
||||
"defense-in-depth."
|
||||
)
|
||||
findings.append(report)
|
||||
|
||||
return findings
|
||||
@@ -11,9 +11,7 @@ class RolesAnywhere(AWSService):
|
||||
def __init__(self, provider):
|
||||
super().__init__(__class__.__name__, provider)
|
||||
self.trust_anchors = {}
|
||||
self.profiles = {}
|
||||
self.__threading_call__(self._list_trust_anchors)
|
||||
self.__threading_call__(self._list_profiles)
|
||||
|
||||
def _list_trust_anchors(self, regional_client):
|
||||
logger.info("RolesAnywhere - Listing Trust Anchors...")
|
||||
@@ -54,53 +52,6 @@ class RolesAnywhere(AWSService):
|
||||
f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
|
||||
def _list_profiles(self, regional_client):
|
||||
"""List and cache IAM Roles Anywhere profiles for one AWS Region.
|
||||
|
||||
Args:
|
||||
regional_client: Roles Anywhere client for the audited Region.
|
||||
"""
|
||||
logger.info("RolesAnywhere - Listing Profiles...")
|
||||
try:
|
||||
paginator = regional_client.get_paginator("list_profiles")
|
||||
for page in paginator.paginate():
|
||||
for profile in page.get("profiles", []):
|
||||
arn = profile.get("profileArn", "")
|
||||
if not arn:
|
||||
continue
|
||||
if self.audit_resources and not is_resource_filtered(
|
||||
arn, self.audit_resources
|
||||
):
|
||||
continue
|
||||
tags = []
|
||||
try:
|
||||
tags = regional_client.list_tags_for_resource(
|
||||
resourceArn=arn
|
||||
).get("tags", [])
|
||||
except Exception as error:
|
||||
logger.warning(
|
||||
f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
self.profiles[arn] = Profile(
|
||||
arn=arn,
|
||||
id=profile.get("profileId", ""),
|
||||
name=profile.get("name", ""),
|
||||
region=regional_client.region,
|
||||
enabled=profile.get("enabled", False),
|
||||
role_arns=profile.get("roleArns", []) or [],
|
||||
session_policy=profile.get("sessionPolicy", "") or "",
|
||||
managed_policy_arns=profile.get("managedPolicyArns", []) or [],
|
||||
duration_seconds=profile.get("durationSeconds", 0) or 0,
|
||||
accept_role_session_name=profile.get(
|
||||
"acceptRoleSessionName", False
|
||||
),
|
||||
tags=tags,
|
||||
)
|
||||
except Exception as error:
|
||||
logger.error(
|
||||
f"{regional_client.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
|
||||
|
||||
class TrustAnchor(BaseModel):
|
||||
arn: str
|
||||
@@ -111,19 +62,3 @@ class TrustAnchor(BaseModel):
|
||||
source_type: str = ""
|
||||
acm_pca_arn: str = ""
|
||||
tags: List[Dict[str, str]] = Field(default_factory=list)
|
||||
|
||||
|
||||
class Profile(BaseModel):
|
||||
"""Represent an IAM Roles Anywhere profile."""
|
||||
|
||||
arn: str
|
||||
id: str
|
||||
name: str
|
||||
region: str
|
||||
enabled: bool = False
|
||||
role_arns: List[str] = Field(default_factory=list)
|
||||
session_policy: str = ""
|
||||
managed_policy_arns: List[str] = Field(default_factory=list)
|
||||
duration_seconds: int = 0
|
||||
accept_role_session_name: bool = False
|
||||
tags: List[Dict[str, str]] = Field(default_factory=list)
|
||||
|
||||
@@ -17,8 +17,6 @@ class IAM(GCPService):
|
||||
self.service_accounts = []
|
||||
self._get_service_accounts()
|
||||
self._get_service_accounts_keys()
|
||||
self.workload_identity_pool_providers = []
|
||||
self._get_workload_identity_pool_providers()
|
||||
|
||||
def _get_service_accounts(self):
|
||||
for project_id in self.project_ids:
|
||||
@@ -89,94 +87,6 @@ class IAM(GCPService):
|
||||
f"{self.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
|
||||
def _get_workload_identity_pool_providers(self):
|
||||
for project_id in self.project_ids:
|
||||
try:
|
||||
pools_request = (
|
||||
self.client.projects()
|
||||
.locations()
|
||||
.workloadIdentityPools()
|
||||
.list(parent=f"projects/{project_id}/locations/global")
|
||||
)
|
||||
while pools_request is not None:
|
||||
pools_response = pools_request.execute(
|
||||
num_retries=DEFAULT_RETRY_ATTEMPTS
|
||||
)
|
||||
for pool in pools_response.get("workloadIdentityPools", []):
|
||||
self._get_providers_for_pool(project_id, pool)
|
||||
pools_request = (
|
||||
self.client.projects()
|
||||
.locations()
|
||||
.workloadIdentityPools()
|
||||
.list_next(
|
||||
previous_request=pools_request,
|
||||
previous_response=pools_response,
|
||||
)
|
||||
)
|
||||
except Exception as error:
|
||||
logger.error(
|
||||
f"{self.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
|
||||
def _get_providers_for_pool(self, project_id, pool):
|
||||
try:
|
||||
pool_name = pool.get("name", "")
|
||||
pool_id = pool_name.split("/")[-1]
|
||||
# A provider can remain ACTIVE while its parent pool is disabled or
|
||||
# soft-deleted; a disabled pool cannot vend credentials, so the
|
||||
# pool's effective availability must travel with the provider.
|
||||
pool_disabled = (
|
||||
pool.get("disabled", False) or pool.get("state", "ACTIVE") != "ACTIVE"
|
||||
)
|
||||
request = (
|
||||
self.client.projects()
|
||||
.locations()
|
||||
.workloadIdentityPools()
|
||||
.providers()
|
||||
.list(parent=pool_name)
|
||||
)
|
||||
while request is not None:
|
||||
response = request.execute(num_retries=DEFAULT_RETRY_ATTEMPTS)
|
||||
for provider in response.get("workloadIdentityPoolProviders", []):
|
||||
provider_type = next(
|
||||
(
|
||||
key
|
||||
for key in ("oidc", "aws", "saml", "x509")
|
||||
if key in provider
|
||||
),
|
||||
"",
|
||||
)
|
||||
self.workload_identity_pool_providers.append(
|
||||
WorkloadIdentityPoolProvider(
|
||||
name=provider.get("name", ""),
|
||||
id=provider.get("name", "").split("/")[-1],
|
||||
pool_id=pool_id,
|
||||
pool_disabled=pool_disabled,
|
||||
project_id=project_id,
|
||||
state=provider.get("state", ""),
|
||||
disabled=provider.get("disabled", False),
|
||||
attribute_condition=provider.get("attributeCondition", ""),
|
||||
attribute_mapping=provider.get("attributeMapping", {})
|
||||
or {},
|
||||
provider_type=provider_type,
|
||||
issuer_uri=(provider.get("oidc", {}) or {}).get(
|
||||
"issuerUri", ""
|
||||
),
|
||||
display_name=provider.get("displayName", ""),
|
||||
)
|
||||
)
|
||||
request = (
|
||||
self.client.projects()
|
||||
.locations()
|
||||
.workloadIdentityPools()
|
||||
.providers()
|
||||
.list_next(previous_request=request, previous_response=response)
|
||||
)
|
||||
except Exception as error:
|
||||
logger.error(
|
||||
f"{self.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
|
||||
|
||||
class Key(BaseModel):
|
||||
name: str
|
||||
@@ -196,25 +106,6 @@ class ServiceAccount(BaseModel):
|
||||
disabled: bool = False
|
||||
|
||||
|
||||
class WorkloadIdentityPoolProvider(BaseModel):
|
||||
"""Represent a GCP Workload Identity Federation pool provider."""
|
||||
|
||||
name: str
|
||||
id: str
|
||||
pool_id: str
|
||||
# True when the parent pool is disabled or not ACTIVE; such a pool cannot
|
||||
# vend credentials regardless of the provider's own state.
|
||||
pool_disabled: bool = False
|
||||
project_id: str
|
||||
state: str = ""
|
||||
disabled: bool = False
|
||||
attribute_condition: str = ""
|
||||
attribute_mapping: dict = {}
|
||||
provider_type: str = ""
|
||||
issuer_uri: str = ""
|
||||
display_name: str = ""
|
||||
|
||||
|
||||
class AccessApproval(GCPService):
|
||||
def __init__(self, provider: GcpProvider):
|
||||
super().__init__(__class__.__name__, provider)
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"Provider": "gcp",
|
||||
"CheckID": "iam_workload_identity_pool_provider_attribute_condition",
|
||||
"CheckTitle": "Workload Identity Federation providers trusting a multi-tenant issuer enforce an attribute condition",
|
||||
"CheckType": [],
|
||||
"ServiceName": "iam",
|
||||
"SubServiceName": "",
|
||||
"ResourceIdTemplate": "",
|
||||
"Severity": "high",
|
||||
"ResourceType": "iam.googleapis.com/WorkloadIdentityPoolProvider",
|
||||
"Description": "**Workload Identity Federation providers** define an `attributeCondition` (CEL) restricting which external identities may impersonate Google Cloud principals. When a provider trusts a **multi-tenant issuer** (GitHub Actions, GitLab.com and other shared issuers), omitting the condition trusts every identity that issuer can mint. Providers trusting a dedicated single-tenant issuer are not flagged.",
|
||||
"Risk": "A provider trusting a multi-tenant issuer without an attribute condition accepts any external identity from that issuer - for example any GitHub repository when the issuer is GitHub Actions. An attacker controlling any tenant on that platform can authenticate through the provider and exchange tokens for federated credentials. Because no key is stored, this access survives credential rotation.",
|
||||
"RelatedUrl": "",
|
||||
"AdditionalURLs": [
|
||||
"https://cloud.google.com/iam/docs/workload-identity-federation",
|
||||
"https://cloud.google.com/iam/docs/workload-identity-federation#mapping",
|
||||
"https://cloud.google.com/iam/docs/best-practices-for-using-workload-identity-federation"
|
||||
],
|
||||
"Remediation": {
|
||||
"Code": {
|
||||
"CLI": "gcloud iam workload-identity-pools providers update-<oidc|aws|saml|x509> <PROVIDER_ID> --location=global --workload-identity-pool=<POOL_ID> --attribute-condition=\"<CEL_condition>\" # use the update subcommand matching the provider type",
|
||||
"NativeIaC": "",
|
||||
"Other": "1. In the Google Cloud console, go to IAM & Admin > Workload Identity Federation\n2. Open the affected pool and provider\n3. Set an attribute condition (CEL) restricting the allowed external identities, using an assertion that fits the provider type: OIDC by subject or claim (assertion.sub), SAML by NameID or attribute (assertion.subject or assertion.attributes[...]), AWS by account/role (assertion.account or assertion.arn), X.509 by certificate subject\n4. For OIDC providers, also restrict allowedAudiences to your own audience\n5. Review providers regularly for entries you did not create",
|
||||
"Terraform": "```hcl\nresource \"google_iam_workload_identity_pool_provider\" \"example\" {\n workload_identity_pool_id = \"my-pool\"\n workload_identity_pool_provider_id = \"my-provider\"\n attribute_condition = \"assertion.repository_owner == 'my-org'\" # FIX: restrict trusted identities\n\n # Declare exactly one of oidc {}, aws {}, saml {}, or x509 {} to match the provider type, e.g.:\n oidc {\n issuer_uri = \"https://token.actions.githubusercontent.com\"\n allowed_audiences = [\"https://my-audience.example.com\"]\n }\n}\n```"
|
||||
},
|
||||
"Recommendation": {
|
||||
"Text": "Set an attribute condition on any active Workload Identity Federation provider that trusts a multi-tenant issuer so only the intended external identities can impersonate Google Cloud principals, and pair OIDC providers with a restricted audience. Providers trusting a dedicated single-tenant issuer should still add a condition as defense-in-depth. Audit pools and providers regularly for unexpected entries.",
|
||||
"Url": "https://hub.prowler.com/check/iam_workload_identity_pool_provider_attribute_condition"
|
||||
}
|
||||
},
|
||||
"Categories": [
|
||||
"identity-access",
|
||||
"trust-boundaries"
|
||||
],
|
||||
"DependsOn": [],
|
||||
"RelatedTo": [],
|
||||
"Notes": "Only active providers that trust a known multi-tenant issuer (GitHub Actions, GitLab.com, Google, HCP Terraform) are failed when they omit an attribute condition; providers trusting a dedicated single-tenant issuer, AWS/SAML/X.509 providers, and disabled or non-ACTIVE providers are reported as PASS. This check verifies that an attribute condition is present; it does not evaluate whether the condition's expression is sufficiently restrictive."
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from prowler.lib.check.models import Check, Check_Report_GCP
|
||||
from prowler.providers.gcp.services.iam.iam_client import iam_client
|
||||
|
||||
# OIDC issuers whose tokens are minted for many independent tenants (any GitHub
|
||||
# repository, any GitLab project, any Google account, ...). A provider that
|
||||
# trusts one of these without an ``attributeCondition`` accepts identities
|
||||
# outside the operator's control, so omitting the condition genuinely expands
|
||||
# trust. A dedicated, single-tenant issuer only vends tokens to the operator's
|
||||
# own workloads, so an attribute condition there is defense-in-depth rather than
|
||||
# a requirement (see Google's guidance for GitHub and other shared issuers).
|
||||
MULTI_TENANT_OIDC_ISSUER_HOSTS = {
|
||||
"token.actions.githubusercontent.com", # GitHub Actions (any repository)
|
||||
"gitlab.com", # GitLab.com SaaS (any project)
|
||||
"accounts.google.com", # any Google account
|
||||
"app.terraform.io", # HCP Terraform (any organization)
|
||||
}
|
||||
|
||||
|
||||
def _is_multi_tenant_issuer(issuer_uri: str) -> bool:
|
||||
"""Return True when the OIDC issuer is a known multi-tenant/shared issuer."""
|
||||
if not issuer_uri:
|
||||
return False
|
||||
# hostname lowercases and strips port/userinfo (gitlab.com:443, user@host);
|
||||
# fall back to the raw string for bare hosts without a scheme.
|
||||
host = urlparse(issuer_uri).hostname or issuer_uri.lower()
|
||||
return host in MULTI_TENANT_OIDC_ISSUER_HOSTS
|
||||
|
||||
|
||||
class iam_workload_identity_pool_provider_attribute_condition(Check):
|
||||
"""Ensure WIF providers trusting a multi-tenant issuer enforce an attribute condition.
|
||||
|
||||
A workload identity pool provider that trusts a multi-tenant issuer (GitHub
|
||||
Actions, GitLab.com, ...) without an ``attributeCondition`` accepts every
|
||||
external identity that issuer can mint. An attacker controlling any tenant on
|
||||
that platform can then authenticate through the provider and exchange tokens
|
||||
for federated credentials, surviving credential rotation. Providers that
|
||||
enforce an attribute condition, that trust a dedicated single-tenant issuer,
|
||||
that are not OIDC-based, that are disabled/inactive, or whose parent pool is
|
||||
disabled are reported as PASS.
|
||||
"""
|
||||
|
||||
def execute(self) -> list[Check_Report_GCP]:
|
||||
"""Evaluate the attribute condition of each Workload Identity provider.
|
||||
|
||||
Returns:
|
||||
list[Check_Report_GCP]: One report per workload identity pool
|
||||
provider. FAIL for active providers that trust a multi-tenant issuer
|
||||
without an attribute condition; PASS for providers that enforce one,
|
||||
trust a dedicated issuer, are not OIDC-based, or are
|
||||
disabled/inactive.
|
||||
"""
|
||||
findings = []
|
||||
for provider in iam_client.workload_identity_pool_providers:
|
||||
report = Check_Report_GCP(
|
||||
metadata=self.metadata(),
|
||||
resource=provider,
|
||||
resource_id=provider.name,
|
||||
resource_name=provider.display_name or provider.id,
|
||||
location="global",
|
||||
)
|
||||
if provider.pool_disabled:
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
f"Workload Identity Federation provider {provider.id} belongs "
|
||||
f"to the disabled pool {provider.pool_id}, which cannot vend "
|
||||
"credentials."
|
||||
)
|
||||
elif provider.disabled or provider.state != "ACTIVE":
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
f"Workload Identity Federation provider {provider.id} in pool "
|
||||
f"{provider.pool_id} is not active and cannot vend credentials."
|
||||
)
|
||||
elif provider.attribute_condition:
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
f"Workload Identity Federation provider {provider.id} in pool "
|
||||
f"{provider.pool_id} enforces an attribute condition."
|
||||
)
|
||||
elif _is_multi_tenant_issuer(provider.issuer_uri):
|
||||
report.status = "FAIL"
|
||||
report.status_extended = (
|
||||
f"Workload Identity Federation provider {provider.id} in pool "
|
||||
f"{provider.pool_id} trusts the multi-tenant issuer "
|
||||
f"{provider.issuer_uri} without an attribute condition, so any "
|
||||
"identity from that issuer can authenticate through this provider."
|
||||
)
|
||||
elif provider.provider_type != "oidc":
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
f"Workload Identity Federation provider {provider.id} in pool "
|
||||
f"{provider.pool_id} is not an OIDC provider trusting a "
|
||||
"multi-tenant issuer; an attribute condition is recommended as "
|
||||
"defense-in-depth but not required."
|
||||
)
|
||||
else:
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
f"Workload Identity Federation provider {provider.id} in pool "
|
||||
f"{provider.pool_id} trusts a dedicated issuer; an attribute "
|
||||
"condition is recommended as defense-in-depth but not required."
|
||||
)
|
||||
findings.append(report)
|
||||
|
||||
return findings
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"Provider": "huaweicloud",
|
||||
"CheckID": "vpc_security_group_open_egress",
|
||||
"CheckTitle": "VPC security groups do not allow open egress to the internet",
|
||||
"CheckType": [],
|
||||
"ServiceName": "vpc",
|
||||
"SubServiceName": "",
|
||||
"ResourceIdTemplate": "",
|
||||
"Severity": "medium",
|
||||
"ResourceType": "HUAWEICLOUD::VPC::SecurityGroup",
|
||||
"ResourceGroup": "network",
|
||||
"Description": "Security groups should not allow unrestricted egress to all destinations. Huawei Cloud represents unrestricted destinations as 0.0.0.0/0, ::/0, or an empty remote IP prefix without a remote security group or address group. Open egress allows instances to reach any destination on the internet, increasing the risk of data exfiltration and command-and-control communication.",
|
||||
"Risk": "Unrestricted egress rules allow instances to communicate with any external destination. This increases the risk of data exfiltration, unauthorized outbound connections, and command-and-control channel establishment by compromised instances.",
|
||||
"RelatedUrl": "",
|
||||
"AdditionalURLs": [
|
||||
"https://support.huaweicloud.com/intl/en-us/usermanual-vpc/vpc_SecurityGroup_0001.html"
|
||||
],
|
||||
"Remediation": {
|
||||
"Code": {
|
||||
"CLI": "hcloud VPC UpdateSecurityGroupRule --security_group_rule_id <rule_id> --remote_ip_prefix <restricted_cidr>",
|
||||
"NativeIaC": "",
|
||||
"Other": "1. Log on to the Huawei Cloud console.\n2. Choose VPC.\n3. Click Security Groups.\n4. Select the security group.\n5. Edit each allow egress rule whose destination is 0.0.0.0/0, ::/0, or empty and unscoped.\n6. Restrict the destination to required IP ranges or an appropriate security group or address group.\n7. Click OK.",
|
||||
"Terraform": ""
|
||||
},
|
||||
"Recommendation": {
|
||||
"Text": "Restrict allow egress rules to required destination IP ranges, security groups, or address groups instead of allowing all IPv4 or IPv6 destinations.",
|
||||
"Url": "https://hub.prowler.com/check/vpc_security_group_open_egress"
|
||||
}
|
||||
},
|
||||
"Categories": [
|
||||
"trust-boundaries"
|
||||
],
|
||||
"DependsOn": [],
|
||||
"RelatedTo": [],
|
||||
"Notes": ""
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
from prowler.lib.check.models import Check, CheckReportHuaweiCloud
|
||||
from prowler.providers.huaweicloud.services.vpc.vpc_client import vpc_client
|
||||
|
||||
|
||||
class vpc_security_group_open_egress(Check):
|
||||
"""Check if VPC security groups allow unrestricted egress to the internet."""
|
||||
|
||||
def execute(self) -> list[CheckReportHuaweiCloud]:
|
||||
"""Execute the unrestricted egress check.
|
||||
|
||||
Returns:
|
||||
list[CheckReportHuaweiCloud]: Reports for the evaluated security groups.
|
||||
"""
|
||||
findings = []
|
||||
|
||||
for sg in vpc_client.security_groups.values():
|
||||
report = CheckReportHuaweiCloud(metadata=self.metadata(), resource=sg)
|
||||
report.region = sg.region
|
||||
report.resource_id = sg.id
|
||||
report.resource_arn = (
|
||||
f"huaweicloud:vpc:{sg.region}:"
|
||||
f"{vpc_client.audited_account}:security-group/{sg.id}"
|
||||
)
|
||||
|
||||
open_egress_destination = None
|
||||
for rule in sg.rules:
|
||||
if (
|
||||
rule.direction != "egress"
|
||||
or rule.action != "allow"
|
||||
or rule.remote_group_id
|
||||
or rule.remote_address_group_id
|
||||
):
|
||||
continue
|
||||
if rule.remote_ip_prefix in ("0.0.0.0/0", "::/0"):
|
||||
open_egress_destination = rule.remote_ip_prefix
|
||||
break
|
||||
if not rule.remote_ip_prefix:
|
||||
open_egress_destination = "all destinations"
|
||||
break
|
||||
|
||||
if open_egress_destination:
|
||||
report.status = "FAIL"
|
||||
report.status_extended = (
|
||||
f"Security group {sg.name} ({sg.id}) allows open egress "
|
||||
f"({open_egress_destination}) to the internet."
|
||||
)
|
||||
else:
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
f"Security group {sg.name} ({sg.id}) does not allow open egress "
|
||||
f"to the internet."
|
||||
)
|
||||
|
||||
findings.append(report)
|
||||
|
||||
return findings
|
||||
@@ -91,8 +91,6 @@ class VPC(HuaweiCloudService):
|
||||
id=getattr(rule_data, "id", None) or "",
|
||||
direction=getattr(rule_data, "direction", None)
|
||||
or "",
|
||||
action=getattr(rule_data, "action", None)
|
||||
or "allow",
|
||||
protocol=getattr(rule_data, "protocol", None)
|
||||
or "",
|
||||
ethertype=getattr(rule_data, "ethertype", None)
|
||||
@@ -111,12 +109,6 @@ class VPC(HuaweiCloudService):
|
||||
rule_data, "remote_group_id", None
|
||||
)
|
||||
or "",
|
||||
remote_address_group_id=getattr(
|
||||
rule_data,
|
||||
"remote_address_group_id",
|
||||
None,
|
||||
)
|
||||
or "",
|
||||
description=getattr(
|
||||
rule_data, "description", None
|
||||
)
|
||||
@@ -156,14 +148,12 @@ class SecurityGroupRule(HuaweiCloudBaseModel):
|
||||
|
||||
id: str
|
||||
direction: str
|
||||
action: str = "allow"
|
||||
protocol: str
|
||||
ethertype: str
|
||||
port_range_min: Optional[int] = None
|
||||
port_range_max: Optional[int] = None
|
||||
remote_ip_prefix: str = ""
|
||||
remote_group_id: str = ""
|
||||
remote_address_group_id: str = ""
|
||||
description: str = ""
|
||||
|
||||
|
||||
@@ -191,16 +181,13 @@ def rule_source_is_open(rule: SecurityGroupRule) -> bool:
|
||||
|
||||
Huawei Cloud represents "any source" in two ways: an explicit ``0.0.0.0/0``
|
||||
(or ``::/0``) in ``remote_ip_prefix``, or leaving both ``remote_ip_prefix``
|
||||
and both group identifiers empty. Rules that reference a security group or
|
||||
address group are NOT open even when ``remote_ip_prefix`` is empty.
|
||||
and ``remote_group_id`` empty. Rules that reference another security group
|
||||
via ``remote_group_id`` are NOT open even when ``remote_ip_prefix`` is
|
||||
empty.
|
||||
"""
|
||||
if rule.remote_ip_prefix in ("0.0.0.0/0", "::/0"):
|
||||
return True
|
||||
return (
|
||||
not rule.remote_ip_prefix
|
||||
and not rule.remote_group_id
|
||||
and not rule.remote_address_group_id
|
||||
)
|
||||
return not rule.remote_ip_prefix and not rule.remote_group_id
|
||||
|
||||
|
||||
def rule_covers_all_ports(rule: SecurityGroupRule) -> bool:
|
||||
|
||||
@@ -132,8 +132,7 @@ dependencies = [
|
||||
"huaweicloudsdkobs==3.1.204",
|
||||
"huaweicloudsdkrds==3.1.204",
|
||||
"huaweicloudsdkvpc==3.1.204",
|
||||
"huaweicloudsdkwaf==3.1.204",
|
||||
"zstandard==0.25.0"
|
||||
"huaweicloudsdkwaf==3.1.204"
|
||||
]
|
||||
description = "Prowler is an Open Source security tool to perform AWS, GCP and Azure security best practices assessments, audits, incident response, continuous monitoring, hardening and forensics readiness. It contains hundreds of controls covering CIS, NIST 800, NIST CSF, CISA, RBI, FedRAMP, PCI-DSS, GDPR, HIPAA, FFIEC, SOC2, GXP, AWS Well-Architected Framework Security Pillar, AWS Foundational Technical Review (FTR), ENS (Spanish National Security Scheme) and your custom security frameworks."
|
||||
license = "Apache-2.0"
|
||||
@@ -141,7 +140,7 @@ maintainers = [{name = "Prowler Engineering", email = "engineering@prowler.com"}
|
||||
name = "prowler"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10,<3.14"
|
||||
version = "5.40.0"
|
||||
version = "5.39.1"
|
||||
|
||||
[project.scripts]
|
||||
prowler = "prowler.__main__:prowler"
|
||||
|
||||
@@ -1,837 +0,0 @@
|
||||
from datetime import datetime
|
||||
from unittest import mock
|
||||
|
||||
from prowler.providers.aws.services.ecr.ecr_service import (
|
||||
ImageDetails,
|
||||
Registry,
|
||||
Repository,
|
||||
)
|
||||
from prowler.providers.aws.services.ecr.image_inspection import (
|
||||
ImageScanData,
|
||||
ImageScanFile,
|
||||
)
|
||||
from tests.providers.aws.utils import (
|
||||
AWS_ACCOUNT_NUMBER,
|
||||
AWS_REGION_US_EAST_1,
|
||||
set_mocked_aws_provider,
|
||||
)
|
||||
|
||||
# A real JWT: Kingfisher detects this regardless of the surrounding key name
|
||||
# or format (env-style KEY=value, Dockerfile RUN step, or source file).
|
||||
SECRET_VALUE = (
|
||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
|
||||
".eyJzdWIiOiIxMjM0NTY3ODkwIn0"
|
||||
".dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U"
|
||||
)
|
||||
|
||||
|
||||
def create_repository(name="test-repo", region=AWS_REGION_US_EAST_1) -> Repository:
|
||||
"""Build a minimal ECR Repository fixture."""
|
||||
return Repository(
|
||||
name=name,
|
||||
arn=f"arn:aws:ecr:{region}:{AWS_ACCOUNT_NUMBER}:repository/{name}",
|
||||
region=region,
|
||||
scan_on_push=True,
|
||||
images_details=[],
|
||||
)
|
||||
|
||||
|
||||
def create_image(tag="latest", digest=None) -> ImageDetails:
|
||||
"""Build a minimal ImageDetails fixture."""
|
||||
return ImageDetails(
|
||||
latest_tag=tag,
|
||||
latest_digest=digest or f"sha256:{'0' * 64}",
|
||||
image_pushed_at=datetime.now(),
|
||||
scan_findings_status=None,
|
||||
scan_findings_severity_count=None,
|
||||
artifact_media_type="application/vnd.docker.container.image.v1+json",
|
||||
type="Docker",
|
||||
)
|
||||
|
||||
|
||||
def mock_image_scan_data(pairs):
|
||||
"""Build a fake _get_image_scan_data generator yielding the given pairs."""
|
||||
|
||||
def _generator():
|
||||
"""Yield each (repository, image, scan_data) pair once."""
|
||||
for entry in pairs:
|
||||
yield entry
|
||||
|
||||
return _generator
|
||||
|
||||
|
||||
class Test_ecr_repository_image_no_secrets:
|
||||
"""Tests for the ecr_repository_image_no_secrets check."""
|
||||
|
||||
def test_no_repositories(self):
|
||||
"""No repositories yields no findings."""
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data([])
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 0
|
||||
|
||||
def test_clean_image(self):
|
||||
"""An image with no secrets passes."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
scan_data = ImageScanData(
|
||||
env=["PATH=/usr/bin"],
|
||||
history=["RUN echo hello"],
|
||||
files=[],
|
||||
truncated=False,
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
digest_short = image.latest_digest.split(":")[-1][:12]
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert result[0].status_extended == (
|
||||
f"No secrets found in the image '{image.latest_tag}' "
|
||||
f"({image.latest_digest}) of ECR repository {repository.name}."
|
||||
)
|
||||
assert result[0].region == AWS_REGION_US_EAST_1
|
||||
assert (
|
||||
result[0].resource_id
|
||||
== f"{repository.name}:{image.latest_tag}@{digest_short}"
|
||||
)
|
||||
assert result[0].resource_arn == f"{repository.arn}/image/{digest_short}"
|
||||
|
||||
def test_truncated_image_reports_manual(self):
|
||||
"""A clean but truncated image is MANUAL, since part was not scanned."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
scan_data = ImageScanData(env=[], history=[], files=[], truncated=True)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
assert (
|
||||
"part of it could not be retrieved or exceeded configured size "
|
||||
"limits and was not scanned" in result[0].status_extended
|
||||
)
|
||||
|
||||
def test_secret_in_environment_variable(self):
|
||||
"""A secret in an environment variable fails, naming the variable."""
|
||||
from prowler.lib.check.models import Severity
|
||||
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
scan_data = ImageScanData(
|
||||
env=["PATH=/usr/bin", f"DB_PASSWORD={SECRET_VALUE}"],
|
||||
history=[],
|
||||
files=[],
|
||||
truncated=False,
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert "environment variable DB_PASSWORD" in result[0].status_extended
|
||||
assert SECRET_VALUE not in result[0].status_extended
|
||||
assert result[0].check_metadata.Severity == Severity.high
|
||||
|
||||
def test_secret_in_malformed_env_entry_is_redacted(self):
|
||||
"""An env entry without '=' is reported generically, never echoed."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
# The entry has no "=" so no variable name can be split out; the entry
|
||||
# itself is the secret and must not appear in the finding.
|
||||
scan_data = ImageScanData(
|
||||
env=[SECRET_VALUE],
|
||||
history=[],
|
||||
files=[],
|
||||
truncated=False,
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert "in image environment variables" in result[0].status_extended
|
||||
assert SECRET_VALUE not in result[0].status_extended
|
||||
|
||||
def test_secret_in_unsafe_environment_name_is_redacted(self):
|
||||
"""An unsafe name before '=' is never included in report text."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
scan_data = ImageScanData(
|
||||
env=[f"{SECRET_VALUE}=safe-value"],
|
||||
history=[],
|
||||
files=[],
|
||||
truncated=False,
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
result = ecr_repository_image_no_secrets().execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert "in image environment variables" in result[0].status_extended
|
||||
assert SECRET_VALUE not in str(vars(result[0]))
|
||||
|
||||
def test_scanned_file_content_is_freed_after_execute(self):
|
||||
"""File contents are released after scanning so memory stays flat."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
scanned_file = ImageScanFile(
|
||||
path="app/config.py",
|
||||
layer_digest=f"sha256:{'a' * 64}",
|
||||
content="nothing secret here",
|
||||
)
|
||||
scan_data = ImageScanData(
|
||||
env=[], history=[], files=[scanned_file], truncated=False
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
# The check empties each file's content once it is handed to the
|
||||
# scanner; only path and layer digest are needed thereafter.
|
||||
assert scanned_file.content == ""
|
||||
|
||||
def test_secrets_ignore_patterns_suppresses_finding(self):
|
||||
"""A secret matching an ignore pattern is suppressed."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
scan_data = ImageScanData(
|
||||
env=["PATH=/usr/bin", f"DB_PASSWORD={SECRET_VALUE}"],
|
||||
history=[],
|
||||
files=[],
|
||||
truncated=False,
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [SECRET_VALUE],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
|
||||
def test_secret_in_build_history(self):
|
||||
"""A secret in a build history step fails, naming the step."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
scan_data = ImageScanData(
|
||||
env=[],
|
||||
history=["RUN apt-get update", f'RUN export TOKEN="{SECRET_VALUE}"'],
|
||||
files=[],
|
||||
truncated=False,
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert "image history step 2" in result[0].status_extended
|
||||
assert SECRET_VALUE not in result[0].status_extended
|
||||
|
||||
def test_multiline_environment_secret_keeps_entry_attribution(self):
|
||||
"""Embedded newlines do not shift an env finding to another entry."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
scan_data = ImageScanData(
|
||||
env=[f"MULTILINE=prefix\r\n{SECRET_VALUE}", "WRONG=value"],
|
||||
history=[],
|
||||
files=[],
|
||||
truncated=False,
|
||||
)
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
result = ecr_repository_image_no_secrets().execute()
|
||||
|
||||
assert "environment variable MULTILINE" in result[0].status_extended
|
||||
assert "environment variable WRONG" not in result[0].status_extended
|
||||
|
||||
def test_multiline_history_secret_keeps_step_attribution(self):
|
||||
"""Embedded newlines do not shift a history finding to another step."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
scan_data = ImageScanData(
|
||||
env=[],
|
||||
history=[f"RUN first\nexport TOKEN={SECRET_VALUE}", "RUN second"],
|
||||
files=[],
|
||||
truncated=False,
|
||||
)
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
result = ecr_repository_image_no_secrets().execute()
|
||||
|
||||
assert "image history step 1" in result[0].status_extended
|
||||
assert "image history step 2" not in result[0].status_extended
|
||||
|
||||
def test_secret_in_layer_file(self):
|
||||
"""A secret in a layer file fails, naming the file and layer."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
layer_digest = f"sha256:{'a' * 64}"
|
||||
scan_data = ImageScanData(
|
||||
env=[],
|
||||
history=[],
|
||||
files=[
|
||||
ImageScanFile(
|
||||
path="app/config.py",
|
||||
layer_digest=layer_digest,
|
||||
content=f'TOKEN = "{SECRET_VALUE}"',
|
||||
)
|
||||
],
|
||||
truncated=False,
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert "file app/config.py" in result[0].status_extended
|
||||
assert layer_digest in result[0].status_extended
|
||||
assert SECRET_VALUE not in result[0].status_extended
|
||||
|
||||
def test_manifest_unresolvable(self):
|
||||
"""An unresolvable manifest is reported as MANUAL."""
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, None)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
assert (
|
||||
"Could not resolve or retrieve the manifest"
|
||||
in result[0].status_extended
|
||||
)
|
||||
|
||||
def test_latest_image_lookup_error_reports_repository_manual(self):
|
||||
"""A failed authoritative image lookup is reported for the repository."""
|
||||
repository = create_repository()
|
||||
lookup_error = RuntimeError("authoritative lookup failed")
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, None, lookup_error)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
result = ecr_repository_image_no_secrets().execute()
|
||||
|
||||
assert result[0].status == "MANUAL"
|
||||
assert "Could not determine the latest image" in result[0].status_extended
|
||||
|
||||
def test_scan_error_reports_manual_for_latest_image_per_repository(self):
|
||||
"""A scanner failure reports MANUAL once per repository's latest image."""
|
||||
from prowler.lib.utils.utils import SecretsScanError
|
||||
|
||||
# Each repository has multiple images; the scan-error fallback must
|
||||
# scope to the latest image per repository only, mirroring the
|
||||
# success-path scope, not emit one MANUAL per image.
|
||||
repo1 = create_repository(name="repo-1")
|
||||
repo1.images_details = [
|
||||
create_image(tag="v1", digest=f"sha256:{'1' * 64}"),
|
||||
create_image(tag="v2", digest=f"sha256:{'2' * 64}"),
|
||||
]
|
||||
repo2 = create_repository(name="repo-2")
|
||||
repo2.images_details = [
|
||||
create_image(tag="v1", digest=f"sha256:{'3' * 64}"),
|
||||
create_image(tag="v2", digest=f"sha256:{'4' * 64}"),
|
||||
]
|
||||
registry = Registry(
|
||||
id=AWS_ACCOUNT_NUMBER,
|
||||
arn=f"arn:aws:ecr:{AWS_REGION_US_EAST_1}:{AWS_ACCOUNT_NUMBER}:registry/{AWS_ACCOUNT_NUMBER}",
|
||||
region=AWS_REGION_US_EAST_1,
|
||||
repositories=[repo1, repo2],
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {AWS_REGION_US_EAST_1: registry}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
# Not consumed on this path, but must be a real generator to iterate.
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data([])
|
||||
# The error fallback resolves each repository's scan target via
|
||||
# _get_scan_target_image; mirror the real method's latest-image scope.
|
||||
ecr_client._get_scan_target_image.side_effect = lambda repository: (
|
||||
repository.images_details[-1] if repository.images_details else None
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.detect_secrets_scan_batch",
|
||||
side_effect=SecretsScanError("Scanner failure"),
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
# One MANUAL per repository (its latest image), not one per image.
|
||||
assert len(result) == 2
|
||||
for report in result:
|
||||
assert report.status == "MANUAL"
|
||||
assert "Could not scan image" in report.status_extended
|
||||
assert "Scanner failure" in report.status_extended
|
||||
|
||||
digests_reported = {report.resource_id.split("@")[-1] for report in result}
|
||||
latest_digest_repo1 = repo1.images_details[-1].latest_digest.split(":")[-1][
|
||||
:12
|
||||
]
|
||||
latest_digest_repo2 = repo2.images_details[-1].latest_digest.split(":")[-1][
|
||||
:12
|
||||
]
|
||||
assert digests_reported == {latest_digest_repo1, latest_digest_repo2}
|
||||
assert "Scanner failure" in result[0].status_extended
|
||||
|
||||
def test_verified_secret_escalates_to_critical(self):
|
||||
"""A verified secret escalates severity to critical."""
|
||||
from prowler.lib.check.models import Severity
|
||||
|
||||
repository = create_repository()
|
||||
image = create_image()
|
||||
scan_data = ImageScanData(
|
||||
env=[f"TOKEN={SECRET_VALUE}"], history=[], files=[], truncated=False
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": True,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repository, image, scan_data)]
|
||||
)
|
||||
|
||||
def fake_scan_batch(payloads, **kwargs):
|
||||
# The real detect_secrets_scan_batch consumes the lazily-yielded
|
||||
# payloads generator as a side effect (that's what populates the
|
||||
# check's `scanned` list); replicate that here while returning
|
||||
# a controlled, pre-verified finding.
|
||||
"""Drain the payload generator like the real scanner, then return canned findings."""
|
||||
list(payloads)
|
||||
return {
|
||||
(0, "environment:0"): [
|
||||
{
|
||||
"type": "JSON Web Token (base64url-encoded)",
|
||||
"line_number": 1,
|
||||
"is_verified": True,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.detect_secrets_scan_batch",
|
||||
side_effect=fake_scan_batch,
|
||||
) as mock_scan,
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert mock_scan.call_args.kwargs.get("validate") is True
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert result[0].check_metadata.Severity == Severity.critical
|
||||
assert "confirmed to be live" in result[0].status_extended
|
||||
|
||||
def test_multiple_repositories_and_images(self):
|
||||
"""Mixed pass/fail results are reported across multiple repositories."""
|
||||
repo1 = create_repository(name="repo-1")
|
||||
repo2 = create_repository(name="repo-2")
|
||||
image1 = create_image(tag="v1", digest=f"sha256:{'1' * 64}")
|
||||
image2 = create_image(tag="v2", digest=f"sha256:{'2' * 64}")
|
||||
|
||||
clean_scan = ImageScanData(env=[], history=[], files=[], truncated=False)
|
||||
fail_scan = ImageScanData(
|
||||
env=[f"DB_PASSWORD={SECRET_VALUE}"],
|
||||
history=[],
|
||||
files=[],
|
||||
truncated=False,
|
||||
)
|
||||
|
||||
ecr_client = mock.MagicMock()
|
||||
ecr_client.registries = {}
|
||||
ecr_client.audit_config = {
|
||||
"secrets_ignore_patterns": [],
|
||||
"secrets_validate": False,
|
||||
}
|
||||
ecr_client._get_image_scan_data = mock_image_scan_data(
|
||||
[(repo1, image1, clean_scan), (repo2, image2, fail_scan)]
|
||||
)
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_aws_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets.ecr_client",
|
||||
new=ecr_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.aws.services.ecr.ecr_repository_image_no_secrets.ecr_repository_image_no_secrets import (
|
||||
ecr_repository_image_no_secrets,
|
||||
)
|
||||
|
||||
check = ecr_repository_image_no_secrets()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 2
|
||||
statuses_by_repo = {r.resource_id.split(":")[0]: r.status for r in result}
|
||||
assert statuses_by_repo["repo-1"] == "PASS"
|
||||
assert statuses_by_repo["repo-2"] == "FAIL"
|
||||
report_by_repo = {r.resource_id.split(":")[0]: r for r in result}
|
||||
assert SECRET_VALUE not in report_by_repo["repo-2"].status_extended
|
||||
@@ -1,21 +1,11 @@
|
||||
import json
|
||||
from concurrent.futures import Future
|
||||
from datetime import datetime
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import botocore
|
||||
import pytest
|
||||
from boto3 import client
|
||||
from moto import mock_aws
|
||||
|
||||
from prowler.providers.aws.services.ecr.ecr_service import (
|
||||
ECR,
|
||||
ScanningRule,
|
||||
)
|
||||
from tests.providers.aws.services.ecr.image_scan_fixtures import (
|
||||
MANIFESTS_BY_DIGEST,
|
||||
reset_image_fixtures,
|
||||
)
|
||||
from prowler.providers.aws.services.ecr.ecr_service import ECR, ScanningRule
|
||||
from tests.providers.aws.utils import (
|
||||
AWS_ACCOUNT_NUMBER,
|
||||
AWS_REGION_EU_WEST_1,
|
||||
@@ -28,20 +18,8 @@ repo_name = "test-repo"
|
||||
# Mocking Access Analyzer Calls
|
||||
make_api_call = botocore.client.BaseClient._make_api_call
|
||||
|
||||
# BatchGetImage / GetDownloadUrlForLayer fixtures (which moto does not
|
||||
# implement) live in image_scan_fixtures and are served by mock_make_api_call.
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _reset_image_fixtures():
|
||||
"""Isolate the BatchGetImage/GetDownloadUrlForLayer fixtures per test."""
|
||||
reset_image_fixtures()
|
||||
yield
|
||||
reset_image_fixtures()
|
||||
|
||||
|
||||
def mock_make_api_call(self, operation_name, kwarg):
|
||||
"""Fake botocore responses for the ECR operations this suite exercises."""
|
||||
if operation_name == "DescribeImages":
|
||||
return {
|
||||
"imageDetails": [
|
||||
@@ -172,37 +150,10 @@ def mock_make_api_call(self, operation_name, kwarg):
|
||||
},
|
||||
}
|
||||
|
||||
if operation_name == "BatchGetImage":
|
||||
digest = kwarg["imageIds"][0]["imageDigest"]
|
||||
manifest = MANIFESTS_BY_DIGEST.get(digest)
|
||||
if manifest is None:
|
||||
return {
|
||||
"images": [],
|
||||
"failures": [
|
||||
{
|
||||
"imageId": {"imageDigest": digest},
|
||||
"failureCode": "ImageNotFound",
|
||||
}
|
||||
],
|
||||
}
|
||||
return {
|
||||
"images": [
|
||||
{
|
||||
"imageManifest": json.dumps(manifest),
|
||||
"imageManifestMediaType": manifest.get("mediaType", ""),
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
if operation_name == "GetDownloadUrlForLayer":
|
||||
digest = kwarg["layerDigest"]
|
||||
return {"downloadUrl": f"https://layers.example.com/{digest}"}
|
||||
|
||||
return make_api_call(self, operation_name, kwarg)
|
||||
|
||||
|
||||
def mock_generate_regional_clients(provider, service):
|
||||
"""Return a single regional client for every requested region."""
|
||||
regional_client = provider._session.current_session.client(
|
||||
service, region_name=AWS_REGION_EU_WEST_1
|
||||
)
|
||||
@@ -218,17 +169,13 @@ def mock_generate_regional_clients(provider, service):
|
||||
)
|
||||
class Test_ECR_Service:
|
||||
# Test ECR Service
|
||||
"""Tests for the ECR service."""
|
||||
|
||||
def test_service(self):
|
||||
"""The service name is set correctly."""
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
|
||||
ecr = ECR(aws_provider)
|
||||
assert ecr.service == "ecr"
|
||||
|
||||
# Test ECR client
|
||||
def test_client(self):
|
||||
"""Each regional client is an ECR client."""
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
|
||||
ecr = ECR(aws_provider)
|
||||
for regional_client in ecr.regional_clients.values():
|
||||
@@ -236,7 +183,6 @@ class Test_ECR_Service:
|
||||
|
||||
# Test ECR session
|
||||
def test_get_session(self):
|
||||
"""The session is set correctly."""
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
|
||||
ecr = ECR(aws_provider)
|
||||
assert ecr.session.__class__.__name__ == "Session"
|
||||
@@ -244,7 +190,6 @@ class Test_ECR_Service:
|
||||
# Test describe ECR repositories
|
||||
@mock_aws
|
||||
def test_describe_registries_and_repositories(self):
|
||||
"""Registries and repositories are discovered."""
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
ecr_client.create_repository(
|
||||
repositoryName=repo_name,
|
||||
@@ -275,7 +220,6 @@ class Test_ECR_Service:
|
||||
# Test describe ECR repository policies
|
||||
@mock_aws
|
||||
def test_describe_repository_policies(self):
|
||||
"""Repository policies are fetched and parsed."""
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
ecr_client.create_repository(
|
||||
repositoryName=repo_name,
|
||||
@@ -305,7 +249,6 @@ class Test_ECR_Service:
|
||||
# Test describe ECR repository lifecycle policies
|
||||
@mock_aws
|
||||
def test_get_lifecycle_policies(self):
|
||||
"""Repository lifecycle policies are fetched."""
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
ecr_client.create_repository(
|
||||
repositoryName=repo_name,
|
||||
@@ -325,7 +268,6 @@ class Test_ECR_Service:
|
||||
# Test get image details
|
||||
@mock_aws
|
||||
def test_get_image_details(self):
|
||||
"""Scannable, tagged images are collected and sorted by push date."""
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
ecr_client.create_repository(
|
||||
repositoryName=repo_name,
|
||||
@@ -424,7 +366,6 @@ class Test_ECR_Service:
|
||||
# Test get ECR Registries Scanning Configuration
|
||||
@mock_aws
|
||||
def test_get_registry_scanning_configuration(self):
|
||||
"""The registry's scanning configuration is fetched."""
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
|
||||
ecr = ECR(aws_provider)
|
||||
assert len(ecr.registries) == 1
|
||||
@@ -438,188 +379,39 @@ class Test_ECR_Service:
|
||||
]
|
||||
|
||||
def test_is_artifact_scannable_docker(self):
|
||||
"""A Docker image config is scannable."""
|
||||
assert ECR._is_artifact_scannable(
|
||||
"application/vnd.docker.container.image.v1+json"
|
||||
)
|
||||
|
||||
def test_is_artifact_scannable_layer_tar(self):
|
||||
"""An uncompressed Docker layer is scannable."""
|
||||
assert ECR._is_artifact_scannable(
|
||||
"application/vnd.docker.image.rootfs.diff.tar"
|
||||
)
|
||||
|
||||
def test_is_artifact_scannable_layer_gzip(self):
|
||||
"""A gzip-compressed Docker layer is scannable."""
|
||||
assert ECR._is_artifact_scannable(
|
||||
"application/vnd.docker.image.rootfs.diff.tar.gzip"
|
||||
)
|
||||
|
||||
def test_is_artifact_scannable_oci(self):
|
||||
"""An OCI image config is scannable."""
|
||||
assert ECR._is_artifact_scannable("application/vnd.oci.image.config.v1+json")
|
||||
|
||||
def test_is_artifact_scannable_oci_tar(self):
|
||||
"""An uncompressed OCI layer is scannable."""
|
||||
assert ECR._is_artifact_scannable("application/vnd.oci.image.layer.v1.tar")
|
||||
|
||||
def test_is_artifact_scannable_oci_compressed(self):
|
||||
"""A gzip-compressed OCI layer is scannable."""
|
||||
assert ECR._is_artifact_scannable("application/vnd.oci.image.layer.v1.tar+gzip")
|
||||
|
||||
def test_is_artifact_scannable_none(self):
|
||||
"""A missing media type is not scannable."""
|
||||
assert not ECR._is_artifact_scannable(None)
|
||||
|
||||
def test_is_artifact_scannable_empty(self):
|
||||
"""An empty media type is not scannable."""
|
||||
assert not ECR._is_artifact_scannable("")
|
||||
|
||||
def test_is_artifact_scannable_non_scannable_tags(self):
|
||||
"""A signature-tagged artifact is not scannable."""
|
||||
assert not ECR._is_artifact_scannable("", ["sha256-abcdefg123456.sig"])
|
||||
|
||||
def test_is_artifact_scannable_scannable_tags(self):
|
||||
"""A normally-tagged artifact is scannable."""
|
||||
assert ECR._is_artifact_scannable(
|
||||
"application/vnd.docker.container.image.v1+json", ["abcdefg123456"]
|
||||
)
|
||||
|
||||
@mock_aws
|
||||
def test_get_image_scan_data_selects_only_latest_image_per_repository(self):
|
||||
"""Only the latest image per repository is selected for scanning."""
|
||||
ecr_client_boto = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
ecr_client_boto.create_repository(
|
||||
repositoryName=repo_name,
|
||||
imageScanningConfiguration={"scanOnPush": True},
|
||||
)
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
|
||||
ecr = ECR(aws_provider)
|
||||
|
||||
repository = ecr.registries[AWS_REGION_EU_WEST_1].repositories[0]
|
||||
# Sanity check: this repository has several scannable tagged images.
|
||||
assert len(repository.images_details) == 4
|
||||
|
||||
results = list(ecr._get_image_scan_data())
|
||||
|
||||
# Only the most recently pushed image is selected, not all four.
|
||||
assert len(results) == 1
|
||||
fetched_repository, fetched_image, _ = results[0]
|
||||
assert fetched_repository.name == repo_name
|
||||
assert fetched_image.latest_tag == "test-tag4"
|
||||
assert (
|
||||
fetched_image.latest_digest
|
||||
== "sha256:43251ac64627fc331584f6c498b3aba5badc01574e2c70b2499af3af16630eed"
|
||||
)
|
||||
|
||||
@mock_aws
|
||||
def test_get_image_scan_data_covers_scan_on_push_disabled_repository(self):
|
||||
"""A scan-on-push-disabled repo (empty images_details) is still scanned."""
|
||||
ecr_client_boto = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
ecr_client_boto.create_repository(
|
||||
repositoryName=repo_name,
|
||||
imageScanningConfiguration={"scanOnPush": False},
|
||||
)
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
|
||||
ecr = ECR(aws_provider)
|
||||
|
||||
repository = ecr.registries[AWS_REGION_EU_WEST_1].repositories[0]
|
||||
# Scan-on-push disabled: the metadata pass leaves images_details empty...
|
||||
assert repository.scan_on_push is False
|
||||
assert repository.images_details == []
|
||||
|
||||
# ...yet the secret-scan path resolves the latest image via a dedicated
|
||||
# describe_images lookup, so the repository is not silently skipped.
|
||||
results = list(ecr._get_image_scan_data())
|
||||
|
||||
assert len(results) == 1
|
||||
fetched_repository, fetched_image, _ = results[0]
|
||||
assert fetched_repository.name == repo_name
|
||||
assert fetched_image.latest_tag == "test-tag4"
|
||||
# The dedicated lookup must NOT mutate the shared images_details, or
|
||||
# other checks would treat this repo as having a scanned image.
|
||||
assert repository.images_details == []
|
||||
|
||||
@mock_aws
|
||||
def test_get_image_scan_data_bounds_submitted_futures(self):
|
||||
"""Image fetches are submitted only as earlier results are consumed."""
|
||||
ecr_client_boto = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
for index in range(10):
|
||||
ecr_client_boto.create_repository(
|
||||
repositoryName=f"{repo_name}-{index}",
|
||||
imageScanningConfiguration={"scanOnPush": True},
|
||||
)
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
|
||||
ecr = ECR(aws_provider)
|
||||
repositories = ecr.registries[AWS_REGION_EU_WEST_1].repositories
|
||||
|
||||
executor = MagicMock()
|
||||
executor.__enter__.return_value = executor
|
||||
futures = []
|
||||
|
||||
def submit(*_args):
|
||||
future = Future()
|
||||
futures.append(future)
|
||||
if len(futures) == 1:
|
||||
future.set_result(None)
|
||||
return future
|
||||
|
||||
executor.submit.side_effect = submit
|
||||
with patch(
|
||||
"prowler.providers.aws.services.ecr.ecr_service.ThreadPoolExecutor",
|
||||
return_value=executor,
|
||||
):
|
||||
results = ecr._get_image_scan_data()
|
||||
first_result = next(results)
|
||||
|
||||
assert first_result[0] == repositories[0]
|
||||
assert (
|
||||
first_result[1].latest_digest
|
||||
== repositories[0].images_details[-1].latest_digest
|
||||
)
|
||||
assert executor.submit.call_count == 4
|
||||
|
||||
@mock_aws
|
||||
def test_get_scan_target_image_ignores_stale_scanned_image(self):
|
||||
"""Secret scanning selects a newer image absent from scan findings."""
|
||||
ecr_client_boto = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
ecr_client_boto.create_repository(
|
||||
repositoryName=repo_name,
|
||||
imageScanningConfiguration={"scanOnPush": True},
|
||||
)
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
|
||||
ecr = ECR(aws_provider)
|
||||
repository = ecr.registries[AWS_REGION_EU_WEST_1].repositories[0]
|
||||
older_scanned_image = repository.images_details[0]
|
||||
repository.images_details = [older_scanned_image]
|
||||
|
||||
target = ecr._get_scan_target_image(repository)
|
||||
|
||||
assert target.latest_tag == "test-tag4"
|
||||
assert target.image_pushed_at > older_scanned_image.image_pushed_at
|
||||
|
||||
@mock_aws
|
||||
def test_get_scan_target_image_lookup_failure_rejects_stale_image(self):
|
||||
"""A failed authoritative lookup does not select cached scan metadata."""
|
||||
ecr_client_boto = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
ecr_client_boto.create_repository(
|
||||
repositoryName=repo_name,
|
||||
imageScanningConfiguration={"scanOnPush": True},
|
||||
)
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_EU_WEST_1])
|
||||
ecr = ECR(aws_provider)
|
||||
repository = ecr.registries[AWS_REGION_EU_WEST_1].repositories[0]
|
||||
repository.images_details = [repository.images_details[0]]
|
||||
|
||||
with patch.object(
|
||||
ecr.regional_clients[AWS_REGION_EU_WEST_1],
|
||||
"get_paginator",
|
||||
side_effect=RuntimeError("authoritative lookup failed"),
|
||||
):
|
||||
target = ecr._get_scan_target_image(repository)
|
||||
scan_results = list(ecr._get_image_scan_data())
|
||||
|
||||
assert isinstance(target, RuntimeError)
|
||||
assert len(scan_results) == 1
|
||||
_, result_image, result_error = scan_results[0]
|
||||
assert result_image is None and isinstance(result_error, RuntimeError)
|
||||
|
||||
@@ -1,512 +0,0 @@
|
||||
import gzip
|
||||
import json
|
||||
import random
|
||||
import tarfile
|
||||
from io import BytesIO
|
||||
from unittest.mock import patch
|
||||
|
||||
import botocore
|
||||
import pytest
|
||||
import zstandard
|
||||
from boto3 import client
|
||||
from moto import mock_aws
|
||||
|
||||
from prowler.providers.aws.services.ecr.image_inspection import (
|
||||
MAX_FILE_BYTES,
|
||||
MAX_LAYER_DOWNLOAD_BYTES,
|
||||
ImageInspector,
|
||||
_CappedLayerReader,
|
||||
_LayerTooLargeError,
|
||||
)
|
||||
from tests.providers.aws.services.ecr.image_scan_fixtures import (
|
||||
BLOBS_BY_DIGEST,
|
||||
CHILD_AMD64_DIGEST,
|
||||
CHILD_ARM64_DIGEST,
|
||||
CONFIG_DIGEST,
|
||||
CONFIG_JSON,
|
||||
IMAGE_DIGEST,
|
||||
LAYER_DIGEST,
|
||||
MANIFESTS_BY_DIGEST,
|
||||
MULTI_ARCH_INDEX_DIGEST,
|
||||
MULTI_ARCH_MANIFEST_LIST,
|
||||
SIMPLE_MANIFEST,
|
||||
build_gzip_tar,
|
||||
build_tar,
|
||||
mock_requests_get,
|
||||
reset_image_fixtures,
|
||||
)
|
||||
from tests.providers.aws.utils import (
|
||||
AWS_ACCOUNT_NUMBER,
|
||||
AWS_REGION_EU_WEST_1,
|
||||
)
|
||||
|
||||
REPO_NAME = "test-repo"
|
||||
|
||||
_original_make_api_call = botocore.client.BaseClient._make_api_call
|
||||
|
||||
_REQUESTS_GET = "prowler.providers.aws.services.ecr.image_inspection.requests.get"
|
||||
|
||||
|
||||
def mock_make_api_call(self, operation_name, kwarg):
|
||||
"""Serve BatchGetImage/GetDownloadUrlForLayer from fixtures; delegate the rest.
|
||||
|
||||
moto implements neither operation, so they are answered from the per-test
|
||||
``MANIFESTS_BY_DIGEST`` fixtures; every other call falls through to the real
|
||||
(moto-backed) implementation.
|
||||
"""
|
||||
if operation_name == "BatchGetImage":
|
||||
digest = kwarg["imageIds"][0]["imageDigest"]
|
||||
manifest = MANIFESTS_BY_DIGEST.get(digest)
|
||||
if manifest is None:
|
||||
return {
|
||||
"images": [],
|
||||
"failures": [
|
||||
{
|
||||
"imageId": {"imageDigest": digest},
|
||||
"failureCode": "ImageNotFound",
|
||||
}
|
||||
],
|
||||
}
|
||||
return {
|
||||
"images": [
|
||||
{
|
||||
"imageManifest": json.dumps(manifest),
|
||||
"imageManifestMediaType": manifest.get("mediaType", ""),
|
||||
}
|
||||
]
|
||||
}
|
||||
if operation_name == "GetDownloadUrlForLayer":
|
||||
digest = kwarg["layerDigest"]
|
||||
return {"downloadUrl": f"https://layers.example.com/{digest}"}
|
||||
return _original_make_api_call(self, operation_name, kwarg)
|
||||
|
||||
|
||||
@patch("botocore.client.BaseClient._make_api_call", new=mock_make_api_call)
|
||||
class Test_ImageInspector:
|
||||
"""Tests for the bounded image-content extraction in image_inspection."""
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _reset_image_fixtures(self):
|
||||
"""Isolate the BatchGetImage/GetDownloadUrlForLayer fixtures per test."""
|
||||
reset_image_fixtures()
|
||||
yield
|
||||
reset_image_fixtures()
|
||||
|
||||
@staticmethod
|
||||
def _fetch(digest=IMAGE_DIGEST):
|
||||
"""Fetch scan data for one image, with the layer download stubbed."""
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
with patch(_REQUESTS_GET, new=mock_requests_get):
|
||||
return ImageInspector().fetch_image_scan_data(
|
||||
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, digest
|
||||
)
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_simple_image(self):
|
||||
"""A single-manifest image's config and layer file are scanned."""
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar({"app/config.py": "TOKEN = 'x'"})
|
||||
|
||||
scan_data = self._fetch()
|
||||
|
||||
assert scan_data is not None
|
||||
assert scan_data.env == ["PATH=/usr/bin", "TOKEN=super-secret-value"]
|
||||
assert scan_data.history == ["/bin/sh -c #(nop) ADD file", "RUN echo hi"]
|
||||
assert len(scan_data.files) == 1
|
||||
assert scan_data.files[0].path == "app/config.py"
|
||||
assert scan_data.files[0].layer_digest == LAYER_DIGEST
|
||||
assert scan_data.files[0].content == "TOKEN = 'x'"
|
||||
assert scan_data.truncated is False
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_resolves_multi_arch_manifest(self):
|
||||
"""A multi-arch scan is incomplete when only one child is inspected."""
|
||||
MANIFESTS_BY_DIGEST[MULTI_ARCH_INDEX_DIGEST] = MULTI_ARCH_MANIFEST_LIST
|
||||
MANIFESTS_BY_DIGEST[CHILD_AMD64_DIGEST] = SIMPLE_MANIFEST
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar({"app/config.py": "TOKEN = 'x'"})
|
||||
|
||||
scan_data = self._fetch(digest=MULTI_ARCH_INDEX_DIGEST)
|
||||
|
||||
# Only the amd64/linux child manifest is resolved and scanned; the
|
||||
# arm64 and attestation entries in the manifest list are ignored.
|
||||
assert scan_data is not None
|
||||
assert scan_data.env == ["PATH=/usr/bin", "TOKEN=super-secret-value"]
|
||||
assert len(scan_data.files) == 1
|
||||
assert scan_data.files[0].path == "app/config.py"
|
||||
assert scan_data.truncated is True
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_skips_oversized_layer(self):
|
||||
"""A layer over the size cap is skipped, not downloaded."""
|
||||
oversized_manifest = {
|
||||
"schemaVersion": 2,
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||
"config": {"digest": CONFIG_DIGEST, "size": 10},
|
||||
"layers": [
|
||||
{
|
||||
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
|
||||
"digest": LAYER_DIGEST,
|
||||
"size": MAX_LAYER_DOWNLOAD_BYTES + 1,
|
||||
}
|
||||
],
|
||||
}
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = oversized_manifest
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
|
||||
scan_data = self._fetch()
|
||||
|
||||
# The oversized layer is never downloaded (only the config blob is in
|
||||
# BLOBS_BY_DIGEST), yet the fetch completes without raising.
|
||||
assert scan_data is not None
|
||||
assert scan_data.files == []
|
||||
assert scan_data.truncated is True
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_manifest_not_found_returns_none(self):
|
||||
"""An unknown digest resolves to no scan data."""
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
|
||||
scan_data = ImageInspector().fetch_image_scan_data(
|
||||
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, f"sha256:{'f' * 64}"
|
||||
)
|
||||
|
||||
assert scan_data is None
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_config_download_failure_marks_truncated(self):
|
||||
"""A config blob that cannot be retrieved marks coverage incomplete.
|
||||
|
||||
Empty env/history would otherwise be indistinguishable from a clean
|
||||
config, so the fetch flags the result as truncated rather than risking
|
||||
a false PASS at the check level.
|
||||
"""
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
|
||||
# Register the layer but NOT the config blob, so the config download
|
||||
# fails while the layer is still scanned cleanly.
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar({"app/config.py": "clean"})
|
||||
|
||||
scan_data = self._fetch()
|
||||
|
||||
assert scan_data is not None
|
||||
assert scan_data.env == []
|
||||
assert scan_data.history == []
|
||||
assert scan_data.truncated is True
|
||||
assert [f.path for f in scan_data.files] == ["app/config.py"]
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_member_over_remaining_budget_is_truncated(self):
|
||||
"""A layer exceeding the remaining stream budget is truncated.
|
||||
|
||||
Tar headers and padding consume the authoritative decompressed-byte
|
||||
budget before member payloads are exposed for scanning.
|
||||
"""
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar(
|
||||
{"app/first.txt": "a" * 100, "app/second.txt": "b" * 5000}
|
||||
)
|
||||
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
with (
|
||||
patch(_REQUESTS_GET, new=mock_requests_get),
|
||||
patch(
|
||||
"prowler.providers.aws.services.ecr.image_inspection.MAX_TOTAL_BYTES_PER_IMAGE",
|
||||
1000,
|
||||
),
|
||||
):
|
||||
scan_data = ImageInspector().fetch_image_scan_data(
|
||||
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, IMAGE_DIGEST
|
||||
)
|
||||
|
||||
assert scan_data is not None
|
||||
assert scan_data.files == []
|
||||
assert scan_data.truncated is True
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_oversized_members_count_toward_budget(self):
|
||||
"""Members skipped for size still count toward the per-image budget.
|
||||
|
||||
A streaming reader must decompress each member to advance past it, so
|
||||
oversized-and-skipped members must still consume budget; otherwise a
|
||||
layer of many just-over-limit files would decompress unbounded. The
|
||||
loop must stop before reaching a later scannable member.
|
||||
"""
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
# Ten 300-byte members (each over the patched 100-byte MAX_FILE_BYTES,
|
||||
# so each is skipped for content) followed by a small, scannable file.
|
||||
layer = {f"app/big{i}.bin": "x" * 300 for i in range(10)}
|
||||
layer["app/reachable.txt"] = "hello"
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar(layer)
|
||||
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
with (
|
||||
patch(_REQUESTS_GET, new=mock_requests_get),
|
||||
patch(
|
||||
"prowler.providers.aws.services.ecr.image_inspection.MAX_FILE_BYTES",
|
||||
100,
|
||||
),
|
||||
patch(
|
||||
"prowler.providers.aws.services.ecr.image_inspection.MAX_TOTAL_BYTES_PER_IMAGE",
|
||||
1000,
|
||||
),
|
||||
):
|
||||
scan_data = ImageInspector().fetch_image_scan_data(
|
||||
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, IMAGE_DIGEST
|
||||
)
|
||||
|
||||
assert scan_data is not None
|
||||
# The oversized members exhaust the 1000-byte budget after ~3 of them,
|
||||
# so the loop stops before ever reaching app/reachable.txt. If skipped
|
||||
# members were not counted, reachable.txt would be scanned.
|
||||
assert scan_data.files == []
|
||||
assert scan_data.truncated is True
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_tar_over_stream_budget_is_truncated(self):
|
||||
"""Tar headers, padding, and non-files consume the image byte budget."""
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
layer = BytesIO()
|
||||
with tarfile.open(fileobj=layer, mode="w") as archive:
|
||||
for index in range(20):
|
||||
directory = tarfile.TarInfo(f"metadata-{index}/")
|
||||
directory.type = tarfile.DIRTYPE
|
||||
archive.addfile(directory)
|
||||
content = b"x"
|
||||
member = tarfile.TarInfo("app/reachable.txt")
|
||||
member.size = len(content)
|
||||
archive.addfile(member, BytesIO(content))
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = gzip.compress(layer.getvalue())
|
||||
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
with (
|
||||
patch(_REQUESTS_GET, new=mock_requests_get),
|
||||
patch(
|
||||
"prowler.providers.aws.services.ecr.image_inspection.MAX_TOTAL_BYTES_PER_IMAGE",
|
||||
10 * 1024 - 1,
|
||||
),
|
||||
):
|
||||
scan_data = ImageInspector().fetch_image_scan_data(
|
||||
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, IMAGE_DIGEST
|
||||
)
|
||||
|
||||
assert scan_data is not None
|
||||
assert scan_data.files == []
|
||||
assert scan_data.truncated is True
|
||||
|
||||
def test_select_child_manifest_digest_falls_back_to_non_amd64(self):
|
||||
"""With no amd64/linux entry, the first non-attestation candidate is picked."""
|
||||
manifest_list = {
|
||||
"manifests": [
|
||||
{
|
||||
"digest": CHILD_ARM64_DIGEST,
|
||||
"platform": {"architecture": "arm64", "os": "linux"},
|
||||
},
|
||||
{
|
||||
"digest": f"sha256:{'5' * 64}",
|
||||
"platform": {"architecture": "unknown", "os": "unknown"},
|
||||
"annotations": {
|
||||
"vnd.docker.reference.type": "attestation-manifest"
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
digest = ImageInspector._select_child_manifest_digest(manifest_list)
|
||||
|
||||
assert digest == CHILD_ARM64_DIGEST
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_zstd_layer(self):
|
||||
"""A zstd-compressed layer is streamed, decompressed, and scanned."""
|
||||
zstd_manifest = {
|
||||
"schemaVersion": 2,
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||
"config": {"digest": CONFIG_DIGEST, "size": 100},
|
||||
"layers": [
|
||||
{
|
||||
"mediaType": "application/vnd.oci.image.layer.v1.tar+zstd",
|
||||
"digest": LAYER_DIGEST,
|
||||
"size": 200,
|
||||
}
|
||||
],
|
||||
}
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = zstd_manifest
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = zstandard.ZstdCompressor().compress(
|
||||
build_tar({"app/config.py": "TOKEN = 'x'"})
|
||||
)
|
||||
|
||||
scan_data = self._fetch()
|
||||
|
||||
assert scan_data is not None
|
||||
assert len(scan_data.files) == 1
|
||||
assert scan_data.files[0].content == "TOKEN = 'x'"
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_zstd_layer_over_compressed_cap_is_truncated(self):
|
||||
"""A zstd layer whose compressed bytes exceed the cap is truncated.
|
||||
|
||||
The streaming decompressor reads through a _CappedLayerReader, so a
|
||||
layer whose compressed size exceeds MAX_LAYER_DOWNLOAD_BYTES (patched
|
||||
here) is cut off and disclosed via truncated instead of being buffered
|
||||
or decompressed unbounded.
|
||||
"""
|
||||
zstd_manifest = {
|
||||
"schemaVersion": 2,
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||
"config": {"digest": CONFIG_DIGEST, "size": 100},
|
||||
"layers": [
|
||||
{
|
||||
"mediaType": "application/vnd.oci.image.layer.v1.tar+zstd",
|
||||
"digest": LAYER_DIGEST,
|
||||
# Declares zero size so it passes the pre-download check;
|
||||
# the actual compressed bytes exceed the (patched) cap.
|
||||
"size": 0,
|
||||
}
|
||||
],
|
||||
}
|
||||
# Incompressible payload (so the compressed frame stays large), split
|
||||
# across two members so the first is read before the cap trips while
|
||||
# the second is streamed.
|
||||
rng = random.Random(0)
|
||||
incompressible = bytes(rng.randrange(256) for _ in range(64 * 1024)).decode(
|
||||
"latin-1"
|
||||
)
|
||||
layer_blob = zstandard.ZstdCompressor().compress(
|
||||
build_tar({"app/config.py": "TOKEN = 'x'", "app/big.bin": incompressible})
|
||||
)
|
||||
assert len(layer_blob) > 10 * 1024
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = zstd_manifest
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = layer_blob
|
||||
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
with (
|
||||
patch(_REQUESTS_GET, new=mock_requests_get),
|
||||
patch(
|
||||
"prowler.providers.aws.services.ecr.image_inspection.MAX_LAYER_DOWNLOAD_BYTES",
|
||||
len(layer_blob) - 1,
|
||||
),
|
||||
):
|
||||
scan_data = ImageInspector().fetch_image_scan_data(
|
||||
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, IMAGE_DIGEST
|
||||
)
|
||||
|
||||
assert scan_data is not None
|
||||
assert scan_data.truncated is True
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_uncompressed_tar_layer(self):
|
||||
"""An uncompressed tar layer is read and scanned directly."""
|
||||
tar_manifest = {
|
||||
"schemaVersion": 2,
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||
"config": {"digest": CONFIG_DIGEST, "size": 100},
|
||||
"layers": [
|
||||
{
|
||||
"mediaType": "application/vnd.oci.image.layer.v1.tar",
|
||||
"digest": LAYER_DIGEST,
|
||||
"size": 200,
|
||||
}
|
||||
],
|
||||
}
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = tar_manifest
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_tar({"app/config.py": "TOKEN = 'x'"})
|
||||
|
||||
scan_data = self._fetch()
|
||||
|
||||
assert scan_data is not None
|
||||
assert len(scan_data.files) == 1
|
||||
assert scan_data.files[0].content == "TOKEN = 'x'"
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_skips_whiteout_and_oversized_file(self):
|
||||
"""Whiteout markers and oversized files are skipped, not scanned."""
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = SIMPLE_MANIFEST
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = build_gzip_tar(
|
||||
{
|
||||
".wh.deleted": "should never appear",
|
||||
"app/config.py": "TOKEN = 'x'",
|
||||
"app/oversized.bin": "x" * (MAX_FILE_BYTES + 1),
|
||||
}
|
||||
)
|
||||
|
||||
scan_data = self._fetch()
|
||||
|
||||
assert scan_data is not None
|
||||
assert [f.path for f in scan_data.files] == ["app/config.py"]
|
||||
assert scan_data.truncated is True
|
||||
|
||||
def test_capped_layer_reader_allows_up_to_max(self):
|
||||
"""Reading exactly the byte budget succeeds and then reports EOF."""
|
||||
import io
|
||||
|
||||
reader = _CappedLayerReader(io.BytesIO(b"x" * 10), max_bytes=10)
|
||||
assert reader.read() == b"x" * 10
|
||||
assert reader.read() == b""
|
||||
|
||||
def test_capped_layer_reader_raises_when_exceeding_max(self):
|
||||
"""A stream longer than the byte budget raises _LayerTooLargeError."""
|
||||
import io
|
||||
|
||||
reader = _CappedLayerReader(io.BytesIO(b"x" * 100), max_bytes=10)
|
||||
with pytest.raises(_LayerTooLargeError):
|
||||
reader.read()
|
||||
|
||||
@mock_aws
|
||||
def test_fetch_image_scan_data_streamed_layer_over_cap_is_truncated(self):
|
||||
"""A layer streaming past MAX_LAYER_DOWNLOAD_BYTES is skipped, not buffered."""
|
||||
undersized_manifest = {
|
||||
"schemaVersion": 2,
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||
"config": {"digest": CONFIG_DIGEST, "size": 100},
|
||||
"layers": [
|
||||
{
|
||||
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
|
||||
"digest": LAYER_DIGEST,
|
||||
# Declares zero size so it passes the pre-download check;
|
||||
# the actual streamed bytes exceed the (patched) cap.
|
||||
"size": 0,
|
||||
}
|
||||
],
|
||||
}
|
||||
# Two-member layer: a small first file that is scanned, then a large
|
||||
# incompressible second file. The blob must exceed tarfile's internal
|
||||
# read buffer (~10 KB) so tarfile.open() consumes only part of it and
|
||||
# the cap (set one byte below the full layer) is instead exceeded while
|
||||
# the second member's content is read during archive iteration.
|
||||
rng = random.Random(0)
|
||||
incompressible = bytes(rng.randrange(256) for _ in range(64 * 1024)).decode(
|
||||
"latin-1"
|
||||
)
|
||||
layer_blob = build_gzip_tar(
|
||||
{"app/config.py": "TOKEN = 'x'", "app/big.bin": incompressible}
|
||||
)
|
||||
assert len(layer_blob) > 10 * 1024 # larger than tarfile's read buffer
|
||||
MANIFESTS_BY_DIGEST[IMAGE_DIGEST] = undersized_manifest
|
||||
BLOBS_BY_DIGEST[CONFIG_DIGEST] = json.dumps(CONFIG_JSON).encode()
|
||||
BLOBS_BY_DIGEST[LAYER_DIGEST] = layer_blob
|
||||
|
||||
ecr_client = client("ecr", region_name=AWS_REGION_EU_WEST_1)
|
||||
with (
|
||||
patch(_REQUESTS_GET, new=mock_requests_get),
|
||||
patch(
|
||||
"prowler.providers.aws.services.ecr.image_inspection.MAX_LAYER_DOWNLOAD_BYTES",
|
||||
len(layer_blob) - 1,
|
||||
),
|
||||
):
|
||||
scan_data = ImageInspector().fetch_image_scan_data(
|
||||
ecr_client, AWS_ACCOUNT_NUMBER, REPO_NAME, IMAGE_DIGEST
|
||||
)
|
||||
|
||||
# The over-cap layer is disclosed via truncated, and the config-derived
|
||||
# env/history (fetched independently of the layer) are still returned.
|
||||
assert scan_data is not None
|
||||
assert scan_data.truncated is True
|
||||
assert scan_data.env == ["PATH=/usr/bin", "TOKEN=super-secret-value"]
|
||||
@@ -1,145 +0,0 @@
|
||||
"""Shared fixtures for ECR image-scanning tests.
|
||||
|
||||
Used by both the ECR service tests (orchestration) and the image_inspection
|
||||
tests (bounded extraction), so the manifest/layer fixtures and the fake layer
|
||||
download live in one place. moto implements neither BatchGetImage nor
|
||||
GetDownloadUrlForLayer, so each test registers the manifests/blobs it needs in
|
||||
``MANIFESTS_BY_DIGEST``/``BLOBS_BY_DIGEST`` and a patched ``_make_api_call``
|
||||
serves them.
|
||||
"""
|
||||
|
||||
import io
|
||||
import tarfile
|
||||
|
||||
IMAGE_DIGEST = f"sha256:{'1' * 64}"
|
||||
CONFIG_DIGEST = f"sha256:{'c' * 64}"
|
||||
LAYER_DIGEST = f"sha256:{'d' * 64}"
|
||||
MULTI_ARCH_INDEX_DIGEST = f"sha256:{'2' * 64}"
|
||||
CHILD_AMD64_DIGEST = f"sha256:{'3' * 64}"
|
||||
CHILD_ARM64_DIGEST = f"sha256:{'4' * 64}"
|
||||
ATTESTATION_DIGEST = f"sha256:{'5' * 64}"
|
||||
|
||||
SIMPLE_MANIFEST = {
|
||||
"schemaVersion": 2,
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||
"config": {
|
||||
"mediaType": "application/vnd.docker.container.image.v1+json",
|
||||
"digest": CONFIG_DIGEST,
|
||||
"size": 100,
|
||||
},
|
||||
"layers": [
|
||||
{
|
||||
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
|
||||
"digest": LAYER_DIGEST,
|
||||
"size": 200,
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
MULTI_ARCH_MANIFEST_LIST = {
|
||||
"schemaVersion": 2,
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
|
||||
"manifests": [
|
||||
{
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||
"digest": CHILD_AMD64_DIGEST,
|
||||
"size": 10,
|
||||
"platform": {"architecture": "amd64", "os": "linux"},
|
||||
},
|
||||
{
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
|
||||
"digest": CHILD_ARM64_DIGEST,
|
||||
"size": 10,
|
||||
"platform": {"architecture": "arm64", "os": "linux"},
|
||||
},
|
||||
{
|
||||
"mediaType": "application/vnd.oci.image.manifest.v1+json",
|
||||
"digest": ATTESTATION_DIGEST,
|
||||
"size": 10,
|
||||
"platform": {"architecture": "unknown", "os": "unknown"},
|
||||
"annotations": {"vnd.docker.reference.type": "attestation-manifest"},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
CONFIG_JSON = {
|
||||
"config": {"Env": ["PATH=/usr/bin", "TOKEN=super-secret-value"]},
|
||||
"history": [
|
||||
{"created_by": "/bin/sh -c #(nop) ADD file"},
|
||||
{"created_by": "RUN echo hi"},
|
||||
],
|
||||
}
|
||||
|
||||
# Per-test fixtures keyed by digest. moto implements neither BatchGetImage nor
|
||||
# GetDownloadUrlForLayer, so tests populate these and a patched _make_api_call /
|
||||
# requests.get serves them. Cleared between tests via reset_image_fixtures().
|
||||
MANIFESTS_BY_DIGEST = {}
|
||||
BLOBS_BY_DIGEST = {}
|
||||
|
||||
|
||||
def reset_image_fixtures():
|
||||
"""Clear the per-test manifest/blob fixtures."""
|
||||
MANIFESTS_BY_DIGEST.clear()
|
||||
BLOBS_BY_DIGEST.clear()
|
||||
|
||||
|
||||
def build_tar(files: dict) -> bytes:
|
||||
"""Build an uncompressed tar archive from the given files."""
|
||||
tar_buffer = io.BytesIO()
|
||||
with tarfile.open(fileobj=tar_buffer, mode="w") as tar:
|
||||
for name, content in files.items():
|
||||
data = content.encode("latin-1")
|
||||
info = tarfile.TarInfo(name=name)
|
||||
info.size = len(data)
|
||||
tar.addfile(info, io.BytesIO(data))
|
||||
return tar_buffer.getvalue()
|
||||
|
||||
|
||||
def build_gzip_tar(files: dict) -> bytes:
|
||||
"""Build a gzip-compressed tar archive from the given files."""
|
||||
tar_buffer = io.BytesIO()
|
||||
with tarfile.open(fileobj=tar_buffer, mode="w:gz") as tar:
|
||||
for name, content in files.items():
|
||||
data = content.encode("latin-1")
|
||||
info = tarfile.TarInfo(name=name)
|
||||
info.size = len(data)
|
||||
tar.addfile(info, io.BytesIO(data))
|
||||
return tar_buffer.getvalue()
|
||||
|
||||
|
||||
class FakeLayerResponse:
|
||||
"""A minimal stand-in for a requests.Response over a layer download."""
|
||||
|
||||
def __init__(self, data: bytes):
|
||||
"""Store the fixture bytes to serve (via iter_content and .raw)."""
|
||||
self._data = data
|
||||
# Streaming gzip/tar layers read the compressed bytes straight from
|
||||
# response.raw; the buffered config/zstd path uses iter_content.
|
||||
self.raw = io.BytesIO(data)
|
||||
|
||||
def raise_for_status(self):
|
||||
"""No-op: fixture responses are always successful."""
|
||||
|
||||
def iter_content(self, chunk_size=1024 * 1024):
|
||||
"""Yield the fixture bytes in chunks."""
|
||||
for start in range(0, len(self._data), chunk_size):
|
||||
yield self._data[start : start + chunk_size]
|
||||
|
||||
def close(self):
|
||||
"""Close the backing raw stream, mirroring requests.Response.close."""
|
||||
self.raw.close()
|
||||
|
||||
def __enter__(self):
|
||||
"""Support use as a context manager."""
|
||||
return self
|
||||
|
||||
def __exit__(self, *_):
|
||||
"""Close on exit, mirroring requests.Response context-manager use."""
|
||||
self.close()
|
||||
return False
|
||||
|
||||
|
||||
def mock_requests_get(url, **_):
|
||||
"""Return the fixture bytes registered for the requested layer's URL."""
|
||||
digest = url.rsplit("/", 1)[-1]
|
||||
return FakeLayerResponse(BLOBS_BY_DIGEST[digest])
|
||||
@@ -1,762 +0,0 @@
|
||||
from types import SimpleNamespace
|
||||
from unittest import mock
|
||||
|
||||
from prowler.providers.aws.services.rolesanywhere.rolesanywhere_service import Profile
|
||||
from tests.providers.aws.utils import (
|
||||
AWS_ACCOUNT_NUMBER,
|
||||
AWS_REGION_US_EAST_1,
|
||||
set_mocked_aws_provider,
|
||||
)
|
||||
|
||||
PROFILE_ID = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
|
||||
PROFILE_NAME = "workload-profile"
|
||||
PROFILE_ARN = f"arn:aws:rolesanywhere:{AWS_REGION_US_EAST_1}:{AWS_ACCOUNT_NUMBER}:profile/{PROFILE_ID}"
|
||||
ADMIN_ROLE_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/admin-role"
|
||||
READONLY_ROLE_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/workload-role"
|
||||
UNKNOWN_ROLE_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/cross-account-role"
|
||||
CUSTOM_ADMIN_ROLE_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/custom-admin-role"
|
||||
INLINE_ADMIN_ROLE_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/inline-admin-role"
|
||||
NAME_COLLISION_ROLE_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/name-collision-role"
|
||||
UNRESOLVED_POLICY_ROLE_ARN = (
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/unresolved-policy-role"
|
||||
)
|
||||
ADMIN_UNRESOLVED_POLICY_ROLE_ARN = (
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/admin-unresolved-policy-role"
|
||||
)
|
||||
INVALID_POLICY_ROLE_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/invalid-policy-role"
|
||||
DENY_OVERRIDE_ROLE_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/deny-override-role"
|
||||
CONDITIONAL_DENY_ROLE_ARN = (
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/conditional-deny-role"
|
||||
)
|
||||
CONDITIONAL_ADMIN_ROLE_ARN = (
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/conditional-admin-role"
|
||||
)
|
||||
BOUNDED_ADMIN_ROLE_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/bounded-admin-role"
|
||||
UNRESOLVED_BOUNDARY_ROLE_ARN = (
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/unresolved-boundary-role"
|
||||
)
|
||||
ADMIN_BOUNDED_ROLE_ARN = (
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/admin-bounded-admin-role"
|
||||
)
|
||||
AWS_ADMIN_POLICY_ARN = "arn:aws:iam::aws:policy/AdministratorAccess"
|
||||
CUSTOMER_ADMIN_NAMED_POLICY_ARN = (
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/AdministratorAccess"
|
||||
)
|
||||
CUSTOM_ADMIN_POLICY_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/custom-admin"
|
||||
MANAGED_POLICY_ARN = "arn:aws:iam::aws:policy/ReadOnlyAccess"
|
||||
CUSTOMER_FULL_ACCESS_POLICY_ARN = (
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/full-access-session"
|
||||
)
|
||||
BOUNDARY_POLICY_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/scoped-boundary"
|
||||
UNRESOLVED_BOUNDARY_POLICY_ARN = (
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/unresolved-boundary"
|
||||
)
|
||||
UNRESOLVED_SESSION_POLICY_ARN = (
|
||||
"arn:aws:iam::aws:policy/job-function/SupportUser" # not in iam_client.policies
|
||||
)
|
||||
|
||||
SESSION_POLICY = (
|
||||
'{"Version":"2012-10-17","Statement":[{"Effect":"Allow",'
|
||||
'"Action":["s3:GetObject"],"Resource":["*"]}]}'
|
||||
)
|
||||
FULL_ACCESS_SESSION_POLICY = (
|
||||
'{"Version":"2012-10-17","Statement":[{"Effect":"Allow",'
|
||||
'"Action":"*","Resource":"*"}]}'
|
||||
)
|
||||
|
||||
FULL_ACCESS_DOCUMENT = {
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [{"Effect": "Allow", "Action": "*", "Resource": "*"}],
|
||||
}
|
||||
READONLY_DOCUMENT = {
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [{"Effect": "Allow", "Action": "s3:Get*", "Resource": "*"}],
|
||||
}
|
||||
DENY_ALL_DOCUMENT = {
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [{"Effect": "Deny", "Action": "*", "Resource": "*"}],
|
||||
}
|
||||
CONDITIONAL_ADMIN_DOCUMENT = {
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": "*",
|
||||
"Resource": "*",
|
||||
"Condition": {"Bool": {"aws:MultiFactorAuthPresent": "true"}},
|
||||
}
|
||||
],
|
||||
}
|
||||
CONDITIONAL_DENY_DOCUMENT = {
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Deny",
|
||||
"Action": "*",
|
||||
"Resource": "*",
|
||||
"Condition": {"StringNotEquals": {"aws:PrincipalTag/team": "security"}},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def _profile(
|
||||
*,
|
||||
enabled: bool = True,
|
||||
session_policy: str = "",
|
||||
managed_policy_arns=None,
|
||||
role_arns=None,
|
||||
):
|
||||
return Profile(
|
||||
arn=PROFILE_ARN,
|
||||
id=PROFILE_ID,
|
||||
name=PROFILE_NAME,
|
||||
region=AWS_REGION_US_EAST_1,
|
||||
enabled=enabled,
|
||||
role_arns=role_arns if role_arns is not None else [READONLY_ROLE_ARN],
|
||||
session_policy=session_policy,
|
||||
managed_policy_arns=managed_policy_arns or [],
|
||||
)
|
||||
|
||||
|
||||
def _role(arn, attached_policies=None, inline_policies=None, permissions_boundary=None):
|
||||
return SimpleNamespace(
|
||||
arn=arn,
|
||||
attached_policies=attached_policies or [],
|
||||
inline_policies=inline_policies or [],
|
||||
permissions_boundary=permissions_boundary,
|
||||
)
|
||||
|
||||
|
||||
def _iam_client():
|
||||
"""IAM client stub mirroring iam_service models: roles with attached/inline
|
||||
policies and a policies dict keyed by ARN (inline keyed {role_arn}:policy/{name}).
|
||||
"""
|
||||
roles = [
|
||||
_role(
|
||||
ADMIN_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{"PolicyName": "AdministratorAccess", "PolicyArn": AWS_ADMIN_POLICY_ARN}
|
||||
],
|
||||
),
|
||||
_role(
|
||||
READONLY_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{"PolicyName": "ReadOnlyAccess", "PolicyArn": MANAGED_POLICY_ARN}
|
||||
],
|
||||
),
|
||||
_role(
|
||||
CUSTOM_ADMIN_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{"PolicyName": "custom-admin", "PolicyArn": CUSTOM_ADMIN_POLICY_ARN}
|
||||
],
|
||||
),
|
||||
_role(INLINE_ADMIN_ROLE_ARN, inline_policies=["inline-admin"]),
|
||||
_role(
|
||||
NAME_COLLISION_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{
|
||||
"PolicyName": "AdministratorAccess",
|
||||
"PolicyArn": CUSTOMER_ADMIN_NAMED_POLICY_ARN,
|
||||
}
|
||||
],
|
||||
),
|
||||
_role(
|
||||
UNRESOLVED_POLICY_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{
|
||||
"PolicyName": "unresolved",
|
||||
"PolicyArn": f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/unresolved",
|
||||
}
|
||||
],
|
||||
),
|
||||
# Proven admin attached policy combined with an unresolved one: the
|
||||
# unresolved document could contain a deny, so the outcome is unknown.
|
||||
_role(
|
||||
ADMIN_UNRESOLVED_POLICY_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{
|
||||
"PolicyName": "AdministratorAccess",
|
||||
"PolicyArn": AWS_ADMIN_POLICY_ARN,
|
||||
},
|
||||
{
|
||||
"PolicyName": "unresolved",
|
||||
"PolicyArn": f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/unresolved",
|
||||
},
|
||||
],
|
||||
),
|
||||
# Attached policy resolves to a malformed (non-dict) document.
|
||||
_role(
|
||||
INVALID_POLICY_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{
|
||||
"PolicyName": "invalid",
|
||||
"PolicyArn": f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/invalid",
|
||||
}
|
||||
],
|
||||
),
|
||||
# Allow *:* in the attached policy negated by an unconditional Deny *:*
|
||||
# in an inline policy: not effectively administrative.
|
||||
_role(
|
||||
DENY_OVERRIDE_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{"PolicyName": "custom-admin", "PolicyArn": CUSTOM_ADMIN_POLICY_ARN}
|
||||
],
|
||||
inline_policies=["deny-all"],
|
||||
),
|
||||
# Allow *:* in the attached policy plus a Condition-guarded Deny: the
|
||||
# deny may or may not apply, so the outcome is unknown.
|
||||
_role(
|
||||
CONDITIONAL_DENY_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{"PolicyName": "custom-admin", "PolicyArn": CUSTOM_ADMIN_POLICY_ARN}
|
||||
],
|
||||
inline_policies=["conditional-deny"],
|
||||
),
|
||||
# Allow *:* guarded by a Condition: not statically provable as admin.
|
||||
_role(
|
||||
CONDITIONAL_ADMIN_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{
|
||||
"PolicyName": "conditional-admin",
|
||||
"PolicyArn": f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/conditional-admin",
|
||||
}
|
||||
],
|
||||
),
|
||||
# Administrative identity policies constrained by a restrictive
|
||||
# permissions boundary: not effectively administrative.
|
||||
_role(
|
||||
BOUNDED_ADMIN_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{"PolicyName": "AdministratorAccess", "PolicyArn": AWS_ADMIN_POLICY_ARN}
|
||||
],
|
||||
permissions_boundary={
|
||||
"PermissionsBoundaryType": "Policy",
|
||||
"PermissionsBoundaryArn": BOUNDARY_POLICY_ARN,
|
||||
},
|
||||
),
|
||||
# Boundary present but its document is not in the IAM inventory:
|
||||
# restrictions cannot be evaluated, so the role is not classified admin.
|
||||
_role(
|
||||
UNRESOLVED_BOUNDARY_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{"PolicyName": "AdministratorAccess", "PolicyArn": AWS_ADMIN_POLICY_ARN}
|
||||
],
|
||||
permissions_boundary={
|
||||
"PermissionsBoundaryType": "Policy",
|
||||
"PermissionsBoundaryArn": UNRESOLVED_BOUNDARY_POLICY_ARN,
|
||||
},
|
||||
),
|
||||
# AdministratorAccess as the boundary does not restrict anything.
|
||||
_role(
|
||||
ADMIN_BOUNDED_ROLE_ARN,
|
||||
attached_policies=[
|
||||
{"PolicyName": "AdministratorAccess", "PolicyArn": AWS_ADMIN_POLICY_ARN}
|
||||
],
|
||||
permissions_boundary={
|
||||
"PermissionsBoundaryType": "Policy",
|
||||
"PermissionsBoundaryArn": AWS_ADMIN_POLICY_ARN,
|
||||
},
|
||||
),
|
||||
]
|
||||
policies = {
|
||||
AWS_ADMIN_POLICY_ARN: SimpleNamespace(document=FULL_ACCESS_DOCUMENT),
|
||||
CUSTOM_ADMIN_POLICY_ARN: SimpleNamespace(document=FULL_ACCESS_DOCUMENT),
|
||||
MANAGED_POLICY_ARN: SimpleNamespace(document=READONLY_DOCUMENT),
|
||||
# Customer-managed policy that merely shares the AdministratorAccess name.
|
||||
CUSTOMER_ADMIN_NAMED_POLICY_ARN: SimpleNamespace(document=READONLY_DOCUMENT),
|
||||
f"{INLINE_ADMIN_ROLE_ARN}:policy/inline-admin": SimpleNamespace(
|
||||
document=FULL_ACCESS_DOCUMENT
|
||||
),
|
||||
f"{DENY_OVERRIDE_ROLE_ARN}:policy/deny-all": SimpleNamespace(
|
||||
document=DENY_ALL_DOCUMENT
|
||||
),
|
||||
f"{CONDITIONAL_DENY_ROLE_ARN}:policy/conditional-deny": SimpleNamespace(
|
||||
document=CONDITIONAL_DENY_DOCUMENT
|
||||
),
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/invalid": SimpleNamespace(
|
||||
document="invalid"
|
||||
),
|
||||
f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:policy/conditional-admin": SimpleNamespace(
|
||||
document=CONDITIONAL_ADMIN_DOCUMENT
|
||||
),
|
||||
BOUNDARY_POLICY_ARN: SimpleNamespace(document=READONLY_DOCUMENT),
|
||||
# Customer-managed session policy whose document grants *:*.
|
||||
CUSTOMER_FULL_ACCESS_POLICY_ARN: SimpleNamespace(document=FULL_ACCESS_DOCUMENT),
|
||||
}
|
||||
iam = mock.MagicMock()
|
||||
iam.roles = roles
|
||||
iam.policies = policies
|
||||
return iam
|
||||
|
||||
|
||||
def _build_client(profiles):
|
||||
ra_client = mock.MagicMock()
|
||||
ra_client.profiles = profiles
|
||||
return ra_client
|
||||
|
||||
|
||||
def _patched(ra_client):
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_US_EAST_1])
|
||||
check_module = "prowler.providers.aws.services.rolesanywhere.rolesanywhere_profile_restricts_session_permissions.rolesanywhere_profile_restricts_session_permissions"
|
||||
return [
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=aws_provider,
|
||||
),
|
||||
mock.patch(f"{check_module}.rolesanywhere_client", new=ra_client),
|
||||
mock.patch(f"{check_module}.iam_client", new=_iam_client()),
|
||||
]
|
||||
|
||||
|
||||
def _enter(patches):
|
||||
from contextlib import ExitStack
|
||||
|
||||
stack = ExitStack()
|
||||
for p in patches:
|
||||
stack.enter_context(p)
|
||||
return stack
|
||||
|
||||
|
||||
def _run():
|
||||
from prowler.providers.aws.services.rolesanywhere.rolesanywhere_profile_restricts_session_permissions.rolesanywhere_profile_restricts_session_permissions import (
|
||||
rolesanywhere_profile_restricts_session_permissions,
|
||||
)
|
||||
|
||||
return rolesanywhere_profile_restricts_session_permissions().execute()
|
||||
|
||||
|
||||
class Test_rolesanywhere_profile_restricts_session_permissions:
|
||||
def test_no_profiles(self):
|
||||
with _enter(_patched(_build_client({}))):
|
||||
assert len(_run()) == 0
|
||||
|
||||
def test_unscoped_profile_with_admin_role_fails(self):
|
||||
with _enter(
|
||||
_patched(_build_client({PROFILE_ARN: _profile(role_arns=[ADMIN_ROLE_ARN])}))
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert result[0].resource_id == PROFILE_ID
|
||||
assert result[0].resource_arn == PROFILE_ARN
|
||||
assert result[0].region == AWS_REGION_US_EAST_1
|
||||
assert ADMIN_ROLE_ARN in result[0].status_extended
|
||||
assert "administrative" in result[0].status_extended
|
||||
|
||||
def test_unscoped_profile_with_custom_admin_policy_fails(self):
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[CUSTOM_ADMIN_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert CUSTOM_ADMIN_ROLE_ARN in result[0].status_extended
|
||||
|
||||
def test_unscoped_profile_with_inline_admin_policy_fails(self):
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[INLINE_ADMIN_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert INLINE_ADMIN_ROLE_ARN in result[0].status_extended
|
||||
|
||||
def test_mixed_roles_fail_lists_only_admin_role(self):
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
role_arns=[READONLY_ROLE_ARN, ADMIN_ROLE_ARN]
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert ADMIN_ROLE_ARN in result[0].status_extended
|
||||
assert READONLY_ROLE_ARN not in result[0].status_extended
|
||||
|
||||
def test_customer_policy_named_administratoraccess_passes(self):
|
||||
# Name collision: customer-managed policy called AdministratorAccess
|
||||
# whose document is read-only must not flag the role as administrative.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[NAME_COLLISION_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
|
||||
def test_unresolved_attached_policy_is_manual(self):
|
||||
# Attached policy ARN missing from iam_client.policies: a missing
|
||||
# document is unknown, not proof that the role is unprivileged.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[UNRESOLVED_POLICY_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
assert "could not be evaluated" in result[0].status_extended
|
||||
|
||||
def test_invalid_policy_document_is_manual(self):
|
||||
# A malformed policy document cannot prove anything about the role.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[INVALID_POLICY_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
|
||||
def test_allow_all_with_unresolved_policy_is_manual(self):
|
||||
# Proven admin policy plus an unresolved one: the unresolved document
|
||||
# could contain a deny, so the classification is unknown.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
role_arns=[ADMIN_UNRESOLVED_POLICY_ROLE_ARN]
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
|
||||
def test_unscoped_profile_with_least_privilege_role_passes(self):
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client({PROFILE_ARN: _profile(role_arns=[READONLY_ROLE_ARN])})
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert "defense-in-depth" in result[0].status_extended
|
||||
|
||||
def test_unscoped_profile_with_unknown_role_is_manual(self):
|
||||
# A referenced role missing from the IAM inventory is unknown, not
|
||||
# proof that no administrative role exists.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client({PROFILE_ARN: _profile(role_arns=[UNKNOWN_ROLE_ARN])})
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
assert "could not be evaluated" in result[0].status_extended
|
||||
|
||||
def test_unscoped_profile_without_roles_passes(self):
|
||||
with _enter(_patched(_build_client({PROFILE_ARN: _profile(role_arns=[])}))):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
|
||||
def test_profile_with_session_policy_passes(self):
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
session_policy=SESSION_POLICY, role_arns=[ADMIN_ROLE_ARN]
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert "session policy" in result[0].status_extended
|
||||
|
||||
def test_full_access_session_policy_does_not_scope(self):
|
||||
# A sessionPolicy granting *:* does not restrict anything.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
session_policy=FULL_ACCESS_SESSION_POLICY,
|
||||
role_arns=[ADMIN_ROLE_ARN],
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
|
||||
def test_profile_with_managed_policies_passes(self):
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
managed_policy_arns=[MANAGED_POLICY_ARN],
|
||||
role_arns=[ADMIN_ROLE_ARN],
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
|
||||
def test_admin_managed_session_policy_does_not_scope(self):
|
||||
# AdministratorAccess as the managed session policy restricts nothing.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
managed_policy_arns=[AWS_ADMIN_POLICY_ARN],
|
||||
role_arns=[ADMIN_ROLE_ARN],
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
|
||||
def test_restrictive_inline_with_admin_managed_policy_fails(self):
|
||||
# The session-policy set is evaluated as a union: AdministratorAccess as
|
||||
# a managed session policy makes the boundary unrestricted even though
|
||||
# the inline session policy is restrictive.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
session_policy=SESSION_POLICY,
|
||||
managed_policy_arns=[AWS_ADMIN_POLICY_ARN],
|
||||
role_arns=[ADMIN_ROLE_ARN],
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
|
||||
def test_full_access_inline_with_restrictive_managed_policy_fails(self):
|
||||
# Conversely, a *:* inline session policy leaves the union unrestricted
|
||||
# regardless of a restrictive managed session policy.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
session_policy=FULL_ACCESS_SESSION_POLICY,
|
||||
managed_policy_arns=[MANAGED_POLICY_ARN],
|
||||
role_arns=[ADMIN_ROLE_ARN],
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
|
||||
def test_restrictive_inline_and_restrictive_managed_policy_passes(self):
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
session_policy=SESSION_POLICY,
|
||||
managed_policy_arns=[MANAGED_POLICY_ARN],
|
||||
role_arns=[ADMIN_ROLE_ARN],
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
|
||||
def test_customer_managed_full_access_session_policy_fails(self):
|
||||
# A customer-managed session policy whose document grants *:* must be
|
||||
# resolved through iam_client.policies and treated as unscoped.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
managed_policy_arns=[CUSTOMER_FULL_ACCESS_POLICY_ARN],
|
||||
role_arns=[ADMIN_ROLE_ARN],
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
|
||||
def test_unresolved_managed_session_policy_is_manual(self):
|
||||
# A managed session policy whose document was not collected does not
|
||||
# prove that the session is restricted: the outcome is unknown.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
managed_policy_arns=[UNRESOLVED_SESSION_POLICY_ARN],
|
||||
role_arns=[ADMIN_ROLE_ARN],
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
assert "session scoping could not be evaluated" in result[0].status_extended
|
||||
|
||||
def test_invalid_inline_session_policy_is_manual(self):
|
||||
# An inline session policy that fails to parse does not prove that the
|
||||
# session is restricted: the outcome is unknown.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{
|
||||
PROFILE_ARN: _profile(
|
||||
session_policy="not-json", role_arns=[ADMIN_ROLE_ARN]
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
|
||||
def test_allow_all_with_cross_policy_deny_all_passes(self):
|
||||
# Allow *:* in an attached policy plus an unconditional Deny *:* in an
|
||||
# inline policy: the merged evaluation must not classify the role admin.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[DENY_OVERRIDE_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
|
||||
def test_conditional_admin_allow_is_manual(self):
|
||||
# An Allow *:* guarded by a Condition is not statically provable in
|
||||
# either direction: the classification is unknown.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[CONDITIONAL_ADMIN_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
|
||||
def test_allow_all_with_conditional_deny_is_manual(self):
|
||||
# Unconditional Allow *:* plus a Condition-guarded Deny: the deny may
|
||||
# or may not negate the grant, so the classification is unknown.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[CONDITIONAL_DENY_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
|
||||
def test_admin_role_with_restrictive_boundary_passes(self):
|
||||
# Admin identity policies intersected with a read-only permissions
|
||||
# boundary are not effectively administrative.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[BOUNDED_ADMIN_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
|
||||
def test_admin_role_with_unresolved_boundary_is_manual(self):
|
||||
# When the boundary document cannot be resolved the restrictions are
|
||||
# unknown: neither administrative nor safe can be proven.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[UNRESOLVED_BOUNDARY_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "MANUAL"
|
||||
|
||||
def test_admin_role_with_admin_boundary_fails(self):
|
||||
# An AdministratorAccess boundary restricts nothing: still admin.
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(role_arns=[ADMIN_BOUNDED_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert ADMIN_BOUNDED_ROLE_ARN in result[0].status_extended
|
||||
|
||||
def test_disabled_profile_passes(self):
|
||||
with _enter(
|
||||
_patched(
|
||||
_build_client(
|
||||
{PROFILE_ARN: _profile(enabled=False, role_arns=[ADMIN_ROLE_ARN])}
|
||||
)
|
||||
)
|
||||
):
|
||||
result = _run()
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert "disabled" in result[0].status_extended
|
||||
@@ -4,7 +4,6 @@ import botocore
|
||||
from moto import mock_aws
|
||||
|
||||
from prowler.providers.aws.services.rolesanywhere.rolesanywhere_service import (
|
||||
Profile,
|
||||
RolesAnywhere,
|
||||
TrustAnchor,
|
||||
)
|
||||
@@ -17,9 +16,6 @@ from tests.providers.aws.utils import (
|
||||
TA_ID = "11111111-2222-3333-4444-555555555555"
|
||||
TA_ARN = f"arn:aws:rolesanywhere:{AWS_REGION_US_EAST_1}:{AWS_ACCOUNT_NUMBER}:trust-anchor/{TA_ID}"
|
||||
PCA_ARN = f"arn:aws:acm-pca:{AWS_REGION_US_EAST_1}:{AWS_ACCOUNT_NUMBER}:certificate-authority/abc"
|
||||
PROFILE_ID = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
|
||||
PROFILE_ARN = f"arn:aws:rolesanywhere:{AWS_REGION_US_EAST_1}:{AWS_ACCOUNT_NUMBER}:profile/{PROFILE_ID}"
|
||||
ROLE_ARN = f"arn:aws:iam::{AWS_ACCOUNT_NUMBER}:role/workload-role"
|
||||
|
||||
make_api_call = botocore.client.BaseClient._make_api_call
|
||||
|
||||
@@ -40,21 +36,6 @@ def mock_make_api_call(self, operation_name, kwarg):
|
||||
}
|
||||
]
|
||||
}
|
||||
if operation_name == "ListProfiles":
|
||||
return {
|
||||
"profiles": [
|
||||
{
|
||||
"profileArn": PROFILE_ARN,
|
||||
"profileId": PROFILE_ID,
|
||||
"name": "workload-profile",
|
||||
"enabled": True,
|
||||
"roleArns": [ROLE_ARN],
|
||||
"sessionPolicy": '{"Version":"2012-10-17","Statement":[]}',
|
||||
"durationSeconds": 3600,
|
||||
"acceptRoleSessionName": True,
|
||||
}
|
||||
]
|
||||
}
|
||||
if operation_name == "ListTagsForResource":
|
||||
return {"tags": [{"key": "Environment", "value": "test"}]}
|
||||
return make_api_call(self, operation_name, kwarg)
|
||||
@@ -97,25 +78,6 @@ class Test_RolesAnywhere_Service:
|
||||
assert ta.region == AWS_REGION_US_EAST_1
|
||||
assert ta.tags == [{"key": "Environment", "value": "test"}]
|
||||
|
||||
@patch("botocore.client.BaseClient._make_api_call", new=mock_make_api_call)
|
||||
@mock_aws
|
||||
def test_list_profiles(self):
|
||||
aws_provider = set_mocked_aws_provider([AWS_REGION_US_EAST_1])
|
||||
rolesanywhere = RolesAnywhere(aws_provider)
|
||||
assert len(rolesanywhere.profiles) == 1
|
||||
profile = rolesanywhere.profiles[PROFILE_ARN]
|
||||
assert isinstance(profile, Profile)
|
||||
assert profile.id == PROFILE_ID
|
||||
assert profile.name == "workload-profile"
|
||||
assert profile.enabled is True
|
||||
assert profile.role_arns == [ROLE_ARN]
|
||||
assert profile.session_policy == '{"Version":"2012-10-17","Statement":[]}'
|
||||
assert profile.managed_policy_arns == []
|
||||
assert profile.duration_seconds == 3600
|
||||
assert profile.accept_role_session_name is True
|
||||
assert profile.region == AWS_REGION_US_EAST_1
|
||||
assert profile.tags == [{"key": "Environment", "value": "test"}]
|
||||
|
||||
@patch(
|
||||
"botocore.client.BaseClient._make_api_call", new=mock_make_api_call_tags_failure
|
||||
)
|
||||
|
||||
@@ -490,19 +490,6 @@ def mock_api_projects_calls(client: MagicMock):
|
||||
}
|
||||
client.projects().serviceAccounts().list_next.return_value = None
|
||||
|
||||
# Workload Identity Federation pools/providers: return empty pages and stop
|
||||
# pagination so the discovery while-loops in the IAM service terminate.
|
||||
client.projects().locations().workloadIdentityPools().list().execute.return_value = {
|
||||
"workloadIdentityPools": []
|
||||
}
|
||||
client.projects().locations().workloadIdentityPools().list_next.return_value = None
|
||||
client.projects().locations().workloadIdentityPools().providers().list().execute.return_value = {
|
||||
"workloadIdentityPoolProviders": []
|
||||
}
|
||||
client.projects().locations().workloadIdentityPools().providers().list_next.return_value = (
|
||||
None
|
||||
)
|
||||
|
||||
def mock_list_service_accounts_keys(name):
|
||||
return_value = MagicMock()
|
||||
if (
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
from unittest import mock
|
||||
|
||||
from tests.providers.gcp.gcp_fixtures import (
|
||||
GCP_PROJECT_ID,
|
||||
GCP_US_CENTER1_LOCATION,
|
||||
set_mocked_gcp_provider,
|
||||
)
|
||||
|
||||
CHECK_MODULE = "prowler.providers.gcp.services.iam.iam_workload_identity_pool_provider_attribute_condition.iam_workload_identity_pool_provider_attribute_condition"
|
||||
|
||||
|
||||
def _run(provider_kwargs):
|
||||
iam_client = mock.MagicMock()
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_gcp_provider(),
|
||||
),
|
||||
mock.patch(f"{CHECK_MODULE}.iam_client", new=iam_client),
|
||||
):
|
||||
from prowler.providers.gcp.services.iam.iam_service import (
|
||||
WorkloadIdentityPoolProvider,
|
||||
)
|
||||
from prowler.providers.gcp.services.iam.iam_workload_identity_pool_provider_attribute_condition.iam_workload_identity_pool_provider_attribute_condition import (
|
||||
iam_workload_identity_pool_provider_attribute_condition,
|
||||
)
|
||||
|
||||
providers = []
|
||||
for kwargs in provider_kwargs:
|
||||
provider_id = kwargs.get("provider_id", "my-provider")
|
||||
providers.append(
|
||||
WorkloadIdentityPoolProvider(
|
||||
name=(
|
||||
f"projects/{GCP_PROJECT_ID}/locations/global/"
|
||||
f"workloadIdentityPools/my-pool/providers/{provider_id}"
|
||||
),
|
||||
id=provider_id,
|
||||
pool_id="my-pool",
|
||||
pool_disabled=kwargs.get("pool_disabled", False),
|
||||
project_id=GCP_PROJECT_ID,
|
||||
state=kwargs.get("state", "ACTIVE"),
|
||||
disabled=kwargs.get("disabled", False),
|
||||
attribute_condition=kwargs.get("attribute_condition", ""),
|
||||
provider_type=kwargs.get("provider_type", "oidc"),
|
||||
issuer_uri=kwargs.get(
|
||||
"issuer_uri",
|
||||
"https://token.actions.githubusercontent.com",
|
||||
),
|
||||
display_name="My Provider",
|
||||
)
|
||||
)
|
||||
|
||||
iam_client.project_ids = [GCP_PROJECT_ID]
|
||||
iam_client.region = GCP_US_CENTER1_LOCATION
|
||||
iam_client.workload_identity_pool_providers = providers
|
||||
return iam_workload_identity_pool_provider_attribute_condition().execute()
|
||||
|
||||
|
||||
class Test_iam_workload_identity_pool_provider_attribute_condition:
|
||||
def test_no_providers(self):
|
||||
assert len(_run([])) == 0
|
||||
|
||||
def test_multi_tenant_issuer_without_attribute_condition_fails(self):
|
||||
result = _run(
|
||||
[
|
||||
{
|
||||
"attribute_condition": "",
|
||||
"issuer_uri": "https://token.actions.githubusercontent.com",
|
||||
}
|
||||
]
|
||||
)
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert result[0].resource_id.endswith("my-provider")
|
||||
assert result[0].location == "global"
|
||||
assert "multi-tenant issuer" in result[0].status_extended
|
||||
|
||||
def test_dedicated_issuer_without_attribute_condition_passes(self):
|
||||
result = _run(
|
||||
[
|
||||
{
|
||||
"attribute_condition": "",
|
||||
"issuer_uri": "https://oidc.eks.eu-west-1.amazonaws.com/id/ABC123",
|
||||
}
|
||||
]
|
||||
)
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert "dedicated issuer" in result[0].status_extended
|
||||
|
||||
def test_non_oidc_provider_without_attribute_condition_passes(self):
|
||||
result = _run(
|
||||
[{"attribute_condition": "", "provider_type": "aws", "issuer_uri": ""}]
|
||||
)
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert "not an OIDC provider" in result[0].status_extended
|
||||
|
||||
def test_multi_tenant_issuer_with_port_and_uppercase_fails(self):
|
||||
result = _run(
|
||||
[{"attribute_condition": "", "issuer_uri": "https://GitLab.com:443"}]
|
||||
)
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
|
||||
def test_multi_tenant_issuer_bare_host_fails(self):
|
||||
result = _run(
|
||||
[
|
||||
{
|
||||
"attribute_condition": "",
|
||||
"issuer_uri": "token.actions.githubusercontent.com",
|
||||
}
|
||||
]
|
||||
)
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
|
||||
def test_multi_tenant_issuer_with_attribute_condition_passes(self):
|
||||
result = _run(
|
||||
[
|
||||
{
|
||||
"attribute_condition": "assertion.repository_owner == 'acme'",
|
||||
"issuer_uri": "https://token.actions.githubusercontent.com",
|
||||
}
|
||||
]
|
||||
)
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert "enforces an attribute condition" in result[0].status_extended
|
||||
|
||||
def test_disabled_provider_passes(self):
|
||||
result = _run([{"disabled": True}])
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert "not active" in result[0].status_extended
|
||||
|
||||
def test_non_active_provider_passes(self):
|
||||
result = _run([{"state": "DELETED"}])
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
|
||||
def test_active_provider_in_disabled_pool_passes(self):
|
||||
# The provider itself is ACTIVE and unconditioned on a multi-tenant
|
||||
# issuer, but its parent pool is disabled and cannot vend credentials.
|
||||
result = _run([{"pool_disabled": True}])
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert "disabled pool" in result[0].status_extended
|
||||
@@ -1,215 +0,0 @@
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from tests.providers.gcp.gcp_fixtures import (
|
||||
GCP_PROJECT_ID,
|
||||
mock_is_api_active,
|
||||
set_mocked_gcp_provider,
|
||||
)
|
||||
|
||||
PROJECT_A = GCP_PROJECT_ID
|
||||
PROJECT_B = "test-project-b"
|
||||
|
||||
|
||||
def _pool_name(project_id, pool_id="my-pool"):
|
||||
return f"projects/{project_id}/locations/global/workloadIdentityPools/{pool_id}"
|
||||
|
||||
|
||||
def _provider_payload(pool_name, provider_id="my-provider"):
|
||||
return {
|
||||
"name": f"{pool_name}/providers/{provider_id}",
|
||||
"state": "ACTIVE",
|
||||
"disabled": False,
|
||||
"attributeMapping": {"google.subject": "assertion.sub"},
|
||||
"oidc": {"issuerUri": "https://token.actions.githubusercontent.com"},
|
||||
"displayName": "gh",
|
||||
}
|
||||
|
||||
|
||||
def _empty_service_accounts(client):
|
||||
"""Stub the service-account calls used by the rest of the IAM __init__."""
|
||||
sa = client.projects.return_value.serviceAccounts.return_value
|
||||
sa.list.return_value.execute.return_value = {"accounts": []}
|
||||
sa.list_next.return_value = None
|
||||
|
||||
|
||||
def _wif_client(_GCPService, _service, _api_version, _credentials):
|
||||
"""Discovery client stub returning one pool with one provider."""
|
||||
client = MagicMock()
|
||||
|
||||
pool_name = _pool_name(GCP_PROJECT_ID)
|
||||
pools = (
|
||||
client.projects.return_value.locations.return_value.workloadIdentityPools.return_value
|
||||
)
|
||||
pools.list.return_value.execute.return_value = {
|
||||
"workloadIdentityPools": [{"name": pool_name, "state": "ACTIVE"}]
|
||||
}
|
||||
pools.list_next.return_value = None
|
||||
|
||||
providers = pools.providers.return_value
|
||||
providers.list.return_value.execute.return_value = {
|
||||
"workloadIdentityPoolProviders": [_provider_payload(pool_name)]
|
||||
}
|
||||
providers.list_next.return_value = None
|
||||
|
||||
_empty_service_accounts(client)
|
||||
return client
|
||||
|
||||
|
||||
def _disabled_pool_client(_GCPService, _service, _api_version, _credentials):
|
||||
"""Discovery client stub: a disabled pool containing an ACTIVE provider."""
|
||||
client = MagicMock()
|
||||
|
||||
pool_name = _pool_name(GCP_PROJECT_ID)
|
||||
pools = (
|
||||
client.projects.return_value.locations.return_value.workloadIdentityPools.return_value
|
||||
)
|
||||
pools.list.return_value.execute.return_value = {
|
||||
"workloadIdentityPools": [
|
||||
{"name": pool_name, "state": "ACTIVE", "disabled": True}
|
||||
]
|
||||
}
|
||||
pools.list_next.return_value = None
|
||||
|
||||
providers = pools.providers.return_value
|
||||
providers.list.return_value.execute.return_value = {
|
||||
"workloadIdentityPoolProviders": [_provider_payload(pool_name)]
|
||||
}
|
||||
providers.list_next.return_value = None
|
||||
|
||||
_empty_service_accounts(client)
|
||||
return client
|
||||
|
||||
|
||||
def _pool_list_failure_client(_GCPService, _service, _api_version, _credentials):
|
||||
"""Pool listing fails for PROJECT_A but succeeds for PROJECT_B."""
|
||||
client = MagicMock()
|
||||
pool_name_b = _pool_name(PROJECT_B)
|
||||
|
||||
pools = (
|
||||
client.projects.return_value.locations.return_value.workloadIdentityPools.return_value
|
||||
)
|
||||
|
||||
def pools_list(parent):
|
||||
request = MagicMock()
|
||||
if f"projects/{PROJECT_A}/" in parent:
|
||||
request.execute.side_effect = Exception("permission denied listing pools")
|
||||
else:
|
||||
request.execute.return_value = {
|
||||
"workloadIdentityPools": [{"name": pool_name_b, "state": "ACTIVE"}]
|
||||
}
|
||||
return request
|
||||
|
||||
pools.list.side_effect = pools_list
|
||||
pools.list_next.return_value = None
|
||||
|
||||
providers = pools.providers.return_value
|
||||
providers.list.return_value.execute.return_value = {
|
||||
"workloadIdentityPoolProviders": [_provider_payload(pool_name_b)]
|
||||
}
|
||||
providers.list_next.return_value = None
|
||||
|
||||
_empty_service_accounts(client)
|
||||
return client
|
||||
|
||||
|
||||
def _provider_list_failure_client(_GCPService, _service, _api_version, _credentials):
|
||||
"""Provider listing fails for pool-1 but succeeds for pool-2 in one project."""
|
||||
client = MagicMock()
|
||||
pool_1 = _pool_name(GCP_PROJECT_ID, "pool-1")
|
||||
pool_2 = _pool_name(GCP_PROJECT_ID, "pool-2")
|
||||
|
||||
pools = (
|
||||
client.projects.return_value.locations.return_value.workloadIdentityPools.return_value
|
||||
)
|
||||
pools.list.return_value.execute.return_value = {
|
||||
"workloadIdentityPools": [
|
||||
{"name": pool_1, "state": "ACTIVE"},
|
||||
{"name": pool_2, "state": "ACTIVE"},
|
||||
]
|
||||
}
|
||||
pools.list_next.return_value = None
|
||||
|
||||
providers = pools.providers.return_value
|
||||
|
||||
def providers_list(parent):
|
||||
request = MagicMock()
|
||||
if parent == pool_1:
|
||||
request.execute.side_effect = Exception(
|
||||
"permission denied listing providers"
|
||||
)
|
||||
else:
|
||||
request.execute.return_value = {
|
||||
"workloadIdentityPoolProviders": [
|
||||
_provider_payload(pool_2, provider_id="provider-2")
|
||||
]
|
||||
}
|
||||
return request
|
||||
|
||||
providers.list.side_effect = providers_list
|
||||
providers.list_next.return_value = None
|
||||
|
||||
_empty_service_accounts(client)
|
||||
return client
|
||||
|
||||
|
||||
def _run_service(client_factory, project_ids):
|
||||
with (
|
||||
patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_gcp_provider(project_ids=project_ids),
|
||||
),
|
||||
patch(
|
||||
"prowler.providers.gcp.lib.service.service.GCPService.__is_api_active__",
|
||||
new=mock_is_api_active,
|
||||
),
|
||||
patch(
|
||||
"prowler.providers.gcp.lib.service.service.GCPService.__generate_client__",
|
||||
new=client_factory,
|
||||
),
|
||||
):
|
||||
from prowler.providers.gcp.services.iam.iam_service import IAM
|
||||
|
||||
return IAM(set_mocked_gcp_provider(project_ids=project_ids))
|
||||
|
||||
|
||||
class TestIAMWorkloadIdentityService:
|
||||
def test_get_workload_identity_pool_providers(self):
|
||||
iam = _run_service(_wif_client, [GCP_PROJECT_ID])
|
||||
|
||||
assert len(iam.workload_identity_pool_providers) == 1
|
||||
provider = iam.workload_identity_pool_providers[0]
|
||||
assert provider.id == "my-provider"
|
||||
assert provider.pool_id == "my-pool"
|
||||
assert provider.project_id == GCP_PROJECT_ID
|
||||
assert provider.state == "ACTIVE"
|
||||
assert provider.disabled is False
|
||||
assert provider.pool_disabled is False
|
||||
assert provider.attribute_condition == ""
|
||||
assert provider.provider_type == "oidc"
|
||||
assert provider.issuer_uri == "https://token.actions.githubusercontent.com"
|
||||
|
||||
def test_disabled_pool_state_propagates_to_provider(self):
|
||||
iam = _run_service(_disabled_pool_client, [GCP_PROJECT_ID])
|
||||
|
||||
# The provider is ACTIVE, but its parent pool is disabled: the pool's
|
||||
# effective state must travel with the provider record.
|
||||
assert len(iam.workload_identity_pool_providers) == 1
|
||||
provider = iam.workload_identity_pool_providers[0]
|
||||
assert provider.state == "ACTIVE"
|
||||
assert provider.disabled is False
|
||||
assert provider.pool_disabled is True
|
||||
|
||||
def test_pool_list_failure_does_not_block_other_projects(self):
|
||||
iam = _run_service(_pool_list_failure_client, [PROJECT_A, PROJECT_B])
|
||||
|
||||
# PROJECT_A's pool listing failed, but PROJECT_B is still processed.
|
||||
assert len(iam.workload_identity_pool_providers) == 1
|
||||
assert iam.workload_identity_pool_providers[0].project_id == PROJECT_B
|
||||
|
||||
def test_provider_list_failure_only_skips_that_pool(self):
|
||||
iam = _run_service(_provider_list_failure_client, [GCP_PROJECT_ID])
|
||||
|
||||
# pool-1's provider listing failed, but pool-2's provider is still found.
|
||||
assert len(iam.workload_identity_pool_providers) == 1
|
||||
assert iam.workload_identity_pool_providers[0].pool_id == "pool-2"
|
||||
assert iam.workload_identity_pool_providers[0].id == "provider-2"
|
||||
@@ -6,7 +6,6 @@ from prowler.providers.huaweicloud.services.vpc.vpc_service import (
|
||||
SecurityGroupRule,
|
||||
SecurityGroups,
|
||||
VPCs,
|
||||
rule_source_is_open,
|
||||
)
|
||||
from tests.providers.huaweicloud.huaweicloud_fixtures import (
|
||||
set_mocked_huaweicloud_provider,
|
||||
@@ -25,18 +24,6 @@ def _provider_with_client(regional_client):
|
||||
|
||||
|
||||
class TestVPCService:
|
||||
def test_rule_with_remote_address_group_is_not_open(self):
|
||||
rule = SecurityGroupRule(
|
||||
id="rule-1",
|
||||
direction="ingress",
|
||||
protocol="tcp",
|
||||
ethertype="IPv4",
|
||||
remote_ip_prefix="",
|
||||
remote_address_group_id="address-group-1",
|
||||
)
|
||||
|
||||
assert rule_source_is_open(rule) is False
|
||||
|
||||
def test_list_vpcs_and_security_groups_parses(self):
|
||||
vpc = SimpleNamespace(
|
||||
id="vpc-1",
|
||||
@@ -49,14 +36,12 @@ class TestVPCService:
|
||||
rule = SimpleNamespace(
|
||||
id="rule-1",
|
||||
direction="ingress",
|
||||
action="deny",
|
||||
protocol="tcp",
|
||||
ethertype="IPv4",
|
||||
port_range_min=22,
|
||||
port_range_max=22,
|
||||
remote_ip_prefix="0.0.0.0/0",
|
||||
remote_group_id="",
|
||||
remote_address_group_id="address-group-1",
|
||||
description="ssh open",
|
||||
)
|
||||
sg = SimpleNamespace(
|
||||
@@ -97,10 +82,8 @@ class TestVPCService:
|
||||
parsed_rule = parsed_sg.rules[0]
|
||||
assert isinstance(parsed_rule, SecurityGroupRule)
|
||||
assert parsed_rule.direction == "ingress"
|
||||
assert parsed_rule.action == "deny"
|
||||
assert parsed_rule.protocol == "tcp"
|
||||
assert parsed_rule.remote_ip_prefix == "0.0.0.0/0"
|
||||
assert parsed_rule.remote_address_group_id == "address-group-1"
|
||||
assert parsed_rule.port_range_min == 22
|
||||
assert parsed_rule.port_range_max == 22
|
||||
|
||||
@@ -111,14 +94,12 @@ class TestVPCService:
|
||||
rule = SimpleNamespace(
|
||||
id="rule-1",
|
||||
direction=None,
|
||||
action=None,
|
||||
protocol=None,
|
||||
ethertype=None,
|
||||
port_range_min=None,
|
||||
port_range_max=None,
|
||||
remote_ip_prefix=None,
|
||||
remote_group_id=None,
|
||||
remote_address_group_id=None,
|
||||
description=None,
|
||||
)
|
||||
sg = SimpleNamespace(
|
||||
@@ -153,10 +134,8 @@ class TestVPCService:
|
||||
assert parsed_sg.name == "sg-1" # falls back to id
|
||||
assert parsed_sg.vpc_id == ""
|
||||
parsed_rule = parsed_sg.rules[0]
|
||||
assert parsed_rule.action == "allow"
|
||||
assert parsed_rule.protocol == ""
|
||||
assert parsed_rule.remote_ip_prefix == ""
|
||||
assert parsed_rule.remote_address_group_id == ""
|
||||
assert parsed_rule.description == ""
|
||||
assert parsed_rule.direction == ""
|
||||
|
||||
|
||||
@@ -1,277 +0,0 @@
|
||||
from unittest import mock
|
||||
|
||||
from tests.providers.huaweicloud.huaweicloud_fixtures import (
|
||||
set_mocked_huaweicloud_provider,
|
||||
)
|
||||
|
||||
|
||||
class TestVpcSecurityGroupOpenEgress:
|
||||
def test_no_open_egress_passes(self):
|
||||
vpc_client = mock.MagicMock()
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_huaweicloud_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.huaweicloud.services.vpc.vpc_security_group_open_egress.vpc_security_group_open_egress.vpc_client",
|
||||
new=vpc_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.huaweicloud.services.vpc.vpc_security_group_open_egress.vpc_security_group_open_egress import (
|
||||
vpc_security_group_open_egress,
|
||||
)
|
||||
from prowler.providers.huaweicloud.services.vpc.vpc_service import (
|
||||
SecurityGroupRule,
|
||||
SecurityGroups,
|
||||
)
|
||||
|
||||
sg = SecurityGroups(
|
||||
id="sg-1",
|
||||
name="safe-sg",
|
||||
region="la-south-2",
|
||||
vpc_id="vpc-1",
|
||||
rules=[
|
||||
SecurityGroupRule(
|
||||
id="rule-1",
|
||||
direction="egress",
|
||||
protocol="tcp",
|
||||
ethertype="IPv4",
|
||||
remote_ip_prefix="10.0.0.0/24",
|
||||
port_range_min=443,
|
||||
port_range_max=443,
|
||||
),
|
||||
SecurityGroupRule(
|
||||
id="deny-rule",
|
||||
direction="egress",
|
||||
action="deny",
|
||||
protocol="",
|
||||
ethertype="IPv4",
|
||||
remote_ip_prefix="",
|
||||
),
|
||||
SecurityGroupRule(
|
||||
id="address-group-rule",
|
||||
direction="egress",
|
||||
action="allow",
|
||||
protocol="",
|
||||
ethertype="IPv4",
|
||||
remote_ip_prefix="",
|
||||
remote_address_group_id="address-group-1",
|
||||
),
|
||||
],
|
||||
)
|
||||
vpc_client.security_groups = {"sg-1": sg}
|
||||
vpc_client.audited_account = "123456789012"
|
||||
|
||||
check = vpc_security_group_open_egress()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "PASS"
|
||||
assert result[0].status_extended == (
|
||||
"Security group safe-sg (sg-1) does not allow open egress to "
|
||||
"the internet."
|
||||
)
|
||||
assert result[0].resource_id == "sg-1"
|
||||
assert result[0].resource_name == "safe-sg"
|
||||
assert result[0].resource_arn == (
|
||||
"huaweicloud:vpc:la-south-2:123456789012:security-group/sg-1"
|
||||
)
|
||||
assert result[0].region == "la-south-2"
|
||||
|
||||
def test_open_egress_ipv4_fails(self):
|
||||
vpc_client = mock.MagicMock()
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_huaweicloud_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.huaweicloud.services.vpc.vpc_security_group_open_egress.vpc_security_group_open_egress.vpc_client",
|
||||
new=vpc_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.huaweicloud.services.vpc.vpc_security_group_open_egress.vpc_security_group_open_egress import (
|
||||
vpc_security_group_open_egress,
|
||||
)
|
||||
from prowler.providers.huaweicloud.services.vpc.vpc_service import (
|
||||
SecurityGroupRule,
|
||||
SecurityGroups,
|
||||
)
|
||||
|
||||
sg = SecurityGroups(
|
||||
id="sg-1",
|
||||
name="open-egress-sg",
|
||||
region="la-south-2",
|
||||
vpc_id="vpc-1",
|
||||
rules=[
|
||||
SecurityGroupRule(
|
||||
id="rule-1",
|
||||
direction="egress",
|
||||
protocol="tcp",
|
||||
ethertype="IPv4",
|
||||
remote_ip_prefix="0.0.0.0/0",
|
||||
port_range_min=80,
|
||||
port_range_max=80,
|
||||
),
|
||||
],
|
||||
)
|
||||
vpc_client.security_groups = {"sg-1": sg}
|
||||
vpc_client.audited_account = "123456789012"
|
||||
|
||||
check = vpc_security_group_open_egress()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert result[0].status_extended == (
|
||||
"Security group open-egress-sg (sg-1) allows open egress "
|
||||
"(0.0.0.0/0) to the internet."
|
||||
)
|
||||
assert result[0].resource_id == "sg-1"
|
||||
assert result[0].resource_name == "open-egress-sg"
|
||||
assert result[0].resource_arn == (
|
||||
"huaweicloud:vpc:la-south-2:123456789012:security-group/sg-1"
|
||||
)
|
||||
assert result[0].region == "la-south-2"
|
||||
|
||||
def test_open_egress_ipv6_fails(self):
|
||||
vpc_client = mock.MagicMock()
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_huaweicloud_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.huaweicloud.services.vpc.vpc_security_group_open_egress.vpc_security_group_open_egress.vpc_client",
|
||||
new=vpc_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.huaweicloud.services.vpc.vpc_security_group_open_egress.vpc_security_group_open_egress import (
|
||||
vpc_security_group_open_egress,
|
||||
)
|
||||
from prowler.providers.huaweicloud.services.vpc.vpc_service import (
|
||||
SecurityGroupRule,
|
||||
SecurityGroups,
|
||||
)
|
||||
|
||||
sg = SecurityGroups(
|
||||
id="sg-1",
|
||||
name="open-egress-sg-ipv6",
|
||||
region="la-south-2",
|
||||
vpc_id="vpc-1",
|
||||
rules=[
|
||||
SecurityGroupRule(
|
||||
id="rule-1",
|
||||
direction="egress",
|
||||
protocol="tcp",
|
||||
ethertype="IPv6",
|
||||
remote_ip_prefix="::/0",
|
||||
port_range_min=443,
|
||||
port_range_max=443,
|
||||
),
|
||||
],
|
||||
)
|
||||
vpc_client.security_groups = {"sg-1": sg}
|
||||
vpc_client.audited_account = "123456789012"
|
||||
|
||||
check = vpc_security_group_open_egress()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert result[0].status_extended == (
|
||||
"Security group open-egress-sg-ipv6 (sg-1) allows open egress "
|
||||
"(::/0) to the internet."
|
||||
)
|
||||
assert result[0].resource_id == "sg-1"
|
||||
assert result[0].resource_name == "open-egress-sg-ipv6"
|
||||
assert result[0].resource_arn == (
|
||||
"huaweicloud:vpc:la-south-2:123456789012:security-group/sg-1"
|
||||
)
|
||||
assert result[0].region == "la-south-2"
|
||||
|
||||
def test_open_egress_with_empty_destination_fails(self):
|
||||
vpc_client = mock.MagicMock()
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_huaweicloud_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.huaweicloud.services.vpc.vpc_security_group_open_egress.vpc_security_group_open_egress.vpc_client",
|
||||
new=vpc_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.huaweicloud.services.vpc.vpc_security_group_open_egress.vpc_security_group_open_egress import (
|
||||
vpc_security_group_open_egress,
|
||||
)
|
||||
from prowler.providers.huaweicloud.services.vpc.vpc_service import (
|
||||
SecurityGroupRule,
|
||||
SecurityGroups,
|
||||
)
|
||||
|
||||
sg = SecurityGroups(
|
||||
id="sg-1",
|
||||
name="open-egress-sg-empty-destination",
|
||||
region="la-south-2",
|
||||
vpc_id="vpc-1",
|
||||
rules=[
|
||||
SecurityGroupRule(
|
||||
id="rule-1",
|
||||
direction="egress",
|
||||
action="allow",
|
||||
protocol="",
|
||||
ethertype="IPv4",
|
||||
remote_ip_prefix="",
|
||||
remote_address_group_id="",
|
||||
),
|
||||
],
|
||||
)
|
||||
vpc_client.security_groups = {"sg-1": sg}
|
||||
vpc_client.audited_account = "123456789012"
|
||||
|
||||
check = vpc_security_group_open_egress()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 1
|
||||
assert result[0].status == "FAIL"
|
||||
assert result[0].status_extended == (
|
||||
"Security group open-egress-sg-empty-destination (sg-1) allows "
|
||||
"open egress (all destinations) to the internet."
|
||||
)
|
||||
assert result[0].resource_id == "sg-1"
|
||||
assert result[0].resource_name == "open-egress-sg-empty-destination"
|
||||
assert result[0].resource_arn == (
|
||||
"huaweicloud:vpc:la-south-2:123456789012:security-group/sg-1"
|
||||
)
|
||||
assert result[0].region == "la-south-2"
|
||||
|
||||
def test_no_security_groups(self):
|
||||
vpc_client = mock.MagicMock()
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_huaweicloud_provider(),
|
||||
),
|
||||
mock.patch(
|
||||
"prowler.providers.huaweicloud.services.vpc.vpc_security_group_open_egress.vpc_security_group_open_egress.vpc_client",
|
||||
new=vpc_client,
|
||||
),
|
||||
):
|
||||
from prowler.providers.huaweicloud.services.vpc.vpc_security_group_open_egress.vpc_security_group_open_egress import (
|
||||
vpc_security_group_open_egress,
|
||||
)
|
||||
|
||||
vpc_client.security_groups = {}
|
||||
vpc_client.audited_account = "123456789012"
|
||||
|
||||
check = vpc_security_group_open_egress()
|
||||
result = check.execute()
|
||||
|
||||
assert len(result) == 0
|
||||
@@ -1 +0,0 @@
|
||||
Prowler Cloud indicator for providers created via Import Findings alongside every connection status
|
||||
@@ -1 +0,0 @@
|
||||
Scan auto-refresh no longer overlaps slow client refreshes and now signals when scan execution settles
|
||||
@@ -1 +0,0 @@
|
||||
Display the default one-scan free trial and trial expiration in the existing sidebar banner
|
||||
@@ -1,217 +0,0 @@
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
TRIAL_SIDEBAR_BANNER_VARIANT,
|
||||
TrialSidebarBanner,
|
||||
} from "./trial-sidebar-banner";
|
||||
|
||||
describe("TrialSidebarBanner", () => {
|
||||
it("preserves the active day-based trial card", () => {
|
||||
// Given / When
|
||||
render(
|
||||
<TrialSidebarBanner
|
||||
variant={TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_DAYS}
|
||||
remaining={7}
|
||||
/>,
|
||||
);
|
||||
|
||||
// Then
|
||||
const banner = screen.getByRole("status", { name: "Active trial" });
|
||||
expect(banner).toHaveTextContent("Unlimited trial");
|
||||
expect(banner).toHaveTextContent("7 days left");
|
||||
expect(banner).toHaveTextContent(
|
||||
"Unlimited accounts, scans, and daily schedules",
|
||||
);
|
||||
expect(banner).toHaveTextContent("Explore plans");
|
||||
expect(banner).toHaveAttribute("data-slot", "sidebar-trial");
|
||||
expect(
|
||||
screen.getByRole("link", {
|
||||
name: "Explore plans for your unlimited trial",
|
||||
}),
|
||||
).toHaveAttribute("href", "/billing");
|
||||
});
|
||||
|
||||
it("preserves an active unlimited trial without a counter", () => {
|
||||
// Given / When
|
||||
render(
|
||||
<TrialSidebarBanner
|
||||
variant={TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_UNLIMITED}
|
||||
/>,
|
||||
);
|
||||
|
||||
// Then
|
||||
const banner = screen.getByRole("status", { name: "Active trial" });
|
||||
expect(banner).toHaveTextContent("Unlimited trial");
|
||||
expect(banner).toHaveTextContent("Trial active");
|
||||
expect(banner).toHaveTextContent(
|
||||
"Unlimited accounts, scans, and daily schedules",
|
||||
);
|
||||
expect(banner).toHaveAttribute("data-urgency", "healthy");
|
||||
expect(
|
||||
screen.getByRole("link", {
|
||||
name: "Explore plans for your unlimited trial",
|
||||
}),
|
||||
).toHaveAttribute("href", "/billing");
|
||||
});
|
||||
|
||||
it("formats a singular remaining day", () => {
|
||||
// Given / When
|
||||
render(
|
||||
<TrialSidebarBanner
|
||||
variant={TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_DAYS}
|
||||
remaining={1}
|
||||
/>,
|
||||
);
|
||||
|
||||
// Then
|
||||
const banner = screen.getByRole("status", { name: "Active trial" });
|
||||
expect(banner).toHaveTextContent("1 day left");
|
||||
expect(banner).toHaveAttribute("data-urgency", "critical");
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ remaining: 1, copy: "1 scan left", urgency: "healthy" },
|
||||
{ remaining: 5, copy: "5 scans left", urgency: "healthy" },
|
||||
])(
|
||||
"formats $remaining remaining scan(s) in the active card",
|
||||
({ remaining, copy, urgency }) => {
|
||||
// Given / When
|
||||
render(
|
||||
<TrialSidebarBanner
|
||||
variant={TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_SCANS}
|
||||
remaining={remaining}
|
||||
/>,
|
||||
);
|
||||
|
||||
// Then
|
||||
const banner = screen.getByRole("status", { name: "Active trial" });
|
||||
expect(banner).toHaveTextContent(copy);
|
||||
expect(banner).toHaveTextContent("Free trial");
|
||||
expect(banner).not.toHaveTextContent("Unlimited trial");
|
||||
expect(banner).toHaveTextContent(
|
||||
"Choose a plan to keep running scans after your trial ends.",
|
||||
);
|
||||
expect(banner).toHaveAttribute("data-urgency", urgency);
|
||||
expect(
|
||||
screen.getByRole("link", {
|
||||
name: "Explore plans for your free trial",
|
||||
}),
|
||||
).toHaveAttribute("href", "/billing");
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
{ remaining: 0, copy: "0 scans left" },
|
||||
{ remaining: -4, copy: "0 scans left" },
|
||||
])(
|
||||
"marks a scan trial with $remaining remaining as spent",
|
||||
({ remaining, copy }) => {
|
||||
// Given / When
|
||||
render(
|
||||
<TrialSidebarBanner
|
||||
variant={TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_SCANS}
|
||||
remaining={remaining}
|
||||
/>,
|
||||
);
|
||||
|
||||
// Then
|
||||
const banner = screen.getByRole("status", { name: "Active trial" });
|
||||
expect(banner).toHaveTextContent(copy);
|
||||
expect(banner).toHaveAttribute("data-urgency", "critical");
|
||||
expect(screen.getByText("Free trial")).toHaveClass(
|
||||
"bg-bg-fail-secondary",
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("renders exhausted scan trials with the existing expired presentation", () => {
|
||||
// Given / When
|
||||
render(
|
||||
<TrialSidebarBanner variant={TRIAL_SIDEBAR_BANNER_VARIANT.EXPIRED} />,
|
||||
);
|
||||
|
||||
// Then
|
||||
const banner = screen.getByRole("status", { name: "Expired trial" });
|
||||
expect(banner).toHaveTextContent("Trial expired");
|
||||
expect(banner).toHaveTextContent("Subscription required");
|
||||
expect(banner).toHaveTextContent(
|
||||
"Subscribe to continue scanning and running scheduled scans.",
|
||||
);
|
||||
expect(banner).not.toHaveTextContent("0 scans left");
|
||||
expect(banner).toHaveAttribute("data-urgency", "critical");
|
||||
expect(
|
||||
screen.getByRole("link", {
|
||||
name: "Explore plans after your trial expired",
|
||||
}),
|
||||
).toHaveAttribute("href", "/billing");
|
||||
});
|
||||
|
||||
it("invokes the sidebar selection callback from the billing CTA", async () => {
|
||||
// Given
|
||||
const user = userEvent.setup();
|
||||
const onSelect = vi.fn();
|
||||
render(
|
||||
<TrialSidebarBanner
|
||||
variant={TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_DAYS}
|
||||
remaining={7}
|
||||
onSelect={onSelect}
|
||||
/>,
|
||||
);
|
||||
document.addEventListener("click", (event) => event.preventDefault(), {
|
||||
once: true,
|
||||
});
|
||||
|
||||
// When
|
||||
await user.click(
|
||||
screen.getByRole("link", {
|
||||
name: "Explore plans for your unlimited trial",
|
||||
}),
|
||||
);
|
||||
|
||||
// Then
|
||||
expect(onSelect).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
// The tilt runs on animation frames and `useReducedMotion` caches its media
|
||||
// query module-globally, so both belong in Browser Mode, not jsdom.
|
||||
it("renders the decorative glow layer", () => {
|
||||
// Given / When
|
||||
const { container } = render(
|
||||
<TrialSidebarBanner
|
||||
variant={TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_DAYS}
|
||||
remaining={7}
|
||||
/>,
|
||||
);
|
||||
|
||||
// Then
|
||||
const glow = container.querySelector('[data-slot="trial-glow"]');
|
||||
expect(glow).toBeInTheDocument();
|
||||
expect(glow).toHaveClass("motion-reduce:hidden");
|
||||
});
|
||||
|
||||
it.each([{ pointerType: "touch" }, { pointerType: "mouse" }])(
|
||||
"keeps the card usable under $pointerType input",
|
||||
({ pointerType }) => {
|
||||
// Given
|
||||
render(
|
||||
<TrialSidebarBanner
|
||||
variant={TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_DAYS}
|
||||
remaining={7}
|
||||
/>,
|
||||
);
|
||||
const card = screen.getByRole("link", {
|
||||
name: "Explore plans for your unlimited trial",
|
||||
});
|
||||
|
||||
// When
|
||||
fireEvent.pointerMove(card, { clientX: 250, clientY: 60, pointerType });
|
||||
fireEvent.pointerLeave(card);
|
||||
|
||||
// Then
|
||||
expect(card).toBeInTheDocument();
|
||||
expect(card).toHaveTextContent("7 days left");
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -1,317 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
motion,
|
||||
useMotionValue,
|
||||
useReducedMotion,
|
||||
useSpring,
|
||||
useTransform,
|
||||
} from "framer-motion";
|
||||
import { ArrowRight, Sparkles } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { type PointerEvent } from "react";
|
||||
|
||||
import { Badge } from "@/components/shadcn/badge/badge";
|
||||
import { Card } from "@/components/shadcn/card/card";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export const TRIAL_SIDEBAR_BANNER_VARIANT = {
|
||||
ACTIVE_DAYS: "active_days",
|
||||
ACTIVE_SCANS: "active_scans",
|
||||
ACTIVE_UNLIMITED: "active_unlimited",
|
||||
EXPIRED: "expired",
|
||||
} as const;
|
||||
|
||||
interface TrialSidebarBannerBaseProps {
|
||||
onSelect?: () => HTMLElement | null;
|
||||
}
|
||||
|
||||
interface ActiveTrialSidebarBannerProps extends TrialSidebarBannerBaseProps {
|
||||
remaining: number;
|
||||
}
|
||||
|
||||
interface ActiveDaysTrialSidebarBannerProps
|
||||
extends ActiveTrialSidebarBannerProps {
|
||||
variant: typeof TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_DAYS;
|
||||
}
|
||||
|
||||
interface ActiveScansTrialSidebarBannerProps
|
||||
extends ActiveTrialSidebarBannerProps {
|
||||
variant: typeof TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_SCANS;
|
||||
}
|
||||
|
||||
interface ActiveUnlimitedTrialSidebarBannerProps
|
||||
extends TrialSidebarBannerBaseProps {
|
||||
variant: typeof TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_UNLIMITED;
|
||||
remaining?: never;
|
||||
}
|
||||
|
||||
interface ExpiredTrialSidebarBannerProps extends TrialSidebarBannerBaseProps {
|
||||
variant: typeof TRIAL_SIDEBAR_BANNER_VARIANT.EXPIRED;
|
||||
remaining?: never;
|
||||
}
|
||||
|
||||
export type TrialSidebarBannerProps =
|
||||
| ActiveDaysTrialSidebarBannerProps
|
||||
| ActiveScansTrialSidebarBannerProps
|
||||
| ActiveUnlimitedTrialSidebarBannerProps
|
||||
| ExpiredTrialSidebarBannerProps;
|
||||
|
||||
const TRIAL_URGENCY = {
|
||||
HEALTHY: "healthy",
|
||||
WARNING: "warning",
|
||||
CRITICAL: "critical",
|
||||
} as const;
|
||||
|
||||
type TrialUrgency = (typeof TRIAL_URGENCY)[keyof typeof TRIAL_URGENCY];
|
||||
|
||||
const TRIAL_SIDEBAR_BANNER_UNIT = {
|
||||
DAY: "day",
|
||||
SCAN: "scan",
|
||||
} as const;
|
||||
|
||||
type TrialSidebarBannerUnit =
|
||||
(typeof TRIAL_SIDEBAR_BANNER_UNIT)[keyof typeof TRIAL_SIDEBAR_BANNER_UNIT];
|
||||
|
||||
type TrialSidebarBannerVariant =
|
||||
(typeof TRIAL_SIDEBAR_BANNER_VARIANT)[keyof typeof TRIAL_SIDEBAR_BANNER_VARIANT];
|
||||
|
||||
type MeteredTrialVariant = Extract<
|
||||
TrialSidebarBannerProps,
|
||||
{ remaining: number }
|
||||
>["variant"];
|
||||
|
||||
interface TrialSidebarBannerCopy {
|
||||
badge: string;
|
||||
body: string;
|
||||
linkLabel: string;
|
||||
cardLabel: string;
|
||||
}
|
||||
|
||||
const UNLIMITED_COPY = {
|
||||
badge: "Unlimited trial",
|
||||
body: "Unlimited accounts, scans, and daily schedules. Subscribe to keep everything running.",
|
||||
linkLabel: "Explore plans for your unlimited trial",
|
||||
cardLabel: "Active trial",
|
||||
} as const satisfies TrialSidebarBannerCopy;
|
||||
|
||||
// Keyed maps rather than ternaries: a new variant fails to compile until every
|
||||
// string and unit is supplied for it.
|
||||
const TRIAL_SIDEBAR_BANNER_COPY: Record<
|
||||
TrialSidebarBannerVariant,
|
||||
TrialSidebarBannerCopy
|
||||
> = {
|
||||
[TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_DAYS]: UNLIMITED_COPY,
|
||||
[TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_UNLIMITED]: UNLIMITED_COPY,
|
||||
[TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_SCANS]: {
|
||||
badge: "Free trial",
|
||||
body: "Choose a plan to keep running scans after your trial ends.",
|
||||
linkLabel: "Explore plans for your free trial",
|
||||
cardLabel: "Active trial",
|
||||
},
|
||||
[TRIAL_SIDEBAR_BANNER_VARIANT.EXPIRED]: {
|
||||
badge: "Trial expired",
|
||||
body: "Subscribe to continue scanning and running scheduled scans.",
|
||||
linkLabel: "Explore plans after your trial expired",
|
||||
cardLabel: "Expired trial",
|
||||
},
|
||||
};
|
||||
|
||||
const TRIAL_SIDEBAR_BANNER_METER: Record<
|
||||
MeteredTrialVariant,
|
||||
TrialSidebarBannerUnit
|
||||
> = {
|
||||
[TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_DAYS]: TRIAL_SIDEBAR_BANNER_UNIT.DAY,
|
||||
[TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_SCANS]: TRIAL_SIDEBAR_BANNER_UNIT.SCAN,
|
||||
};
|
||||
|
||||
interface TrialUrgencyStyles {
|
||||
sidebarBorder: string;
|
||||
sidebarTint: string;
|
||||
sidebarGlow: string;
|
||||
}
|
||||
|
||||
const TRIAL_URGENCY_STYLES: Record<TrialUrgency, TrialUrgencyStyles> = {
|
||||
[TRIAL_URGENCY.HEALTHY]: {
|
||||
sidebarBorder: "border-button-primary",
|
||||
sidebarTint: "bg-button-primary/10",
|
||||
sidebarGlow: "bg-button-primary/20",
|
||||
},
|
||||
[TRIAL_URGENCY.WARNING]: {
|
||||
sidebarBorder: "border-bg-warning",
|
||||
sidebarTint: "bg-bg-warning-secondary/20",
|
||||
sidebarGlow: "bg-bg-warning/20",
|
||||
},
|
||||
[TRIAL_URGENCY.CRITICAL]: {
|
||||
sidebarBorder: "border-border-error",
|
||||
sidebarTint: "bg-bg-fail-secondary/40",
|
||||
sidebarGlow: "bg-bg-fail/20",
|
||||
},
|
||||
};
|
||||
|
||||
const getTrialUrgency = (props: TrialSidebarBannerProps): TrialUrgency => {
|
||||
if (props.variant === TRIAL_SIDEBAR_BANNER_VARIANT.EXPIRED) {
|
||||
return TRIAL_URGENCY.CRITICAL;
|
||||
}
|
||||
if (
|
||||
props.variant === TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_SCANS &&
|
||||
props.remaining > 0
|
||||
) {
|
||||
return TRIAL_URGENCY.HEALTHY;
|
||||
}
|
||||
if (props.variant === TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_UNLIMITED) {
|
||||
return TRIAL_URGENCY.HEALTHY;
|
||||
}
|
||||
if (props.remaining <= 1) return TRIAL_URGENCY.CRITICAL;
|
||||
if (props.remaining <= 5) return TRIAL_URGENCY.WARNING;
|
||||
return TRIAL_URGENCY.HEALTHY;
|
||||
};
|
||||
|
||||
const formatRemaining = (remaining: number, unit: TrialSidebarBannerUnit) => {
|
||||
// The API sends a cap and a usage counter, so callers subtract and can go negative.
|
||||
const left = Math.max(0, remaining);
|
||||
|
||||
return `${left} ${unit}${left === 1 ? "" : "s"} left`;
|
||||
};
|
||||
|
||||
const TILT_SPRING = { stiffness: 260, damping: 26, mass: 0.6 } as const;
|
||||
const TILT_RESTING_POINTER = 0.5;
|
||||
const TILT_RANGE_X = 1.5;
|
||||
const TILT_RANGE_Y = 2;
|
||||
const TILT_LIFT = -2;
|
||||
|
||||
export const TrialSidebarBanner = (props: TrialSidebarBannerProps) => {
|
||||
const isExpired = props.variant === TRIAL_SIDEBAR_BANNER_VARIANT.EXPIRED;
|
||||
const isScanBased =
|
||||
props.variant === TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_SCANS;
|
||||
// The backend keeps a scan-capped trial `active` once its quota is spent.
|
||||
const isExhausted = isScanBased && props.remaining <= 0;
|
||||
const urgency = getTrialUrgency(props);
|
||||
const urgencyStyles = TRIAL_URGENCY_STYLES[urgency];
|
||||
const copy = TRIAL_SIDEBAR_BANNER_COPY[props.variant];
|
||||
const heading = isExpired
|
||||
? "Subscription required"
|
||||
: props.variant === TRIAL_SIDEBAR_BANNER_VARIANT.ACTIVE_UNLIMITED
|
||||
? "Trial active"
|
||||
: formatRemaining(
|
||||
props.remaining,
|
||||
TRIAL_SIDEBAR_BANNER_METER[props.variant],
|
||||
);
|
||||
|
||||
const prefersReducedMotion = useReducedMotion();
|
||||
|
||||
// Normalised pointer position (0..1) over the card.
|
||||
const pointerX = useMotionValue(TILT_RESTING_POINTER);
|
||||
const pointerY = useMotionValue(TILT_RESTING_POINTER);
|
||||
const hover = useMotionValue(0);
|
||||
|
||||
const rotateX = useSpring(
|
||||
useTransform(pointerY, [0, 1], [TILT_RANGE_X, -TILT_RANGE_X]),
|
||||
TILT_SPRING,
|
||||
);
|
||||
const rotateY = useSpring(
|
||||
useTransform(pointerX, [0, 1], [-TILT_RANGE_Y, TILT_RANGE_Y]),
|
||||
TILT_SPRING,
|
||||
);
|
||||
const lift = useSpring(
|
||||
useTransform(hover, [0, 1], [0, TILT_LIFT]),
|
||||
TILT_SPRING,
|
||||
);
|
||||
const glowLeft = useTransform(pointerX, (value) => `${value * 100}%`);
|
||||
const glowTop = useTransform(pointerY, (value) => `${value * 100}%`);
|
||||
|
||||
const resetMotion = () => {
|
||||
pointerX.set(TILT_RESTING_POINTER);
|
||||
pointerY.set(TILT_RESTING_POINTER);
|
||||
hover.set(0);
|
||||
};
|
||||
|
||||
const followPointer = (event: PointerEvent<HTMLAnchorElement>) => {
|
||||
if (prefersReducedMotion || event.pointerType === "touch") return;
|
||||
|
||||
const bounds = event.currentTarget.getBoundingClientRect();
|
||||
if (!bounds.width || !bounds.height) return;
|
||||
|
||||
pointerX.set((event.clientX - bounds.left) / bounds.width);
|
||||
pointerY.set((event.clientY - bounds.top) / bounds.height);
|
||||
hover.set(1);
|
||||
};
|
||||
|
||||
return (
|
||||
<Link
|
||||
href="/billing"
|
||||
aria-label={copy.linkLabel}
|
||||
onClick={props.onSelect}
|
||||
onPointerMove={followPointer}
|
||||
onPointerLeave={resetMotion}
|
||||
onPointerCancel={resetMotion}
|
||||
onBlur={resetMotion}
|
||||
className="focus-visible:ring-button-primary/50 group mx-3 mb-4 block rounded-xl focus-visible:ring-2 focus-visible:outline-none"
|
||||
>
|
||||
<motion.div
|
||||
className="rounded-xl"
|
||||
style={{ transformPerspective: 700, rotateX, rotateY, y: lift }}
|
||||
>
|
||||
<Card
|
||||
variant="inner"
|
||||
padding="sm"
|
||||
data-slot="sidebar-trial"
|
||||
data-urgency={urgency}
|
||||
role="status"
|
||||
aria-label={copy.cardLabel}
|
||||
// role="status" is implicitly atomic, which re-reads the whole card
|
||||
// on every counter change.
|
||||
aria-atomic="false"
|
||||
className={cn(
|
||||
"relative gap-3 overflow-hidden transition-colors duration-200",
|
||||
urgencyStyles.sidebarBorder,
|
||||
urgencyStyles.sidebarTint,
|
||||
)}
|
||||
>
|
||||
<motion.span
|
||||
data-slot="trial-glow"
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"pointer-events-none absolute size-32 rounded-full opacity-0 blur-3xl transition-opacity duration-300 group-hover:opacity-100 motion-reduce:hidden",
|
||||
urgencyStyles.sidebarGlow,
|
||||
)}
|
||||
style={{ left: glowLeft, top: glowTop, x: "-50%", y: "-50%" }}
|
||||
/>
|
||||
<div className="relative z-10 flex min-w-0 items-start gap-2.5">
|
||||
<span className="border-border-neutral-tertiary bg-bg-neutral-secondary flex size-9 shrink-0 items-center justify-center rounded-md border">
|
||||
<Sparkles
|
||||
className={cn(
|
||||
"size-4",
|
||||
isExpired ? "text-text-error-primary" : "text-button-primary",
|
||||
)}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-1.5">
|
||||
<Badge
|
||||
variant={isExpired || isExhausted ? "error" : "success"}
|
||||
size="sm"
|
||||
className="w-fit"
|
||||
>
|
||||
{copy.badge}
|
||||
</Badge>
|
||||
<strong className="text-text-neutral-primary text-lg leading-none">
|
||||
{heading}
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-text-neutral-secondary relative z-10 text-xs leading-4">
|
||||
{copy.body}
|
||||
</p>
|
||||
<span className="text-button-primary relative z-10 flex items-center justify-between text-xs font-semibold">
|
||||
Explore plans
|
||||
<ArrowRight
|
||||
className="size-4 transition-transform duration-200 group-hover:translate-x-0.5 motion-reduce:transform-none"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
</Card>
|
||||
</motion.div>
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
@@ -1,7 +1,6 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import type { ReactNode } from "react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
PROVIDERS_ROW_TYPE,
|
||||
@@ -11,18 +10,9 @@ import {
|
||||
|
||||
import { getColumnProviders } from "./column-providers";
|
||||
|
||||
vi.mock("@/components/shadcn", async () => {
|
||||
const tooltip = await vi.importActual<
|
||||
typeof import("@/components/shadcn/tooltip")
|
||||
>("@/components/shadcn/tooltip");
|
||||
|
||||
return {
|
||||
Badge: ({ children, ...props }: { children: ReactNode }) => (
|
||||
<span {...props}>{children}</span>
|
||||
),
|
||||
...tooltip,
|
||||
};
|
||||
});
|
||||
vi.mock("@/components/shadcn", () => ({
|
||||
Badge: ({ children }: { children: ReactNode }) => <span>{children}</span>,
|
||||
}));
|
||||
|
||||
vi.mock("@/components/shadcn/checkbox/checkbox", () => ({
|
||||
Checkbox: () => null,
|
||||
@@ -74,7 +64,6 @@ const providerRow: ProvidersProviderRow = {
|
||||
attributes: {
|
||||
provider: "aws",
|
||||
is_dynamic: false,
|
||||
is_imported: false,
|
||||
uid: "123456789012",
|
||||
alias: "Production",
|
||||
status: "completed",
|
||||
@@ -126,33 +115,6 @@ function renderLastScanCell(row: ProvidersTableRow) {
|
||||
render(<>{element as ReactNode}</>);
|
||||
}
|
||||
|
||||
function renderStatusCell(row: ProvidersTableRow) {
|
||||
const statusColumn = getColumnProviders(
|
||||
{},
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
vi.fn(),
|
||||
vi.fn(),
|
||||
vi.fn(),
|
||||
).find((column) => column.id === "status");
|
||||
|
||||
const cell = statusColumn?.cell;
|
||||
if (typeof cell !== "function") {
|
||||
throw new Error("Status column cell renderer not found");
|
||||
}
|
||||
|
||||
const element = cell({
|
||||
row: { original: row },
|
||||
} as unknown as Parameters<typeof cell>[0]);
|
||||
|
||||
render(<>{element as ReactNode}</>);
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
describe("getColumnProviders", () => {
|
||||
it("falls back to connection last_checked_at when lastScanAt is undefined", () => {
|
||||
renderLastScanCell({ ...providerRow, lastScanAt: undefined });
|
||||
@@ -167,133 +129,4 @@ describe("getColumnProviders", () => {
|
||||
expect(screen.getByText("Never")).toBeVisible();
|
||||
expect(screen.queryByText("2026-01-01T00:00:00Z")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows Not connected with the imported tooltip in Cloud", async () => {
|
||||
// Given
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
const importedProvider = {
|
||||
...providerRow,
|
||||
attributes: {
|
||||
...providerRow.attributes,
|
||||
is_imported: true,
|
||||
connection: {
|
||||
connected: null,
|
||||
last_checked_at: null,
|
||||
},
|
||||
},
|
||||
relationships: {
|
||||
...providerRow.relationships,
|
||||
secret: { data: null },
|
||||
},
|
||||
} satisfies ProvidersProviderRow;
|
||||
|
||||
// When
|
||||
renderStatusCell(importedProvider);
|
||||
|
||||
// Then
|
||||
expect(screen.getByText("Not connected")).toBeVisible();
|
||||
const indicator = screen.getByLabelText("Imported provider");
|
||||
expect(indicator).not.toHaveTextContent("Imported");
|
||||
expect(indicator).toHaveAttribute("tabindex", "0");
|
||||
expect(indicator.querySelector(".lucide-terminal")).toBeInTheDocument();
|
||||
expect(indicator.parentElement).toHaveClass("items-stretch");
|
||||
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("Disconnected")).not.toBeInTheDocument();
|
||||
|
||||
await user.hover(indicator);
|
||||
|
||||
expect(await screen.findByRole("tooltip")).toHaveTextContent(
|
||||
/^This provider has findings imported with the Prowler CLI$/,
|
||||
);
|
||||
});
|
||||
|
||||
it("shows the imported tooltip beside Connected in Cloud", async () => {
|
||||
// Given
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const user = userEvent.setup();
|
||||
const connectedImportedProvider = {
|
||||
...providerRow,
|
||||
attributes: {
|
||||
...providerRow.attributes,
|
||||
is_imported: true,
|
||||
connection: {
|
||||
connected: true,
|
||||
last_checked_at: "2026-01-01T00:00:00Z",
|
||||
},
|
||||
},
|
||||
} satisfies ProvidersProviderRow;
|
||||
|
||||
// When
|
||||
renderStatusCell(connectedImportedProvider);
|
||||
|
||||
// Then
|
||||
expect(screen.getByText("Connected")).toBeVisible();
|
||||
const indicator = screen.getByLabelText("Imported provider");
|
||||
expect(indicator).toBeVisible();
|
||||
expect(indicator.querySelector(".lucide-terminal")).toBeInTheDocument();
|
||||
expect(indicator.parentElement).toHaveClass("items-stretch");
|
||||
expect(indicator).not.toHaveTextContent("Imported");
|
||||
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
|
||||
|
||||
await user.hover(indicator);
|
||||
|
||||
expect(await screen.findByRole("tooltip")).toHaveTextContent(
|
||||
/^This provider has findings imported with the Prowler CLI$/,
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps Connection failed for imported providers in Cloud", () => {
|
||||
// Given
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "true");
|
||||
const importedProviderWithCredentials = {
|
||||
...providerRow,
|
||||
attributes: {
|
||||
...providerRow.attributes,
|
||||
is_imported: true,
|
||||
connection: {
|
||||
connected: false,
|
||||
last_checked_at: null,
|
||||
},
|
||||
},
|
||||
} satisfies ProvidersProviderRow;
|
||||
|
||||
// When
|
||||
renderStatusCell(importedProviderWithCredentials);
|
||||
|
||||
// Then
|
||||
expect(screen.getByText("Connection failed")).toBeVisible();
|
||||
expect(screen.queryByText("Not connected")).not.toBeInTheDocument();
|
||||
const indicator = screen.getByLabelText("Imported provider");
|
||||
expect(indicator).not.toHaveTextContent("Imported");
|
||||
});
|
||||
|
||||
it("does not expose imported provenance in OSS", () => {
|
||||
// Given
|
||||
vi.stubEnv("UI_CLOUD_ENABLED", "false");
|
||||
const importedProvider = {
|
||||
...providerRow,
|
||||
attributes: {
|
||||
...providerRow.attributes,
|
||||
is_imported: true,
|
||||
connection: {
|
||||
connected: null,
|
||||
last_checked_at: null,
|
||||
},
|
||||
},
|
||||
relationships: {
|
||||
...providerRow.relationships,
|
||||
secret: { data: null },
|
||||
},
|
||||
} satisfies ProvidersProviderRow;
|
||||
|
||||
// When
|
||||
renderStatusCell(importedProvider);
|
||||
|
||||
// Then
|
||||
expect(screen.getByText("Not connected")).toBeVisible();
|
||||
expect(
|
||||
screen.queryByLabelText("Imported provider"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import { ColumnDef, Row, RowSelectionState } from "@tanstack/react-table";
|
||||
import { Building2, FolderTree, Terminal } from "lucide-react";
|
||||
import { Building2, FolderTree } from "lucide-react";
|
||||
|
||||
import type {
|
||||
OrgWizardInitialData,
|
||||
ProviderWizardInitialData,
|
||||
} from "@/components/providers/wizard/types";
|
||||
import {
|
||||
Badge,
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/shadcn";
|
||||
import { Badge } from "@/components/shadcn";
|
||||
import { Checkbox } from "@/components/shadcn/checkbox/checkbox";
|
||||
import { CodeSnippet } from "@/components/shadcn/code-snippet/code-snippet";
|
||||
import { DateWithTime, EntityInfo } from "@/components/shadcn/entities";
|
||||
@@ -20,7 +15,6 @@ import { DataTableColumnHeader } from "@/components/shadcn/table";
|
||||
import { DataTableExpandAllToggle } from "@/components/shadcn/table/data-table-expand-all-toggle";
|
||||
import { DataTableExpandableCell } from "@/components/shadcn/table/data-table-expandable-cell";
|
||||
import { getNodeLabel } from "@/lib/organizations";
|
||||
import { isCloud } from "@/lib/shared/env";
|
||||
import {
|
||||
isProvidersOrganizationRow,
|
||||
PROVIDERS_GROUP_KIND,
|
||||
@@ -57,70 +51,28 @@ const OrganizationIcon = ({ groupKind }: { groupKind: ProvidersGroupKind }) => {
|
||||
);
|
||||
};
|
||||
|
||||
interface ProviderStatusCellProps {
|
||||
connected: boolean | null;
|
||||
isImported: boolean;
|
||||
}
|
||||
|
||||
const IMPORTED_PROVIDER_TOOLTIP =
|
||||
"This provider has findings imported with the Prowler CLI";
|
||||
|
||||
const ImportedIndicator = () => {
|
||||
const indicator = (
|
||||
<Badge
|
||||
variant="info"
|
||||
className="text-sm"
|
||||
aria-label="Imported provider"
|
||||
tabIndex={0}
|
||||
>
|
||||
<Terminal aria-hidden />
|
||||
</Badge>
|
||||
);
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>{indicator}</TooltipTrigger>
|
||||
<TooltipContent>{IMPORTED_PROVIDER_TOOLTIP}</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
const ProviderStatusCell = ({
|
||||
connected,
|
||||
isImported,
|
||||
}: ProviderStatusCellProps) => {
|
||||
let statusBadge;
|
||||
|
||||
const ProviderStatusCell = ({ connected }: { connected: boolean | null }) => {
|
||||
if (connected === true) {
|
||||
statusBadge = (
|
||||
return (
|
||||
<Badge variant="success" className="text-sm">
|
||||
Connected
|
||||
</Badge>
|
||||
);
|
||||
} else if (connected === false) {
|
||||
statusBadge = (
|
||||
}
|
||||
|
||||
if (connected === false) {
|
||||
return (
|
||||
<Badge variant="error" className="text-sm">
|
||||
Connection failed
|
||||
</Badge>
|
||||
);
|
||||
} else {
|
||||
statusBadge = (
|
||||
<Badge variant="tag" className="text-text-neutral-secondary text-sm">
|
||||
Not connected
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
|
||||
if (isImported) {
|
||||
return (
|
||||
<div className="flex items-stretch gap-2">
|
||||
{statusBadge}
|
||||
<ImportedIndicator />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return statusBadge;
|
||||
return (
|
||||
<Badge variant="tag" className="text-text-neutral-secondary text-sm">
|
||||
Not connected
|
||||
</Badge>
|
||||
);
|
||||
};
|
||||
|
||||
function getSelectionLabel(row: Row<ProvidersTableRow>): string | undefined {
|
||||
@@ -347,9 +299,6 @@ export function getColumnProviders(
|
||||
return (
|
||||
<ProviderStatusCell
|
||||
connected={row.original.attributes.connection.connected}
|
||||
isImported={
|
||||
isCloud() && Boolean(row.original.attributes.is_imported)
|
||||
}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
import { render } from "@testing-library/react";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { navigationState, routerRefreshMock } = vi.hoisted(() => ({
|
||||
navigationState: { searchParams: new URLSearchParams() },
|
||||
routerRefreshMock: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("next/navigation", () => ({
|
||||
useRouter: () => ({ refresh: routerRefreshMock }),
|
||||
useSearchParams: () => navigationState.searchParams,
|
||||
}));
|
||||
|
||||
import {
|
||||
AutoRefresh,
|
||||
SCAN_EXECUTION_SETTLED_EVENT,
|
||||
SCAN_POLL_TICK_EVENT,
|
||||
} from "./auto-refresh";
|
||||
|
||||
describe("AutoRefresh", () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
vi.clearAllMocks();
|
||||
navigationState.searchParams = new URLSearchParams();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("dispatches a poll tick after a successful callback refresh", async () => {
|
||||
// Given
|
||||
let resolveRefresh!: () => void;
|
||||
const refreshPromise = new Promise<void>((resolve) => {
|
||||
resolveRefresh = resolve;
|
||||
});
|
||||
const onRefresh = vi.fn().mockReturnValue(refreshPromise);
|
||||
const eventListener = vi.fn();
|
||||
window.addEventListener(SCAN_POLL_TICK_EVENT, eventListener);
|
||||
render(<AutoRefresh hasExecutingScan onRefresh={onRefresh} />);
|
||||
|
||||
// When
|
||||
await vi.advanceTimersByTimeAsync(5_000);
|
||||
|
||||
// Then
|
||||
expect(onRefresh).toHaveBeenCalledOnce();
|
||||
expect(eventListener).not.toHaveBeenCalled();
|
||||
|
||||
// When
|
||||
resolveRefresh();
|
||||
await refreshPromise;
|
||||
await Promise.resolve();
|
||||
|
||||
// Then
|
||||
expect(eventListener).toHaveBeenCalledOnce();
|
||||
window.removeEventListener(SCAN_POLL_TICK_EVENT, eventListener);
|
||||
});
|
||||
|
||||
it("dispatches a poll tick after the default router refresh", async () => {
|
||||
// Given
|
||||
const eventListener = vi.fn();
|
||||
window.addEventListener(SCAN_POLL_TICK_EVENT, eventListener);
|
||||
render(<AutoRefresh hasExecutingScan />);
|
||||
|
||||
// When
|
||||
await vi.advanceTimersByTimeAsync(5_000);
|
||||
|
||||
// Then
|
||||
expect(routerRefreshMock).toHaveBeenCalledOnce();
|
||||
expect(eventListener).toHaveBeenCalledOnce();
|
||||
window.removeEventListener(SCAN_POLL_TICK_EVENT, eventListener);
|
||||
});
|
||||
|
||||
it("does not dispatch a poll tick when an async callback rejects", async () => {
|
||||
// Given
|
||||
const onRefresh = vi.fn().mockRejectedValue(new Error("refresh failed"));
|
||||
const eventListener = vi.fn();
|
||||
window.addEventListener(SCAN_POLL_TICK_EVENT, eventListener);
|
||||
render(<AutoRefresh hasExecutingScan onRefresh={onRefresh} />);
|
||||
|
||||
// When
|
||||
await vi.advanceTimersByTimeAsync(5_000);
|
||||
|
||||
// Then
|
||||
expect(onRefresh).toHaveBeenCalledOnce();
|
||||
expect(eventListener).not.toHaveBeenCalled();
|
||||
window.removeEventListener(SCAN_POLL_TICK_EVENT, eventListener);
|
||||
});
|
||||
|
||||
it("does not start another refresh while the previous one is pending", async () => {
|
||||
// Given
|
||||
let resolveRefresh!: () => void;
|
||||
const refreshPromise = new Promise<void>((resolve) => {
|
||||
resolveRefresh = resolve;
|
||||
});
|
||||
const onRefresh = vi.fn().mockReturnValue(refreshPromise);
|
||||
render(<AutoRefresh hasExecutingScan onRefresh={onRefresh} />);
|
||||
|
||||
// When
|
||||
await vi.advanceTimersByTimeAsync(10_000);
|
||||
|
||||
// Then
|
||||
expect(onRefresh).toHaveBeenCalledOnce();
|
||||
|
||||
// When
|
||||
resolveRefresh();
|
||||
await refreshPromise;
|
||||
await vi.advanceTimersByTimeAsync(5_000);
|
||||
|
||||
// Then
|
||||
expect(onRefresh).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("does not dispatch a poll tick after unmounting a pending refresh", async () => {
|
||||
// Given
|
||||
let resolveRefresh!: () => void;
|
||||
const refreshPromise = new Promise<void>((resolve) => {
|
||||
resolveRefresh = resolve;
|
||||
});
|
||||
const onRefresh = vi.fn().mockReturnValue(refreshPromise);
|
||||
const eventListener = vi.fn();
|
||||
window.addEventListener(SCAN_POLL_TICK_EVENT, eventListener);
|
||||
const { unmount } = render(
|
||||
<AutoRefresh hasExecutingScan onRefresh={onRefresh} />,
|
||||
);
|
||||
await vi.advanceTimersByTimeAsync(5_000);
|
||||
|
||||
// When
|
||||
unmount();
|
||||
resolveRefresh();
|
||||
await refreshPromise;
|
||||
await Promise.resolve();
|
||||
|
||||
// Then
|
||||
expect(onRefresh).toHaveBeenCalledOnce();
|
||||
expect(eventListener).not.toHaveBeenCalled();
|
||||
window.removeEventListener(SCAN_POLL_TICK_EVENT, eventListener);
|
||||
});
|
||||
|
||||
it("signals when scan execution settles", () => {
|
||||
// Given
|
||||
const eventListener = vi.fn();
|
||||
window.addEventListener(SCAN_EXECUTION_SETTLED_EVENT, eventListener);
|
||||
const { rerender } = render(<AutoRefresh hasExecutingScan />);
|
||||
|
||||
// When
|
||||
rerender(<AutoRefresh hasExecutingScan={false} />);
|
||||
rerender(<AutoRefresh hasExecutingScan={false} />);
|
||||
|
||||
// Then
|
||||
expect(eventListener).toHaveBeenCalledOnce();
|
||||
window.removeEventListener(SCAN_EXECUTION_SETTLED_EVENT, eventListener);
|
||||
});
|
||||
|
||||
it("does not signal settled execution on an idle initial render", () => {
|
||||
// Given
|
||||
const eventListener = vi.fn();
|
||||
window.addEventListener(SCAN_EXECUTION_SETTLED_EVENT, eventListener);
|
||||
|
||||
// When
|
||||
render(<AutoRefresh hasExecutingScan={false} />);
|
||||
|
||||
// Then
|
||||
expect(eventListener).not.toHaveBeenCalled();
|
||||
window.removeEventListener(SCAN_EXECUTION_SETTLED_EVENT, eventListener);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
hasExecutingScan: false,
|
||||
searchParams: "",
|
||||
condition: "no scan executes",
|
||||
},
|
||||
{
|
||||
hasExecutingScan: true,
|
||||
searchParams: "scanId=scan-executing",
|
||||
condition: "the scan drawer is open",
|
||||
},
|
||||
])(
|
||||
"does not poll when $condition",
|
||||
async ({ hasExecutingScan, searchParams }) => {
|
||||
// Given
|
||||
const onRefresh = vi.fn();
|
||||
const eventListener = vi.fn();
|
||||
navigationState.searchParams = new URLSearchParams(searchParams);
|
||||
window.addEventListener(SCAN_POLL_TICK_EVENT, eventListener);
|
||||
render(
|
||||
<AutoRefresh
|
||||
hasExecutingScan={hasExecutingScan}
|
||||
onRefresh={onRefresh}
|
||||
/>,
|
||||
);
|
||||
|
||||
// When
|
||||
await vi.advanceTimersByTimeAsync(5_000);
|
||||
|
||||
// Then
|
||||
expect(onRefresh).not.toHaveBeenCalled();
|
||||
expect(eventListener).not.toHaveBeenCalled();
|
||||
window.removeEventListener(SCAN_POLL_TICK_EVENT, eventListener);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -1,17 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
/**
|
||||
* Signals that a poll cycle ran, not that fresh data landed: the default branch
|
||||
* calls the fire-and-forget `router.refresh()`, which reports neither.
|
||||
* Listeners must read authoritative state themselves.
|
||||
*/
|
||||
export const SCAN_POLL_TICK_EVENT = "prowler:scan-poll-tick";
|
||||
|
||||
/** Signals the transition from an executing scan to no executing scan. */
|
||||
export const SCAN_EXECUTION_SETTLED_EVENT = "prowler:scan-execution-settled";
|
||||
import { useEffect } from "react";
|
||||
|
||||
interface AutoRefreshProps {
|
||||
hasExecutingScan: boolean;
|
||||
@@ -19,19 +9,9 @@ interface AutoRefreshProps {
|
||||
onRefresh?: () => void | Promise<void>;
|
||||
}
|
||||
|
||||
const useAutoRefresh = ({ hasExecutingScan, onRefresh }: AutoRefreshProps) => {
|
||||
export function AutoRefresh({ hasExecutingScan, onRefresh }: AutoRefreshProps) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const refreshInProgress = useRef(false);
|
||||
const previouslyExecuting = useRef(hasExecutingScan);
|
||||
|
||||
useEffect(() => {
|
||||
if (previouslyExecuting.current && !hasExecutingScan) {
|
||||
window.dispatchEvent(new Event(SCAN_EXECUTION_SETTLED_EVENT));
|
||||
}
|
||||
|
||||
previouslyExecuting.current = hasExecutingScan;
|
||||
}, [hasExecutingScan]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!hasExecutingScan) return;
|
||||
@@ -40,45 +20,18 @@ const useAutoRefresh = ({ hasExecutingScan, onRefresh }: AutoRefreshProps) => {
|
||||
const scanId = searchParams.get("scanId");
|
||||
if (scanId) return;
|
||||
|
||||
let active = true;
|
||||
const interval = setInterval(() => {
|
||||
if (refreshInProgress.current) return;
|
||||
|
||||
const refresh = async () => {
|
||||
refreshInProgress.current = true;
|
||||
|
||||
try {
|
||||
if (onRefresh) {
|
||||
// Use custom refresh callback for client-side state management
|
||||
await onRefresh();
|
||||
} else {
|
||||
// Default: trigger server-side refresh
|
||||
router.refresh();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Scan auto-refresh failed:", error);
|
||||
return;
|
||||
} finally {
|
||||
refreshInProgress.current = false;
|
||||
}
|
||||
|
||||
if (active) {
|
||||
window.dispatchEvent(new Event(SCAN_POLL_TICK_EVENT));
|
||||
}
|
||||
};
|
||||
|
||||
void refresh();
|
||||
if (onRefresh) {
|
||||
// Use custom refresh callback for client-side state management
|
||||
onRefresh();
|
||||
} else {
|
||||
// Default: trigger server-side refresh
|
||||
router.refresh();
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
return () => {
|
||||
active = false;
|
||||
clearInterval(interval);
|
||||
};
|
||||
return () => clearInterval(interval);
|
||||
}, [hasExecutingScan, router, searchParams, onRefresh]);
|
||||
};
|
||||
|
||||
export function AutoRefresh(props: AutoRefreshProps) {
|
||||
useAutoRefresh(props);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -595,9 +595,9 @@
|
||||
"section": "dependencies",
|
||||
"name": "sharp",
|
||||
"from": "0.33.5",
|
||||
"to": "0.35.3",
|
||||
"to": "0.33.5",
|
||||
"strategy": "installed",
|
||||
"generatedAt": "2026-08-11T11:35:35.609Z"
|
||||
"generatedAt": "2025-10-22T12:36:37.962Z"
|
||||
},
|
||||
{
|
||||
"section": "dependencies",
|
||||
|
||||
@@ -80,15 +80,13 @@ export interface ProviderProps {
|
||||
attributes: {
|
||||
provider: ProviderType;
|
||||
is_dynamic: boolean;
|
||||
/** Import Findings provenance returned only by the Prowler Cloud API. */
|
||||
is_imported?: boolean;
|
||||
uid: string;
|
||||
alias: string;
|
||||
status: "completed" | "pending" | "cancelled";
|
||||
resources: number;
|
||||
connection: {
|
||||
connected: boolean | null;
|
||||
last_checked_at: string | null;
|
||||
connected: boolean;
|
||||
last_checked_at: string;
|
||||
};
|
||||
scanner_args: {
|
||||
only_logs: boolean;
|
||||
|
||||
@@ -3752,7 +3752,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "prowler"
|
||||
version = "5.40.0"
|
||||
version = "5.39.1"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "alibabacloud-actiontrail20200706" },
|
||||
@@ -3848,7 +3848,6 @@ dependencies = [
|
||||
{ name = "tabulate" },
|
||||
{ name = "tzlocal" },
|
||||
{ name = "uuid6" },
|
||||
{ name = "zstandard" },
|
||||
]
|
||||
|
||||
[package.dev-dependencies]
|
||||
@@ -3969,7 +3968,6 @@ requires-dist = [
|
||||
{ name = "tabulate", specifier = "==0.9.0" },
|
||||
{ name = "tzlocal", specifier = "==5.3.1" },
|
||||
{ name = "uuid6", specifier = "==2024.7.10" },
|
||||
{ name = "zstandard", specifier = "==0.25.0" },
|
||||
]
|
||||
|
||||
[package.metadata.requires-dev]
|
||||
@@ -5517,81 +5515,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/08/8a/0861bec20485572fbddf3dfba2910e38fe249796cb73ecdeb74e07eeb8d3/zipp-3.23.1-py3-none-any.whl", hash = "sha256:0b3596c50a5c700c9cb40ba8d86d9f2cc4807e9bedb06bcdf7fac85633e444dc", size = 10378, upload-time = "2026-04-13T23:21:45.386Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstandard"
|
||||
version = "0.25.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/fd/aa/3e0508d5a5dd96529cdc5a97011299056e14c6505b678fd58938792794b1/zstandard-0.25.0.tar.gz", hash = "sha256:7713e1179d162cf5c7906da876ec2ccb9c3a9dcbdffef0cc7f70c3667a205f0b", size = 711513, upload-time = "2025-09-14T22:15:54.002Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/56/7a/28efd1d371f1acd037ac64ed1c5e2b41514a6cc937dd6ab6a13ab9f0702f/zstandard-0.25.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e59fdc271772f6686e01e1b3b74537259800f57e24280be3f29c8a0deb1904dd", size = 795256, upload-time = "2025-09-14T22:15:56.415Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/96/34/ef34ef77f1ee38fc8e4f9775217a613b452916e633c4f1d98f31db52c4a5/zstandard-0.25.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4d441506e9b372386a5271c64125f72d5df6d2a8e8a2a45a0ae09b03cb781ef7", size = 640565, upload-time = "2025-09-14T22:15:58.177Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9d/1b/4fdb2c12eb58f31f28c4d28e8dc36611dd7205df8452e63f52fb6261d13e/zstandard-0.25.0-cp310-cp310-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:ab85470ab54c2cb96e176f40342d9ed41e58ca5733be6a893b730e7af9c40550", size = 5345306, upload-time = "2025-09-14T22:16:00.165Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/73/28/a44bdece01bca027b079f0e00be3b6bd89a4df180071da59a3dd7381665b/zstandard-0.25.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:e05ab82ea7753354bb054b92e2f288afb750e6b439ff6ca78af52939ebbc476d", size = 5055561, upload-time = "2025-09-14T22:16:02.22Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/74/68341185a4f32b274e0fc3410d5ad0750497e1acc20bd0f5b5f64ce17785/zstandard-0.25.0-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:78228d8a6a1c177a96b94f7e2e8d012c55f9c760761980da16ae7546a15a8e9b", size = 5402214, upload-time = "2025-09-14T22:16:04.109Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8b/67/f92e64e748fd6aaffe01e2b75a083c0c4fd27abe1c8747fee4555fcee7dd/zstandard-0.25.0-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:2b6bd67528ee8b5c5f10255735abc21aa106931f0dbaf297c7be0c886353c3d0", size = 5449703, upload-time = "2025-09-14T22:16:06.312Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fd/e5/6d36f92a197c3c17729a2125e29c169f460538a7d939a27eaaa6dcfcba8e/zstandard-0.25.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4b6d83057e713ff235a12e73916b6d356e3084fd3d14ced499d84240f3eecee0", size = 5556583, upload-time = "2025-09-14T22:16:08.457Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d7/83/41939e60d8d7ebfe2b747be022d0806953799140a702b90ffe214d557638/zstandard-0.25.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:9174f4ed06f790a6869b41cba05b43eeb9a35f8993c4422ab853b705e8112bbd", size = 5045332, upload-time = "2025-09-14T22:16:10.444Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b3/87/d3ee185e3d1aa0133399893697ae91f221fda79deb61adbe998a7235c43f/zstandard-0.25.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:25f8f3cd45087d089aef5ba3848cd9efe3ad41163d3400862fb42f81a3a46701", size = 5572283, upload-time = "2025-09-14T22:16:12.128Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0a/1d/58635ae6104df96671076ac7d4ae7816838ce7debd94aecf83e30b7121b0/zstandard-0.25.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3756b3e9da9b83da1796f8809dd57cb024f838b9eeafde28f3cb472012797ac1", size = 4959754, upload-time = "2025-09-14T22:16:14.225Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/75/d6/57e9cb0a9983e9a229dd8fd2e6e96593ef2aa82a3907188436f22b111ccd/zstandard-0.25.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:81dad8d145d8fd981b2962b686b2241d3a1ea07733e76a2f15435dfb7fb60150", size = 5266477, upload-time = "2025-09-14T22:16:16.343Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d1/a9/ee891e5edf33a6ebce0a028726f0bbd8567effe20fe3d5808c42323e8542/zstandard-0.25.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:a5a419712cf88862a45a23def0ae063686db3d324cec7edbe40509d1a79a0aab", size = 5440914, upload-time = "2025-09-14T22:16:18.453Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/58/08/a8522c28c08031a9521f27abc6f78dbdee7312a7463dd2cfc658b813323b/zstandard-0.25.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:e7360eae90809efd19b886e59a09dad07da4ca9ba096752e61a2e03c8aca188e", size = 5819847, upload-time = "2025-09-14T22:16:20.559Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6f/11/4c91411805c3f7b6f31c60e78ce347ca48f6f16d552fc659af6ec3b73202/zstandard-0.25.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:75ffc32a569fb049499e63ce68c743155477610532da1eb38e7f24bf7cd29e74", size = 5363131, upload-time = "2025-09-14T22:16:22.206Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ef/d6/8c4bd38a3b24c4c7676a7a3d8de85d6ee7a983602a734b9f9cdefb04a5d6/zstandard-0.25.0-cp310-cp310-win32.whl", hash = "sha256:106281ae350e494f4ac8a80470e66d1fe27e497052c8d9c3b95dc4cf1ade81aa", size = 436469, upload-time = "2025-09-14T22:16:25.002Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/93/90/96d50ad417a8ace5f841b3228e93d1bb13e6ad356737f42e2dde30d8bd68/zstandard-0.25.0-cp310-cp310-win_amd64.whl", hash = "sha256:ea9d54cc3d8064260114a0bbf3479fc4a98b21dffc89b3459edd506b69262f6e", size = 506100, upload-time = "2025-09-14T22:16:23.569Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2a/83/c3ca27c363d104980f1c9cee1101cc8ba724ac8c28a033ede6aab89585b1/zstandard-0.25.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:933b65d7680ea337180733cf9e87293cc5500cc0eb3fc8769f4d3c88d724ec5c", size = 795254, upload-time = "2025-09-14T22:16:26.137Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ac/4d/e66465c5411a7cf4866aeadc7d108081d8ceba9bc7abe6b14aa21c671ec3/zstandard-0.25.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a3f79487c687b1fc69f19e487cd949bf3aae653d181dfb5fde3bf6d18894706f", size = 640559, upload-time = "2025-09-14T22:16:27.973Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/12/56/354fe655905f290d3b147b33fe946b0f27e791e4b50a5f004c802cb3eb7b/zstandard-0.25.0-cp311-cp311-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:0bbc9a0c65ce0eea3c34a691e3c4b6889f5f3909ba4822ab385fab9057099431", size = 5348020, upload-time = "2025-09-14T22:16:29.523Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3b/13/2b7ed68bd85e69a2069bcc72141d378f22cae5a0f3b353a2c8f50ef30c1b/zstandard-0.25.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:01582723b3ccd6939ab7b3a78622c573799d5d8737b534b86d0e06ac18dbde4a", size = 5058126, upload-time = "2025-09-14T22:16:31.811Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/c9/dd/fdaf0674f4b10d92cb120ccff58bbb6626bf8368f00ebfd2a41ba4a0dc99/zstandard-0.25.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:5f1ad7bf88535edcf30038f6919abe087f606f62c00a87d7e33e7fc57cb69fcc", size = 5405390, upload-time = "2025-09-14T22:16:33.486Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/0f/67/354d1555575bc2490435f90d67ca4dd65238ff2f119f30f72d5cde09c2ad/zstandard-0.25.0-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:06acb75eebeedb77b69048031282737717a63e71e4ae3f77cc0c3b9508320df6", size = 5452914, upload-time = "2025-09-14T22:16:35.277Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/bb/1f/e9cfd801a3f9190bf3e759c422bbfd2247db9d7f3d54a56ecde70137791a/zstandard-0.25.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9300d02ea7c6506f00e627e287e0492a5eb0371ec1670ae852fefffa6164b072", size = 5559635, upload-time = "2025-09-14T22:16:37.141Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/21/88/5ba550f797ca953a52d708c8e4f380959e7e3280af029e38fbf47b55916e/zstandard-0.25.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bfd06b1c5584b657a2892a6014c2f4c20e0db0208c159148fa78c65f7e0b0277", size = 5048277, upload-time = "2025-09-14T22:16:38.807Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/46/c0/ca3e533b4fa03112facbe7fbe7779cb1ebec215688e5df576fe5429172e0/zstandard-0.25.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f373da2c1757bb7f1acaf09369cdc1d51d84131e50d5fa9863982fd626466313", size = 5574377, upload-time = "2025-09-14T22:16:40.523Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/12/9b/3fb626390113f272abd0799fd677ea33d5fc3ec185e62e6be534493c4b60/zstandard-0.25.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:6c0e5a65158a7946e7a7affa6418878ef97ab66636f13353b8502d7ea03c8097", size = 4961493, upload-time = "2025-09-14T22:16:43.3Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/cb/d3/23094a6b6a4b1343b27ae68249daa17ae0651fcfec9ed4de09d14b940285/zstandard-0.25.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:c8e167d5adf59476fa3e37bee730890e389410c354771a62e3c076c86f9f7778", size = 5269018, upload-time = "2025-09-14T22:16:45.292Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8c/a7/bb5a0c1c0f3f4b5e9d5b55198e39de91e04ba7c205cc46fcb0f95f0383c1/zstandard-0.25.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:98750a309eb2f020da61e727de7d7ba3c57c97cf6213f6f6277bb7fb42a8e065", size = 5443672, upload-time = "2025-09-14T22:16:47.076Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/27/22/503347aa08d073993f25109c36c8d9f029c7d5949198050962cb568dfa5e/zstandard-0.25.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:22a086cff1b6ceca18a8dd6096ec631e430e93a8e70a9ca5efa7561a00f826fa", size = 5822753, upload-time = "2025-09-14T22:16:49.316Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e2/be/94267dc6ee64f0f8ba2b2ae7c7a2df934a816baaa7291db9e1aa77394c3c/zstandard-0.25.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:72d35d7aa0bba323965da807a462b0966c91608ef3a48ba761678cb20ce5d8b7", size = 5366047, upload-time = "2025-09-14T22:16:51.328Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7b/a3/732893eab0a3a7aecff8b99052fecf9f605cf0fb5fb6d0290e36beee47a4/zstandard-0.25.0-cp311-cp311-win32.whl", hash = "sha256:f5aeea11ded7320a84dcdd62a3d95b5186834224a9e55b92ccae35d21a8b63d4", size = 436484, upload-time = "2025-09-14T22:16:55.005Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/43/a3/c6155f5c1cce691cb80dfd38627046e50af3ee9ddc5d0b45b9b063bfb8c9/zstandard-0.25.0-cp311-cp311-win_amd64.whl", hash = "sha256:daab68faadb847063d0c56f361a289c4f268706b598afbf9ad113cbe5c38b6b2", size = 506183, upload-time = "2025-09-14T22:16:52.753Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8c/3e/8945ab86a0820cc0e0cdbf38086a92868a9172020fdab8a03ac19662b0e5/zstandard-0.25.0-cp311-cp311-win_arm64.whl", hash = "sha256:22a06c5df3751bb7dc67406f5374734ccee8ed37fc5981bf1ad7041831fa1137", size = 462533, upload-time = "2025-09-14T22:16:53.878Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/82/fc/f26eb6ef91ae723a03e16eddb198abcfce2bc5a42e224d44cc8b6765e57e/zstandard-0.25.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7b3c3a3ab9daa3eed242d6ecceead93aebbb8f5f84318d82cee643e019c4b73b", size = 795738, upload-time = "2025-09-14T22:16:56.237Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/aa/1c/d920d64b22f8dd028a8b90e2d756e431a5d86194caa78e3819c7bf53b4b3/zstandard-0.25.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:913cbd31a400febff93b564a23e17c3ed2d56c064006f54efec210d586171c00", size = 640436, upload-time = "2025-09-14T22:16:57.774Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/53/6c/288c3f0bd9fcfe9ca41e2c2fbfd17b2097f6af57b62a81161941f09afa76/zstandard-0.25.0-cp312-cp312-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:011d388c76b11a0c165374ce660ce2c8efa8e5d87f34996aa80f9c0816698b64", size = 5343019, upload-time = "2025-09-14T22:16:59.302Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1e/15/efef5a2f204a64bdb5571e6161d49f7ef0fffdbca953a615efbec045f60f/zstandard-0.25.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6dffecc361d079bb48d7caef5d673c88c8988d3d33fb74ab95b7ee6da42652ea", size = 5063012, upload-time = "2025-09-14T22:17:01.156Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b7/37/a6ce629ffdb43959e92e87ebdaeebb5ac81c944b6a75c9c47e300f85abdf/zstandard-0.25.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:7149623bba7fdf7e7f24312953bcf73cae103db8cae49f8154dd1eadc8a29ecb", size = 5394148, upload-time = "2025-09-14T22:17:03.091Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e3/79/2bf870b3abeb5c070fe2d670a5a8d1057a8270f125ef7676d29ea900f496/zstandard-0.25.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:6a573a35693e03cf1d67799fd01b50ff578515a8aeadd4595d2a7fa9f3ec002a", size = 5451652, upload-time = "2025-09-14T22:17:04.979Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/53/60/7be26e610767316c028a2cbedb9a3beabdbe33e2182c373f71a1c0b88f36/zstandard-0.25.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5a56ba0db2d244117ed744dfa8f6f5b366e14148e00de44723413b2f3938a902", size = 5546993, upload-time = "2025-09-14T22:17:06.781Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/85/c7/3483ad9ff0662623f3648479b0380d2de5510abf00990468c286c6b04017/zstandard-0.25.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:10ef2a79ab8e2974e2075fb984e5b9806c64134810fac21576f0668e7ea19f8f", size = 5046806, upload-time = "2025-09-14T22:17:08.415Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/08/b3/206883dd25b8d1591a1caa44b54c2aad84badccf2f1de9e2d60a446f9a25/zstandard-0.25.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:aaf21ba8fb76d102b696781bddaa0954b782536446083ae3fdaa6f16b25a1c4b", size = 5576659, upload-time = "2025-09-14T22:17:10.164Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9d/31/76c0779101453e6c117b0ff22565865c54f48f8bd807df2b00c2c404b8e0/zstandard-0.25.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1869da9571d5e94a85a5e8d57e4e8807b175c9e4a6294e3b66fa4efb074d90f6", size = 4953933, upload-time = "2025-09-14T22:17:11.857Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/18/e1/97680c664a1bf9a247a280a053d98e251424af51f1b196c6d52f117c9720/zstandard-0.25.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:809c5bcb2c67cd0ed81e9229d227d4ca28f82d0f778fc5fea624a9def3963f91", size = 5268008, upload-time = "2025-09-14T22:17:13.627Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1e/73/316e4010de585ac798e154e88fd81bb16afc5c5cb1a72eeb16dd37e8024a/zstandard-0.25.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:f27662e4f7dbf9f9c12391cb37b4c4c3cb90ffbd3b1fb9284dadbbb8935fa708", size = 5433517, upload-time = "2025-09-14T22:17:16.103Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5b/60/dd0f8cfa8129c5a0ce3ea6b7f70be5b33d2618013a161e1ff26c2b39787c/zstandard-0.25.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:99c0c846e6e61718715a3c9437ccc625de26593fea60189567f0118dc9db7512", size = 5814292, upload-time = "2025-09-14T22:17:17.827Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fc/5f/75aafd4b9d11b5407b641b8e41a57864097663699f23e9ad4dbb91dc6bfe/zstandard-0.25.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:474d2596a2dbc241a556e965fb76002c1ce655445e4e3bf38e5477d413165ffa", size = 5360237, upload-time = "2025-09-14T22:17:19.954Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ff/8d/0309daffea4fcac7981021dbf21cdb2e3427a9e76bafbcdbdf5392ff99a4/zstandard-0.25.0-cp312-cp312-win32.whl", hash = "sha256:23ebc8f17a03133b4426bcc04aabd68f8236eb78c3760f12783385171b0fd8bd", size = 436922, upload-time = "2025-09-14T22:17:24.398Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/79/3b/fa54d9015f945330510cb5d0b0501e8253c127cca7ebe8ba46a965df18c5/zstandard-0.25.0-cp312-cp312-win_amd64.whl", hash = "sha256:ffef5a74088f1e09947aecf91011136665152e0b4b359c42be3373897fb39b01", size = 506276, upload-time = "2025-09-14T22:17:21.429Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ea/6b/8b51697e5319b1f9ac71087b0af9a40d8a6288ff8025c36486e0c12abcc4/zstandard-0.25.0-cp312-cp312-win_arm64.whl", hash = "sha256:181eb40e0b6a29b3cd2849f825e0fa34397f649170673d385f3598ae17cca2e9", size = 462679, upload-time = "2025-09-14T22:17:23.147Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/35/0b/8df9c4ad06af91d39e94fa96cc010a24ac4ef1378d3efab9223cc8593d40/zstandard-0.25.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ec996f12524f88e151c339688c3897194821d7f03081ab35d31d1e12ec975e94", size = 795735, upload-time = "2025-09-14T22:17:26.042Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3f/06/9ae96a3e5dcfd119377ba33d4c42a7d89da1efabd5cb3e366b156c45ff4d/zstandard-0.25.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a1a4ae2dec3993a32247995bdfe367fc3266da832d82f8438c8570f989753de1", size = 640440, upload-time = "2025-09-14T22:17:27.366Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d9/14/933d27204c2bd404229c69f445862454dcc101cd69ef8c6068f15aaec12c/zstandard-0.25.0-cp313-cp313-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:e96594a5537722fdfb79951672a2a63aec5ebfb823e7560586f7484819f2a08f", size = 5343070, upload-time = "2025-09-14T22:17:28.896Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/6d/db/ddb11011826ed7db9d0e485d13df79b58586bfdec56e5c84a928a9a78c1c/zstandard-0.25.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:bfc4e20784722098822e3eee42b8e576b379ed72cca4a7cb856ae733e62192ea", size = 5063001, upload-time = "2025-09-14T22:17:31.044Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/db/00/87466ea3f99599d02a5238498b87bf84a6348290c19571051839ca943777/zstandard-0.25.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:457ed498fc58cdc12fc48f7950e02740d4f7ae9493dd4ab2168a47c93c31298e", size = 5394120, upload-time = "2025-09-14T22:17:32.711Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2b/95/fc5531d9c618a679a20ff6c29e2b3ef1d1f4ad66c5e161ae6ff847d102a9/zstandard-0.25.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:fd7a5004eb1980d3cefe26b2685bcb0b17989901a70a1040d1ac86f1d898c551", size = 5451230, upload-time = "2025-09-14T22:17:34.41Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/63/4b/e3678b4e776db00f9f7b2fe58e547e8928ef32727d7a1ff01dea010f3f13/zstandard-0.25.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8e735494da3db08694d26480f1493ad2cf86e99bdd53e8e9771b2752a5c0246a", size = 5547173, upload-time = "2025-09-14T22:17:36.084Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/4e/d5/ba05ed95c6b8ec30bd468dfeab20589f2cf709b5c940483e31d991f2ca58/zstandard-0.25.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3a39c94ad7866160a4a46d772e43311a743c316942037671beb264e395bdd611", size = 5046736, upload-time = "2025-09-14T22:17:37.891Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/50/d5/870aa06b3a76c73eced65c044b92286a3c4e00554005ff51962deef28e28/zstandard-0.25.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:172de1f06947577d3a3005416977cce6168f2261284c02080e7ad0185faeced3", size = 5576368, upload-time = "2025-09-14T22:17:40.206Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/5d/35/398dc2ffc89d304d59bc12f0fdd931b4ce455bddf7038a0a67733a25f550/zstandard-0.25.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:3c83b0188c852a47cd13ef3bf9209fb0a77fa5374958b8c53aaa699398c6bd7b", size = 4954022, upload-time = "2025-09-14T22:17:41.879Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9a/5c/36ba1e5507d56d2213202ec2b05e8541734af5f2ce378c5d1ceaf4d88dc4/zstandard-0.25.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:1673b7199bbe763365b81a4f3252b8e80f44c9e323fc42940dc8843bfeaf9851", size = 5267889, upload-time = "2025-09-14T22:17:43.577Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/70/e8/2ec6b6fb7358b2ec0113ae202647ca7c0e9d15b61c005ae5225ad0995df5/zstandard-0.25.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:0be7622c37c183406f3dbf0cba104118eb16a4ea7359eeb5752f0794882fc250", size = 5433952, upload-time = "2025-09-14T22:17:45.271Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7b/01/b5f4d4dbc59ef193e870495c6f1275f5b2928e01ff5a81fecb22a06e22fb/zstandard-0.25.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:5f5e4c2a23ca271c218ac025bd7d635597048b366d6f31f420aaeb715239fc98", size = 5814054, upload-time = "2025-09-14T22:17:47.08Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b2/e5/fbd822d5c6f427cf158316d012c5a12f233473c2f9c5fe5ab1ae5d21f3d8/zstandard-0.25.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4f187a0bb61b35119d1926aee039524d1f93aaf38a9916b8c4b78ac8514a0aaf", size = 5360113, upload-time = "2025-09-14T22:17:48.893Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/8e/e0/69a553d2047f9a2c7347caa225bb3a63b6d7704ad74610cb7823baa08ed7/zstandard-0.25.0-cp313-cp313-win32.whl", hash = "sha256:7030defa83eef3e51ff26f0b7bfb229f0204b66fe18e04359ce3474ac33cbc09", size = 436936, upload-time = "2025-09-14T22:17:52.658Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d9/82/b9c06c870f3bd8767c201f1edbdf9e8dc34be5b0fbc5682c4f80fe948475/zstandard-0.25.0-cp313-cp313-win_amd64.whl", hash = "sha256:1f830a0dac88719af0ae43b8b2d6aef487d437036468ef3c2ea59c51f9d55fd5", size = 506232, upload-time = "2025-09-14T22:17:50.402Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/d4/57/60c3c01243bb81d381c9916e2a6d9e149ab8627c0c7d7abb2d73384b3c0c/zstandard-0.25.0-cp313-cp313-win_arm64.whl", hash = "sha256:85304a43f4d513f5464ceb938aa02c1e78c2943b29f44a750b48b25ac999a049", size = 462671, upload-time = "2025-09-14T22:17:51.533Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd"
|
||||
version = "1.5.7.2"
|
||||
|
||||