Skip to content

Commit b7eb623

Browse files
authored
[injector] feat(shodan): create new injector (#106)
1 parent 5fc1a95 commit b7eb623

Some content is hidden

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

50 files changed

+4114
-0
lines changed

shodan/.dockerignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Git
2+
.git
3+
.git*
4+
.gitignore
5+
6+
# Python cache
7+
__pycache__/
8+
*.py[cod]
9+
10+
# Virtual environments
11+
.venv/
12+
venv/
13+
env/
14+
15+
# Build / packaging
16+
build/
17+
dist/
18+
*.egg-info/
19+
20+
# Environment files
21+
.env
22+
config.yml
23+
24+
# Logs
25+
logs/
26+
27+
# Tests & coverage
28+
.pytest_cache/
29+
.coverage
30+
htmlcov/
31+
32+
# IDE
33+
.idea/
34+
.vscode/
35+
36+
# OS
37+
.DS_Store

shodan/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Python cache
2+
__pycache__/
3+
*.py[cod]
4+
5+
# Virtual environments
6+
.venv/
7+
venv/
8+
env/
9+
10+
# Build / packaging
11+
build/
12+
dist/
13+
*.egg-info/
14+
15+
# Environment files
16+
.env
17+
config.yml
18+
19+
# Logs
20+
logs/
21+
22+
# Tests & coverage
23+
.pytest_cache/
24+
.coverage
25+
htmlcov/
26+
27+
# IDE
28+
.idea/
29+
.vscode/
30+
31+
# OS
32+
.DS_Store

shodan/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WIP

shodan/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM python:3.13-alpine AS build
2+
3+
WORKDIR /opt/openaev-injector-shodan
4+
5+
# Copy dependency files (pyproject.toml / poetry.lock / README.md)
6+
COPY pyproject.toml poetry.lock* README.md ./
7+
8+
# Build dependencies
9+
RUN apk add --no-cache --virtual .build-dependencies \
10+
build-base git libffi-dev libxml2-dev libxslt-dev \
11+
&& pip3 install --no-cache-dir poetry==2.2.1 \
12+
&& poetry config virtualenvs.create false \
13+
&& poetry install --only main --extras prod --no-interaction --no-ansi --no-root \
14+
&& apk del .build-dependencies
15+
16+
# Copy the injector
17+
COPY shodan ./shodan
18+
19+
FROM python:3.13-alpine AS runner
20+
21+
WORKDIR /opt/openaev-injector-shodan
22+
23+
# Runtime libraries
24+
RUN apk add --no-cache libmagic libffi libxml2 libxslt
25+
26+
COPY --from=build /opt/openaev-injector-shodan/shodan ./shodan
27+
COPY --from=build /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
28+
29+
CMD ["python3", "-m", "shodan"]

shodan/README.md

Lines changed: 392 additions & 0 deletions
Large diffs are not rendered by default.

shodan/docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3.8'
2+
services:
3+
injector-shodan:
4+
image: openaev/injector-shodan:2.0.14
5+
environment:
6+
- OPENAEV_URL=http://localhost
7+
- OPENAEV_TOKEN=ChangeMe
8+
# - INJECTOR_ID=shodan--a87488ad-2c72-4592-b429-69259d7bcef1
9+
# - INJECTOR_NAME=Shodan
10+
# - INJECTOR_LOG_LEVEL=error
11+
- SHODAN_API_KEY=ChangeMe
12+
# - SHODAN_BASE_URL=https://api.shodan.io
13+
# - SHODAN_API_LEAKY_BUCKET_RATE=10
14+
# - SHODAN_API_LEAKY_BUCKET_CAPACITY=10
15+
# - SHODAN_API_RETRY=5
16+
# - SHODAN_API_BACKOFF=PT30S
17+
restart: always
18+
depends_on:
19+
openaev:
20+
condition: service_healthy

shodan/pyproject.toml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project.urls]
6+
Homepage = "https://filigran.io/"
7+
Repository = "https://github.com/OpenAEV-Platform/injectors/tree/main/shodan"
8+
Documentation = "https://github.com/OpenAEV-Platform/injectors/tree/main/shodan/README.md"
9+
Issues = "https://github.com/OpenAEV-Platform/injectors/issues"
10+
11+
[project]
12+
name = "openaev-shodan-injector"
13+
version = "2.0.14"
14+
description = "An injector for running with Shodan"
15+
readme = "README.md"
16+
authors = [{ name = "Filigran", email = "contact@filigran.io" }]
17+
license = "Apache-2.0"
18+
requires-python = ">=3.11, <3.14"
19+
classifiers = [
20+
"Development Status :: 5 - Production/Stable",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3.13",
25+
]
26+
dependencies = [
27+
"pydantic~=2.11.7",
28+
"pydantic-settings~=2.11.0",
29+
"requests~=2.32.5",
30+
"limiter==0.5.0",
31+
"tenacity~=9.1.2",
32+
"rich~=14.2.0",
33+
]
34+
35+
[project.optional-dependencies]
36+
prod = [
37+
"pyoaev ~=2.0.14"
38+
]
39+
current = [
40+
"pyoaev @ git+https://github.com/OpenAEV-Platform/client-python.git@release/current"
41+
]
42+
dev = [
43+
"black~=25.1", # Code formatter
44+
"isort~=7.0.0", # Import sorter
45+
"ruff~=0.14.2", # linter
46+
"mypy~=1.18.2", # Type validator
47+
"pip_audit~=2.9.0", # Security checker
48+
"pre-commit~=4.3.0", # Git hooks
49+
"types-PyYAML~=6.0.12", # stubs for untyped module
50+
]
51+
test = [
52+
"pytest~=8.4.1",
53+
"polyfactory~=2.22.2",
54+
]
55+
56+
[tool.poetry]
57+
packages = [{ include = "shodan" }]
58+
59+
[project.scripts]
60+
ShodanInjector = "shodan.__main__:main"
61+
62+
[tool.setuptools.packages.find]
63+
where = ["."]
64+
65+
[tool.isort]
66+
profile = "black"
67+
src_paths = ["shodan"]
68+
69+
[tool.pytest.ini_options]
70+
testpaths = ["./tests"]
71+
72+
[tool.ruff]
73+
exclude = [
74+
".bzr",
75+
".direnv",
76+
".eggs",
77+
".git",
78+
".git-rewrite",
79+
".hg",
80+
".ipynb_checkpoints",
81+
".mypy_cache",
82+
".nox",
83+
".pants.d",
84+
".pyenv",
85+
".pytest_cache",
86+
".pytype",
87+
".ruff_cache",
88+
".tox",
89+
".venv",
90+
".vscode",
91+
"__pypackages__",
92+
"_build",
93+
"buck-out",
94+
"build",
95+
"dist",
96+
"node_modules",
97+
"site-packages",
98+
"venv",
99+
]
100+
101+
target-version = "py312"
102+
103+
[tool.ruff.lint]
104+
# Never enforce `I001` (unsorted import). Already handle with isort
105+
# Never enforce `E501` (line length violations). Already handle with black
106+
# Never enforce `F821` (Undefined name `null`). incorrect issue with notebook
107+
# Never enforce `D213` (Multi-line docstring summary should start at the second line) conflict with our docstring convention
108+
# Never enforce `D211` (NoBlankLinesBeforeClass)`
109+
# Never enforce `G004` (logging-f-string) Logging statement uses f-string
110+
# Never enforce `TRY003`() Avoid specifying long messages outside the exception class not useful
111+
# Never enforce `D104` (Missing docstring in public package)
112+
# Never enforce `D407` (Missing dashed underline after section)
113+
# Never enforce `D408` (Section underline should be in the line following the section’s name)
114+
# Never enforce `D409` (Section underline should match the length of its name)
115+
ignore = [
116+
"I001",
117+
"D203",
118+
"E501",
119+
"F821",
120+
"D205",
121+
"D213",
122+
"D211",
123+
"G004",
124+
"TRY003",
125+
"D104",
126+
"D407",
127+
"D408",
128+
"D409",
129+
]
130+
select = ["E", "F", "W", "D", "G", "T", "B", "C", "N", "I", "S"]
131+
132+
[tool.mypy]
133+
strict = true
134+
exclude = [
135+
'^tests',
136+
'^docs',
137+
'^build',
138+
'^dist',
139+
'^venv',
140+
'^site-packages',
141+
'^__pypackages__',
142+
'^.venv',
143+
]
144+
plugins = ["pydantic.mypy"]

