Skip to content

Commit d176cad

Browse files
authored
Merge branch 'release/current' into main
2 parents 9054c72 + 2be02eb commit d176cad

72 files changed

Lines changed: 1010 additions & 526 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 156 additions & 177 deletions
Large diffs are not rendered by default.

.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

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,59 @@ The following repository is used to store the OpenAEV injectors for the platform
1010

1111
This repository is used to host injectors that are supported by the core development team of OpenAEV. Nevertheless, the community is also developing a lot of injectors, third-parties modules directly linked to OpenAEV. You can find the list of all available injectors and plugins in the [OpenAEV ecosystem dedicated space](https://filigran.notion.site/OpenAEV-Ecosystem-30d8eb73d7d04611843e758ddef8941b).
1212

13+
### Creating a new injector
14+
15+
#### Project setup
16+
Assuming a new collector by the name of `new_injector`, create a skeleton directory with:
17+
```shell
18+
poetry new new_injector
19+
```
20+
21+
#### `pyoaev` dependency
22+
We wish to retain the possibility to develop simultaneously on `pyoaev` and collectors. We rely on PEP 508 environment
23+
markers to alternatively install a local path `pyoaev` dependency or a released version from PyPI; specifically the `extra`
24+
marker.
25+
26+
Navigate to the new directory and edit `pyproject.toml`.
27+
```shell
28+
vim new_injector/pyproject.toml
29+
```
30+
(or open the file in your favourite editor).
31+
32+
Here's the expression for the pyoaev dependency, including the `extra` definition:
33+
```toml
34+
[tool.poetry.dependencies]
35+
pyoaev = [
36+
{ markers = "extra == 'prod' and extra != 'dev'", version = "<latest pyoaev release on PyPI>", source = "pypi" },
37+
{ markers = "extra == 'dev' and extra != 'prod'", path = "../../client-python", develop = true },
38+
]
39+
40+
[tool.poetry.extras]
41+
prod = ["pyoaev"]
42+
dev = ["pyoaev"]
43+
```
44+
45+
### Simultaneous development on pyoaev and an injector
46+
The injectors repository is set to assume that in the event of a simultaneous development work on both `pyoaev`
47+
and injectors, the `pyoaev` repository is cloned in a directory at the same level as the injectors root directory,
48+
and is named strictly `client-python`.
49+
50+
Here's an example layout:
51+
```
52+
.
53+
├── client-python <= mandatory dir name
54+
│ ├── docs
55+
│ ├── pyoaev
56+
│ ├── scripts
57+
│ └── test
58+
└── injectors <= this repo root dir
59+
├── aws
60+
├── http-query
61+
├── nmap
62+
└── nuclei
63+
```
64+
65+
1366
## Contributing
1467

1568
If you want to help use improve or develop new injector, please check out the **[development documentation for new injectors](https://docs.openaev.io/latest/development/injectors)**. If you want to make your injectors available to the community, **please create a Pull Request on this repository**, then we will integrate it to the CI and in the [OpenAEV ecosystem](https://filigran.notion.site/OpenAEV-Ecosystem-30d8eb73d7d04611843e758ddef8941b).

aws/Dockerfile

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
1-
FROM python:3.11-slim
1+
FROM python:3.13-alpine AS builder
22

3-
# Install system dependencies
4-
RUN apt-get update && apt-get install -y \
5-
git \
6-
gcc \
7-
python3-dev \
8-
libssl-dev \
9-
libffi-dev \
10-
&& rm -rf /var/lib/apt/lists/*
3+
RUN apk update && apk upgrade
114

12-
# Create working directory
13-
WORKDIR /opt/openaev-injector-aws
5+
WORKDIR /opt/injector_common
6+
COPY --from=injector_common ./ ./
147

15-
# Copy the injector source code
16-
COPY src /opt/openaev-injector-aws
8+
# poetry version available on Ubuntu 24.04
9+
RUN pip3 install poetry==2.1.3
1710

18-
# Install Python dependencies
19-
RUN pip3 install --no-cache-dir -r requirements.txt
11+
ARG installdir=/opt/injector
12+
ADD . ${installdir}
13+
WORKDIR ${installdir}
14+
RUN poetry build
15+
16+
FROM python:3.13-alpine AS runner
17+
18+
WORKDIR /opt/injector_common
19+
COPY --from=injector_common ./ ./
20+
21+
ARG installdir=/opt/injector
22+
WORKDIR ${installdir}
23+
COPY --from=builder ${installdir} ${installdir}
24+
RUN pip3 install --no-cache-dir "$(ls dist/*.whl)[prod]"
25+
26+
# Declare the build argument
27+
ARG PYOAEV_GIT_BRANCH_OVERRIDE
28+
29+
RUN if [[ ${PYOAEV_GIT_BRANCH_OVERRIDE} ]] ; then \
30+
echo "Forcing specific version of client-python" && \
31+
apk add --no-cache git && \
32+
pip install pip3-autoremove && \
33+
pip-autoremove pyoaev -y && \
34+
pip install git+https://github.com/OpenAEV-Platform/client-python@${PYOAEV_GIT_BRANCH_OVERRIDE} ; \
35+
fi
2036

2137
# Verify AWS CLI is installed
2238
RUN aws --version || echo "AWS CLI installation verification"
2339

24-
# Create AWS data directory
25-
RUN mkdir -p /root/.local/share/aws
26-
2740
# Set environment variables for AWS
2841
ENV AWS_HOME=/root/.local/share/aws
42+
# Create AWS data directory
43+
RUN mkdir -p ${AWS_HOME}
2944

30-
# Copy and set up entrypoint script
31-
COPY entrypoint.sh /
32-
RUN chmod +x /entrypoint.sh
3345

34-
# Set the entrypoint
35-
ENTRYPOINT ["/entrypoint.sh"]
46+
CMD ["python3", "-m", "aws.openaev_aws"]

aws/README.md

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,39 @@ The injector supports all current AWS regions including:
8585

8686
**Other Regions**: Middle East (Bahrain, UAE, Tel Aviv), Africa (Cape Town), South America (São Paulo), China (Beijing, Ningxia), AWS GovCloud (US-East, US-West)
8787

88-
## Installation
88+
## Configuration variables
89+
90+
There are a number of configuration options, which are set either in `docker-compose.yml` (for Docker) or
91+
in `config.yml` (for manual deployment).
92+
93+
### OpenAEV environment variables
94+
95+
Below are the parameters you'll need to set for OpenAEV:
96+
97+
| Parameter | config.yml | Docker environment variable | Mandatory | Description |
98+
|---------------|------------|-----------------------------|-----------|------------------------------------------------------|
99+
| OpenAEV URL | url | `OPENAEV_URL` | Yes | The URL of the OpenAEV platform. |
100+
| OpenAEV Token | token | `OPENAEV_TOKEN` | Yes | The default admin token set in the OpenAEV platform. |
101+
102+
### Base injector environment variables
103+
104+
Below are the parameters you'll need to set for running the injector properly:
105+
106+
| Parameter | config.yml | Docker environment variable | Default | Mandatory | Description |
107+
|------------------|------------|-----------------------------|---------|-----------|----------------------------------------------------------------------------------------|
108+
| Injector ID | id | `INJECTOR_ID` | / | Yes | A unique `UUIDv4` identifier for this injector instance. |
109+
| Collector Name | name | `INJECTOR_NAME` | | Yes | Name of the injector. |
110+
| Log Level | log_level | `INJECTOR_LOG_LEVEL` | info | Yes | Determines the verbosity of the logs. Options are `debug`, `info`, `warn`, or `error`. |
111+
112+
113+
## Deployment
89114

90115
### Using Docker
91116

92117
1. Build the Docker image:
93118
```bash
94119
cd aws
95-
docker build -t openaev/injector-aws:latest .
120+
docker build --build-context injector_common=../injector_common -t openaev/injector-aws:latest .
96121
```
97122

98123
2. Run with docker-compose:
@@ -102,54 +127,35 @@ docker-compose up -d
102127

103128
### Manual Installation
104129

105-
1. Install Python dependencies:
106-
```bash
107-
cd aws/src
108-
pip install -r requirements.txt
109-
```
110-
111-
2. Install AWS:
112-
```bash
113-
pip install aws
114-
```
115-
116-
3. Configure the injector:
117-
```bash
118-
cp config.yml.sample config.yml
119-
# Edit config.yml with your OpenAEV connection details
120-
```
121-
122-
4. Run the injector:
123-
```bash
124-
python openaev_aws.py
125-
```
130+
Create a file `config.yml` based on the provided `config.yml.sample`.
126131

127-
## Configuration
132+
Replace the configuration variables with the appropriate configurations for
133+
you environment.
128134

129-
### Environment Variables
135+
The poetry package management system (version 2.1 or later) must also be available: https://python-poetry.org/
130136

131-
- `OPENAEV_URL`: URL of your OpenAEV instance
132-
- `OPENAEV_TOKEN`: Authentication token for OpenAEV API
133-
- `INJECTOR_ID`: Unique identifier for this injector instance
134-
- `INJECTOR_NAME`: Display name for the injector (default: "AWS")
135-
- `INJECTOR_LOG_LEVEL`: Logging level (info, warning, error) - debug logging has been removed for production use
137+
Install the environment:
136138

137-
### Configuration File
139+
**Production**:
140+
```shell
141+
# production environment
142+
poetry install --extras prod
143+
```
138144

139-
Create a `config.yml` file based on the provided sample:
145+
**Development** (note that you should also clone the [pyoaev](OpenAEV-Platform/client-python) repository [according to
146+
these instructions](../README.md#simultaneous-development-on-pyoaev-and-an-injector))
147+
```shell
148+
# development environment
149+
poetry install --extras dev
150+
```
140151

141-
```yaml
142-
openaev:
143-
url: 'http://localhost:3001'
144-
token: 'your-openaev-token'
152+
Then, start the collector:
145153

146-
injector:
147-
id: 'unique-injector-id'
148-
name: 'AWS'
149-
log_level: 'info'
154+
```shell
155+
poetry run python -m aws.openaev_aws
150156
```
151157

152-
## Usage in OpenAEV
158+
## Behaviour
153159

154160
1. **Deploy the Injector**: Start the AWS injector using Docker or manual installation
155161
2. **Verify Registration**: Check that the injector appears in OpenAEV under Integrations > Injectors
@@ -221,7 +227,7 @@ To add support for additional AWS modules:
221227

222228
Run the injector with info logging to test new modules:
223229

224-
```python
230+
```yaml
225231
# In config.yml
226232
injector:
227233
log_level: 'info'
File renamed without 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": "openaev_aws"},
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
)

0 commit comments

Comments
 (0)