-
Notifications
You must be signed in to change notification settings - Fork 3
[teams] feat(injector): add Microsoft Teams injector (#141) #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RomuDeuxfois
wants to merge
6
commits into
main
Choose a base branch
from
issue/141
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
75e46dd
[teams] feat(injector): add Microsoft Teams injector
RomuDeuxfois 8131aea
[teams] feat(injector): improv code
RomuDeuxfois 1c35131
[teams] feat(injector): improv code
RomuDeuxfois 91c6a79
[teams] feat(injector): improv code
RomuDeuxfois 49cc352
[ci] chore(circleci): improv script
RomuDeuxfois 13db9b3
[ci] chore(circleci): improv script
RomuDeuxfois File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| version: 2.1 | ||
|
|
||
| orbs: | ||
| slack: circleci/slack@5.2.3 | ||
| kubernetes: circleci/kubernetes@1.3.1 | ||
|
|
||
| jobs: | ||
| ensure_formatting: | ||
| docker: | ||
|
|
@@ -59,39 +61,26 @@ jobs: | |
| name: Install poetry | ||
| command: pip install poetry==2.1.3 && poetry config installer.re-resolve false | ||
| - run: | ||
| working_directory: ~/openaev/nuclei | ||
| name: Run tests for Nuclei injector | ||
| command: | | ||
| poetry install --extras prod | ||
| if [ "${CIRCLE_BRANCH}" = "main" ]; then | ||
| poetry run pip install --force-reinstall git+https://github.com/OpenAEV-Platform/client-python.git@main | ||
| else | ||
| poetry run pip install --force-reinstall git+https://github.com/OpenAEV-Platform/client-python.git@release/current | ||
| fi | ||
| poetry run python -m unittest | ||
| - run: | ||
| working_directory: ~/openaev/nmap | ||
| name: Run tests for nmap injector | ||
| command: | | ||
| poetry install --extras prod | ||
| if [ "${CIRCLE_BRANCH}" = "main" ]; then | ||
| poetry run pip install --force-reinstall git+https://github.com/OpenAEV-Platform/client-python.git@main | ||
| else | ||
| poetry run pip install --force-reinstall git+https://github.com/OpenAEV-Platform/client-python.git@release/current | ||
| fi | ||
| poetry run python -m unittest | ||
|
|
||
| - run: | ||
| working_directory: ~/openaev/http-query | ||
| name: Run tests for HTTP Query injector | ||
| name: Run injector tests | ||
| working_directory: ~/openaev | ||
| command: | | ||
| poetry install --extras prod | ||
| INJECTORS="nuclei nmap http-query" | ||
|
|
||
| if [ "${CIRCLE_BRANCH}" = "main" ]; then | ||
| poetry run pip install --force-reinstall git+https://github.com/OpenAEV-Platform/client-python.git@main | ||
| PYOAEV_REF="main" | ||
| else | ||
| poetry run pip install --force-reinstall git+https://github.com/OpenAEV-Platform/client-python.git@release/current | ||
| PYOAEV_REF="release/current" | ||
| fi | ||
| poetry run python -m unittest | ||
|
|
||
| for injector in $INJECTORS; do | ||
| echo "Running tests for injector: $injector" | ||
|
|
||
| cd ~/openaev/$injector | ||
|
|
||
| poetry install --extras prod | ||
| poetry run pip install --force-reinstall git+https://github.com/OpenAEV-Platform/client-python.git@${PYOAEV_REF} | ||
| poetry run python -m unittest | ||
| done | ||
| build_docker_images: | ||
| working_directory: ~/openaev | ||
| docker: | ||
|
|
@@ -121,52 +110,30 @@ jobs: | |
| find . -name pyproject.toml | xargs -I ___ sed "s|branch = 'release/current'|branch = '${CIRCLE_BRANCH}'|" -i ___; | ||
| fi; | ||
| - run: | ||
| working_directory: ~/openaev/aws | ||
| name: Build Docker image openaev/injector-aws | ||
| command: | | ||
| if [ "${CIRCLE_BRANCH}" = "release/current" ]; then | ||
| docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-aws:${CIRCLE_SHA1} --build-arg PYOAEV_GIT_BRANCH_OVERRIDE="${CIRCLE_BRANCH}" . | ||
| else | ||
| docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-aws:${CIRCLE_SHA1} . | ||
| fi | ||
| docker save -o ~/openaev/images/injector-aws openaev/injector-aws:${CIRCLE_SHA1} | ||
| - run: | ||
| working_directory: ~/openaev/http-query | ||
| name: Build Docker image openaev/injector-http-query | ||
| command: | | ||
| if [ "${CIRCLE_BRANCH}" = "release/current" ]; then | ||
| 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}" . | ||
| else | ||
| docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-http-query:${CIRCLE_SHA1} . | ||
| fi | ||
| docker save -o ~/openaev/images/injector-http-query openaev/injector-http-query:${CIRCLE_SHA1} | ||
| - run: | ||
| working_directory: ~/openaev/nmap | ||
| name: Build Docker image openaev/injector-nmap | ||
| command: | | ||
| if [ "${CIRCLE_BRANCH}" = "release/current" ]; then | ||
| docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-nmap:${CIRCLE_SHA1} --build-arg PYOAEV_GIT_BRANCH_OVERRIDE="${CIRCLE_BRANCH}" . | ||
| else | ||
| docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-nmap:${CIRCLE_SHA1} . | ||
| fi | ||
| docker save -o ~/openaev/images/injector-nmap openaev/injector-nmap:${CIRCLE_SHA1} | ||
| - run: | ||
| working_directory: ~/openaev/nuclei | ||
| name: Build Docker image openaev/injector-nuclei | ||
| name: Build injector Docker images | ||
| working_directory: ~/openaev | ||
| command: | | ||
| if [ "${CIRCLE_BRANCH}" = "release/current" ]; then | ||
| docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-nuclei:${CIRCLE_SHA1} --build-arg PYOAEV_GIT_BRANCH_OVERRIDE="${CIRCLE_BRANCH}" . | ||
| else | ||
| docker build --progress=plain --build-context injector_common=../injector_common -t openaev/injector-nuclei:${CIRCLE_SHA1} . | ||
| fi | ||
| docker save -o ~/openaev/images/injector-nuclei openaev/injector-nuclei:${CIRCLE_SHA1} | ||
| INJECTORS="aws http-query nmap nuclei teams" | ||
|
|
||
| for injector in $INJECTORS; do | ||
| echo "Building injector: $injector" | ||
|
|
||
| if [ "${CIRCLE_BRANCH}" = "release/current" ]; then | ||
| docker build --progress=plain --build-context injector_common=injector_common -t openaev/injector-$injector:${CIRCLE_SHA1} --build-arg PYOAEV_GIT_BRANCH_OVERRIDE="${CIRCLE_BRANCH}" ./$injector | ||
| else | ||
| docker build --progress=plain --build-context injector_common=injector_common -t openaev/injector-$injector:${CIRCLE_SHA1} ./$injector | ||
| fi | ||
|
|
||
| docker save -o ~/openaev/images/injector-$injector openaev/injector-$injector:${CIRCLE_SHA1} | ||
| done | ||
| - persist_to_workspace: | ||
| root: ~/openaev | ||
| paths: | ||
| - images | ||
| - slack/notify: | ||
| event: fail | ||
| template: basic_fail_1 | ||
|
|
||
| publish_images: | ||
| working_directory: ~/openaev | ||
| docker: | ||
|
|
@@ -201,67 +168,50 @@ jobs: | |
| exit 1 | ||
| fi | ||
| echo "Image tag: ${IMAGETAG}" | ||
|
|
||
| INJECTORS="aws http-query nmap nuclei teams" | ||
|
|
||
| docker image load < injector-aws | ||
| docker tag openaev/injector-aws:${CIRCLE_SHA1} openaev/injector-aws:${IMAGETAG} | ||
| docker tag openaev/injector-aws:${CIRCLE_SHA1} openbas/injector-aws:${IMAGETAG} | ||
| docker image load < injector-http-query | ||
| docker tag openaev/injector-http-query:${CIRCLE_SHA1} openaev/injector-http-query:${IMAGETAG} | ||
| docker tag openaev/injector-http-query:${CIRCLE_SHA1} openbas/injector-http-query:${IMAGETAG} | ||
| docker image load < injector-nmap | ||
| docker tag openaev/injector-nmap:${CIRCLE_SHA1} openaev/injector-nmap:${IMAGETAG} | ||
| docker tag openaev/injector-nmap:${CIRCLE_SHA1} openbas/injector-nmap:${IMAGETAG} | ||
| docker image load < injector-nuclei | ||
| docker tag openaev/injector-nuclei:${CIRCLE_SHA1} openaev/injector-nuclei:${IMAGETAG} | ||
| docker tag openaev/injector-nuclei:${CIRCLE_SHA1} openbas/injector-nuclei:${IMAGETAG} | ||
| for injector in $INJECTORS; do | ||
| docker image load < injector-$injector | ||
| docker tag openaev/injector-$injector:${CIRCLE_SHA1} openaev/injector-$injector:${IMAGETAG} | ||
| docker tag openaev/injector-$injector:${CIRCLE_SHA1} openbas/injector-$injector:${IMAGETAG} | ||
| done | ||
|
|
||
| echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin | ||
| # docker push openaev/injector-aws:${IMAGETAG} | ||
| docker push openbas/injector-aws:${IMAGETAG} | ||
| # docker push openaev/injector-http-query:${IMAGETAG} | ||
| docker push openbas/injector-http-query:${IMAGETAG} | ||
| # docker push openaev/injector-nmap:${IMAGETAG} | ||
| docker push openbas/injector-nmap:${IMAGETAG} | ||
| # docker push openaev/injector-nuclei:${IMAGETAG} | ||
| docker push openbas/injector-nuclei:${IMAGETAG} | ||
| for injector in $INJECTORS; do | ||
| # docker push openaev/injector-$injector:${IMAGETAG} | ||
| docker push openbas/injector-$injector:${IMAGETAG} | ||
| done | ||
|
|
||
| if [ "${IS_LATEST}" == "true" ] | ||
| then | ||
| docker tag openaev/injector-aws:${IMAGETAG} openaev/injector-aws:latest | ||
| docker tag openaev/injector-aws:${IMAGETAG} openbas/injector-aws:latest | ||
| docker tag openaev/injector-http-query:${IMAGETAG} openaev/injector-http-query:latest | ||
| docker tag openaev/injector-http-query:${IMAGETAG} openbas/injector-http-query:latest | ||
| docker tag openaev/injector-nmap:${IMAGETAG} openaev/injector-nmap:latest | ||
| docker tag openaev/injector-nmap:${IMAGETAG} openbas/injector-nmap:latest | ||
| docker tag openaev/injector-nuclei:${IMAGETAG} openaev/injector-nuclei:latest | ||
| docker tag openaev/injector-nuclei:${IMAGETAG} openbas/injector-nuclei:latest | ||
|
|
||
| docker push openaev/injector-aws:latest | ||
| docker push openbas/injector-aws:latest | ||
| docker push openaev/injector-http-query:latest | ||
| docker push openbas/injector-http-query:latest | ||
| docker push openaev/injector-nmap:latest | ||
| docker push openbas/injector-nmap:latest | ||
| docker push openaev/injector-nuclei:latest | ||
| docker push openbas/injector-nuclei:latest | ||
| for injector in $INJECTORS; do | ||
| docker tag openaev/injector-$injector:${IMAGETAG} openaev/injector-$injector:latest | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Do we still need to maintain the openbas reference? @antoinemzs |
||
| docker tag openaev/injector-$injector:${IMAGETAG} openbas/injector-$injector:latest | ||
| docker push openaev/injector-$injector:latest | ||
| docker push openbas/injector-$injector:latest | ||
| done | ||
| fi | ||
| - slack/notify: | ||
| event: fail | ||
| template: basic_fail_1 | ||
|
|
||
| deploy_testing: | ||
| docker: | ||
| - image: cimg/base:current-24.04 | ||
| steps: | ||
| - checkout | ||
| - kubernetes/install-kubectl | ||
| - run: kubectl --server=https://api.staging.eu-west.filigran.io --token=$K8S_TOKEN -n customer-testing-oaev rollout restart deployment -l app=injector | ||
|
|
||
| deploy_prerelease: | ||
| docker: | ||
| - image: cimg/base:current-24.04 | ||
| steps: | ||
| - checkout | ||
| - kubernetes/install-kubectl | ||
| - run: kubectl --server=https://api.staging.eu-west.filigran.io --token=$K8S_TOKEN_PRE_RELEASE -n customer-prerelease-oaev rollout restart deployment -l app=injector | ||
|
|
||
| notify_rolling: | ||
| docker: | ||
| - image: cimg/base:current-24.04 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| from typing import Dict | ||
|
|
||
|
|
||
| class DataHelpers: | ||
|
|
||
| @staticmethod | ||
| def get_injector_contract_id(data: Dict) -> str: | ||
| try: | ||
| return data["injection"]["inject_injector_contract"]["injector_contract_id"] | ||
| except KeyError as e: | ||
| raise ValueError("Invalid data: missing injector contract id") from e | ||
|
|
||
| @staticmethod | ||
| def get_content(data: Dict) -> Dict: | ||
| try: | ||
| return data["injection"]["inject_content"] | ||
| except KeyError as e: | ||
| raise ValueError("Invalid data: missing inject content") from e | ||
|
|
||
| @staticmethod | ||
| def get_inject_id(data: Dict) -> str: | ||
| try: | ||
| return data["injection"]["inject_id"] | ||
| except KeyError as e: | ||
| raise ValueError("Invalid data: missing inject id") from e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| config.yml | ||
| src/__pycache__ | ||
| __pycache__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| config.yml | ||
| __pycache__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| FROM python:3.13-alpine AS builder | ||
|
|
||
| RUN apk update && apk upgrade | ||
|
|
||
| WORKDIR /opt/injector_common | ||
| COPY --from=injector_common ./ ./ | ||
|
|
||
| # poetry version available on Ubuntu 24.04 | ||
| RUN pip3 install poetry==2.1.3 | ||
|
|
||
| ARG installdir=/opt/injector | ||
| ADD . ${installdir} | ||
| WORKDIR ${installdir} | ||
| RUN poetry build | ||
|
|
||
| FROM python:3.13-alpine AS runner | ||
|
|
||
| WORKDIR /opt/injector_common | ||
| COPY --from=injector_common ./ ./ | ||
|
|
||
| ARG installdir=/opt/injector | ||
| WORKDIR ${installdir} | ||
| COPY --from=builder ${installdir} ${installdir} | ||
| RUN pip3 install --no-cache-dir "$(ls dist/*.whl)[prod]" | ||
|
|
||
| # Declare the build argument | ||
| ARG PYOAEV_GIT_BRANCH_OVERRIDE | ||
|
|
||
| RUN if [[ ${PYOAEV_GIT_BRANCH_OVERRIDE} ]] ; then \ | ||
| echo "Forcing specific version of client-python" && \ | ||
| apk add --no-cache git && \ | ||
| pip install pip3-autoremove && \ | ||
| pip-autoremove pyoaev -y && \ | ||
| pip install git+https://github.com/OpenAEV-Platform/client-python@${PYOAEV_GIT_BRANCH_OVERRIDE} ; \ | ||
| fi | ||
|
|
||
| CMD ["python3", "-m", "teams.openaev_teams"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: I have also added some tests in injector_common, maybe you could include it? and maybe you could add some tests to this new injector?