shodan/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Local dependency (client-python)
2+
-e ../../client-python
3+
4+
# Local project with extras (dev + test)
5+
-e .[dev,test]

shodan/shodan/.env.sample

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# OPENAEV Environment Variables
2+
# base URL to reach the OpenAEV server
3+
# note this URL must be routable from inside the container
4+
# so `localhost` will most likely not work
5+
OPENAEV_URL=ChangeMe
6+
# admin account API token from the OpenAEV server
7+
OPENAEV_TOKEN=ChangeMe
8+
9+
# INJECTOR Environment Variables
10+
#INJECTOR_ID=shodan--a87488ad-2c72-4592-b429-69259d7bcef1
11+
#INJECTOR_NAME=Shodan
12+
#INJECTOR_LOG_LEVEL=error
13+
14+
# SHODAN Environment Variables
15+
SHODAN_API_KEY=ChangeMe
16+
#SHODAN_BASE_URL=https://api.shodan.io
17+
#SHODAN_API_LEAKY_BUCKET_RATE=10
18+
#SHODAN_API_LEAKY_BUCKET_CAPACITY=10
19+
#SHODAN_API_RETRY=5
20+
#SHODAN_API_BACKOFF=PT30S

shodan/shodan/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from shodan.models import ConfigLoader
2+
3+
__all__ = ["ConfigLoader"]

0 commit comments

Comments
 (0)