Skip to content

Commit b3e4d9e

Browse files
camrrxantoinemzs
andauthored
[injector] feat(backend): add dump config (#4386)
Signed-off-by: Antoine MAZEAS <antoine.mazeas@filigran.io> Co-authored-by: Antoine MAZEAS <antoine.mazeas@filigran.io>
1 parent 8332d01 commit b3e4d9e

32 files changed

+370
-2167
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,19 @@ jobs:
125125
name: Build Docker image openaev/injector-aws
126126
command: |
127127
if [ "${CIRCLE_BRANCH}" = "release/current" ]; then
128-
docker build --progress=plain -t openaev/injector-aws:${CIRCLE_SHA1} --build-arg PYOAEV_GIT_BRANCH_OVERRIDE="${CIRCLE_BRANCH}" .
128+
docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-aws:${CIRCLE_SHA1} --build-arg PYOAEV_GIT_BRANCH_OVERRIDE="${CIRCLE_BRANCH}" .
129129
else
130-
docker build --progress=plain -t openaev/injector-aws:${CIRCLE_SHA1} .
130+
docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-aws:${CIRCLE_SHA1} .
131131
fi
132132
docker save -o ~/openaev/images/injector-aws openaev/injector-aws:${CIRCLE_SHA1}
133133
- run:
134134
working_directory: ~/openaev/http-query
135135
name: Build Docker image openaev/injector-http-query
136136
command: |
137137
if [ "${CIRCLE_BRANCH}" = "release/current" ]; then
138-
docker build --progress=plain -t openaev/injector-http-query:${CIRCLE_SHA1} --build-arg PYOAEV_GIT_BRANCH_OVERRIDE="${CIRCLE_BRANCH}" .
138+
docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-http-query:${CIRCLE_SHA1} --build-arg PYOAEV_GIT_BRANCH_OVERRIDE="${CIRCLE_BRANCH}" .
139139
else
140-
docker build --progress=plain -t openaev/injector-http-query:${CIRCLE_SHA1} .
140+
docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-http-query:${CIRCLE_SHA1} .
141141
fi
142142
docker save -o ~/openaev/images/injector-http-query openaev/injector-http-query:${CIRCLE_SHA1}
143143
- run:

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,8 @@ dmypy.json
133133

134134
# Cython debug symbols
135135
cython_debug/
136+
137+
# custom
138+
# ignoring the poetry.lock files for now
139+
# as we don't have a good release scheme for keeping them up to date at the moment
140+
poetry.lock

aws/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ FROM python:3.13-alpine AS builder
22

33
RUN apk update && apk upgrade
44

5+
WORKDIR /opt/injector_common
6+
COPY --from=injector_common ./ ./
7+
58
# poetry version available on Ubuntu 24.04
69
RUN pip3 install poetry==2.1.3
710

@@ -12,6 +15,9 @@ RUN poetry build
1215

1316
FROM python:3.13-alpine AS runner
1417

18+
WORKDIR /opt/injector_common
19+
COPY --from=injector_common ./ ./
20+
1521
ARG installdir=/opt/injector
1622
WORKDIR ${installdir}
1723
COPY --from=builder ${installdir} ${installdir}

aws/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Below are the parameters you'll need to set for running the injector properly:
117117
1. Build the Docker image:
118118
```bash
119119
cd aws
120-
docker build -t openaev/injector-aws:latest .
120+
docker build --build-context injector_common=../injector_common -t openaev/injector-aws:latest .
121121
```
122122

123123
2. Run with docker-compose:

aws/aws/configuration/__init__.py

Whitespace-only changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from pydantic import Field
2+
from pyoaev.configuration import ConfigLoaderOAEV, Configuration, SettingsLoader
3+
4+
from aws.configuration.injector_config_override import InjectorConfigOverride
5+
from aws.contracts_aws import AWSContracts
6+
7+
8+
class ConfigLoader(SettingsLoader):
9+
openaev: ConfigLoaderOAEV = Field(default_factory=ConfigLoaderOAEV)
10+
injector: InjectorConfigOverride = Field(default_factory=InjectorConfigOverride)
11+
12+
def to_daemon_config(self) -> Configuration:
13+
return Configuration(
14+
config_hints={
15+
# OpenAEV configuration (flattened)
16+
"openaev_url": {"data": str(self.openaev.url)},
17+
"openaev_token": {"data": self.openaev.token},
18+
# Injector configuration (flattened)
19+
"injector_id": {"data": self.injector.id},
20+
"injector_name": {"data": self.injector.name},
21+
"injector_type": {"data": self.injector.type},
22+
"injector_contracts": {"data": AWSContracts.build_contract()},
23+
"injector_log_level": {"data": self.injector.log_level},
24+
"injector_icon_filepath": {"data": self.injector.icon_filepath},
25+
},
26+
config_base_model=self,
27+
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pydantic import Field
2+
from pyoaev.configuration import ConfigLoaderCollector
3+
4+
5+
# To be change ConfigLoaderCollector
6+
class InjectorConfigOverride(ConfigLoaderCollector):
7+
id: str = Field(
8+
description="A unique UUIDv4 identifier for this injector instance.",
9+
)
10+
name: str = Field(
11+
default="AWS",
12+
description="Name of the injector.",
13+
)
14+
icon_filepath: str | None = Field(
15+
default="aws/img/icon-aws.png",
16+
description="Path to the icon file",
17+
)
18+
type: str = Field(
19+
description="Type of the injector.",
20+
default="openaev_aws",
21+
)
22+
log_level: str = Field(
23+
description="Determines the verbosity of the logs. Options: debug, info, warn, or error.",
24+
default="error",
25+
)

aws/aws/openaev_aws.py

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from pyoaev.helpers import OpenAEVConfigHelper, OpenAEVInjectorHelper
66

7+
from aws.configuration.config_loader import ConfigLoader
78
from aws.contracts_aws import (
89
CLOUDTRAIL_ENUM_CONTRACT,
910
COGNITO_ENUM_CONTRACT,
@@ -32,42 +33,17 @@
3233
SNS_ENUM_CONTRACT,
3334
SSM_ENUM_PARAMETERS_CONTRACT,
3435
VPC_ENUM_CONTRACT,
35-
AWSContracts,
3636
)
3737
from aws.helpers.pacu_executor import PacuExecutor
38+
from injector_common.dump_config import intercept_dump_argument
3839

3940

4041
class OpenAEVAWS:
4142
def __init__(self):
42-
self.config = OpenAEVConfigHelper(
43-
__file__,
44-
{
45-
# API information
46-
"openaev_url": {"env": "OPENAEV_URL", "file_path": ["openaev", "url"]},
47-
"openaev_token": {
48-
"env": "OPENAEV_TOKEN",
49-
"file_path": ["openaev", "token"],
50-
},
51-
# Config information
52-
"injector_id": {"env": "INJECTOR_ID", "file_path": ["injector", "id"]},
53-
"injector_name": {
54-
"env": "INJECTOR_NAME",
55-
"file_path": ["injector", "name"],
56-
},
57-
"injector_type": {
58-
"env": "INJECTOR_TYPE",
59-
"file_path": ["injector", "type"],
60-
"default": "openaev_aws",
61-
},
62-
"injector_log_level": {
63-
"env": "INJECTOR_LOG_LEVEL",
64-
"file_path": ["injector", "log_level"],
65-
"default": "error",
66-
},
67-
"injector_contracts": {"data": AWSContracts.build_contract()},
68-
},
43+
self.config = OpenAEVConfigHelper.from_configuration_object(
44+
ConfigLoader().to_daemon_config()
6945
)
70-
46+
intercept_dump_argument(self.config.get_config_obj())
7147
self.helper = OpenAEVInjectorHelper(
7248
self.config, open("aws/img/icon-aws.png", "rb")
7349
)

aws/manifest-metadata.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"title": "Amazon Web Service",
3+
"slug": "aws_injector",
4+
"description": "This Injector use the credentials provided to enumerate through contract the AWS ressources like S3, IAM, Lambda, CloudTrail, Route53, etc. ",
5+
"short_description": "Use OpenAEV to perform AWS assessment through credentials sets",
6+
"use_cases": ["Injector", "Technical"],
7+
"verified": true,
8+
"last_verified_date": "",
9+
"playbook_supported": false,
10+
"max_confidence_level": 80,
11+
"support_version": "",
12+
"subscription_link": "https://aws.amazon.com/",
13+
"source_code": "",
14+
"manager_supported": true,
15+
"container_version": "rolling",
16+
"container_image": "openaev/injector-aws",
17+
"container_type": "INJECTOR"
18+
}

0 commit comments

Comments
 (0)