Skip to content
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

Threat detection #1783

Draft
wants to merge 89 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
09d279c
pushing malicious requests to kafka
ag060 Nov 6, 2024
a1c1f47
added flush kafka messages task
ag060 Nov 9, 2024
a450ed1
added window based aggregation support for malicious requests
ag060 Nov 12, 2024
b17132f
using separate mongo for storing suspect data
ag060 Nov 12, 2024
2dcb947
fixed kafka host
ag060 Nov 12, 2024
786df40
fixed source ip generation logic
ag060 Nov 12, 2024
a8445b3
not syncing writes and read for RedisWriteBackCache at the same time
ag060 Nov 13, 2024
ec21b33
using redis backed increment counter cache
ag060 Nov 13, 2024
dedd012
added group id to aggregate notifier
ag060 Nov 14, 2024
fa47ad7
added notification cooldown support
ag060 Nov 14, 2024
14ca6ec
added start and end bucket ids with each detected alerts
ag060 Nov 14, 2024
de83383
added ttl for redis entries
ag060 Nov 14, 2024
64c20b7
added new collections for sample malicious requests and detected alerts
ag060 Nov 15, 2024
604cbae
addded cleanup sample malicious records task
ag060 Nov 16, 2024
3dd5ae8
refactor code
ag060 Nov 18, 2024
121429e
refactor code
ag060 Nov 18, 2024
4d6c56e
refactor code
ag060 Nov 18, 2024
71413e3
add aggregation parse layer
ayushaga14 Nov 21, 2024
edad02a
grpc service for consuming malicious and smart events (#1748)
ag060 Nov 22, 2024
821581c
apply aggregations
ayushaga14 Nov 22, 2024
aa5fa0c
removed db service and using mongo client everywhere
ag060 Nov 22, 2024
6972092
moved clean up task to threat protection service
ag060 Nov 22, 2024
6ea40da
added authorization interceptor for grpc server
ag060 Nov 22, 2024
32f1abe
removed account_id field from consume event service requests (threat-…
ag060 Nov 22, 2024
88367f6
added client side authentication support while saving malicious and s…
ag060 Nov 23, 2024
f0c5513
added new api threat detection
ag060 Nov 25, 2024
e877ad2
saving malicious sample data to postgres db
ag060 Nov 25, 2024
2e13707
abstracted out common kafka polling consumer task
ag060 Nov 26, 2024
1de7a3d
added tasks for sending alerts to protection backend
ag060 Nov 28, 2024
7f4d14a
exposing single rpc method for recording alerts
ag060 Nov 28, 2024
151eab0
updated proto definition
ag060 Nov 29, 2024
69fa966
removed cleanup task from threat protection backend module
ag060 Nov 29, 2024
f184d0a
updated kafka topic names
ag060 Nov 29, 2024
e088a38
running flyway migrations programatically
ag060 Nov 29, 2024
5ba40d4
refactored code
ag060 Nov 29, 2024
9c701c7
added clean up for deleting all the malicious entries older than 7 days
ag060 Nov 29, 2024
c01d933
added hibernate orm (#1786)
ag060 Dec 10, 2024
3435917
threat protection producer consumer db writes
ayushaga14 Dec 10, 2024
7e13496
fix create mongo client params
ayushaga14 Dec 10, 2024
4ba5e5f
deleted generated proto files
ag060 Dec 10, 2024
f2cb97c
added dashboard rpc service (#1808)
ag060 Dec 10, 2024
9ab05f4
updated proto definition to include malicious event type (SINGLE or A…
ag060 Dec 10, 2024
38037f6
storing api_collection_id in postgres
ag060 Dec 10, 2024
475c871
fixed paths in ci for threat-detection module
ag060 Dec 11, 2024
2d8b80f
moved kafka config from threat detection to utils
ag060 Dec 11, 2024
bc5a8e9
moved consumer and producer on same machine for threat protection bac…
ag060 Dec 11, 2024
4955950
refactored dashboard proto messages
ag060 Dec 11, 2024
6838d40
fixed MaliciousEventModel not populating data from mongo
ag060 Dec 16, 2024
8311596
refactored code
ag060 Dec 17, 2024
5f99aea
disabled debug logging for hibernate
ag060 Dec 17, 2024
2c5fe25
removed unused imports
ag060 Dec 17, 2024
c48f9cd
disabled debug logging for hibernate
ag060 Dec 17, 2024
58cf88b
committing kafka offsets manually now
ag060 Dec 17, 2024
c765f77
renamed threat detection backend service
ag060 Dec 17, 2024
a496b43
added health check server
ag060 Dec 17, 2024
6c474f7
building threat detection backend image in staging workflow
ag060 Dec 17, 2024
f3442ed
refactored generated proto files
ag060 Dec 18, 2024
77cae61
added health check for rpc and enabled reflection
ag060 Dec 18, 2024
789ff5e
added health service for grpc
ag060 Dec 18, 2024
b0f5320
using vertx http server as threat detection backend (#1842)
ag060 Dec 19, 2024
0bdf17d
reading akto threat detection backend url from env
ag060 Dec 20, 2024
bea57d3
added try catch
ag060 Dec 21, 2024
586b1ae
fixed sample not being to backend
ag060 Dec 21, 2024
f780063
clearing cache as soon the alert is raised
ag060 Dec 23, 2024
9372bbc
sending sample malicious events to backend only once
ag060 Dec 23, 2024
b3a17f6
use fastjson lib and increase template fetch interval
ayushaga14 Dec 29, 2024
c810c5a
add log
ayushaga14 Dec 29, 2024
4ba026e
avoid reevaluating params for each filter check
ayushaga14 Dec 30, 2024
59c70a2
[temp commit] remove unneceesary build from stagiong workflow
ayushaga14 Dec 30, 2024
3439bca
using proto message envelope for kafka transport in threat detection …
ag060 Jan 1, 2025
779e3e1
setting redis ttl while sync to redis instead of increment op
ag060 Jan 2, 2025
f0314f9
fixed merge conflicts in staging and prod workflows
ag060 Jan 2, 2025
65d63d8
proto changes
ayushaga14 Jan 1, 2025
8139956
remove logs and headers loop
ayushaga14 Jan 3, 2025
a145b9f
optimizations
notshivansh Jan 3, 2025
938f4c1
move httpresponse param proto generated files
ayushaga14 Jan 6, 2025
3220902
fixed bad merges
ag060 Jan 6, 2025
5eaa0b3
refactored threat detection backend
ag060 Jan 6, 2025
44c48e1
maxmind integration (#1924)
ag060 Jan 7, 2025
52b70e5
added api protection pages in left nav
ag060 Jan 7, 2025
d8a1470
removed System.out.println
ag060 Jan 8, 2025
489fb59
removed unusued proto messages
ag060 Jan 8, 2025
dd567f0
reading kafka key and value serializer from config
ag060 Jan 8, 2025
2496f82
updated custom generated httpresponse params files
ag060 Jan 8, 2025
20a4cdd
moved threat policies to separate page
ag060 Jan 9, 2025
44c632a
fixed incorrect total count of entries in final result for list threa…
ag060 Jan 9, 2025
f2cc035
fixed sorting in threat detection tables
ag060 Jan 9, 2025
3be068a
fixed prettify endpoint url if url is empty (home page)
ag060 Jan 9, 2025
926bdf6
added filters support in threat detection APIs
ag060 Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ on:
type: boolean
default: true
description: Internal
protection:
threat_detection:
type: boolean
default: true
description: Protection
description: Threat Detection Client

threat_detection_backend:
type: boolean
default: true
description: Threat Deteection Backend

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -37,12 +42,12 @@ jobs:

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
distribution: "adopt"
java-version: "8"
architecture: x64
- uses: actions/setup-node@v2
with:
Expand All @@ -63,6 +68,14 @@ jobs:
wget -O filetypes.json https://raw.githubusercontent.com/akto-api-security/akto/master/pii-types/filetypes.json
wget -O automated_api_groups.csv https://raw.githubusercontent.com/akto-api-security/akto/master/automated-api-groups/automated-api-groups.csv


- name: Create maxmind directory
run: mkdir -p ./apps/threat-detection-backend/src/main/resources/maxmind
- name: Download Maxmind Country database
working-directory: ./apps/threat-detection-backend/src/main/resources/maxmind
run: |
wget -O Geo-Country.mmdb https://raw.githubusercontent.com/akto-api-security/tests-library/refs/heads/master/resources/Geo-Country.mmdb

- name: Prepare Dashboard polaris UI
working-directory: ./apps/dashboard/web/polaris_web
run: npm install && export RELEASE_VERSION=${{github.event.inputs.release_version}} && npm run build
Expand Down Expand Up @@ -125,10 +138,14 @@ jobs:
echo "::set-output name=image::$ECR_REGISTRY/akto-internal:$IMAGE_TAG"
fi

if [[ "${{ github.event.inputs.protection }}" == "true" ]]; then
cd ../api-threat-detection
docker buildx build --platform linux/arm64/v8,linux/amd64 -t $ECR_REGISTRY/akto-api-protection:$IMAGE_TAG_1 -t $ECR_REGISTRY/akto-api-protection:$IMAGE_TAG_2 -t $ECR_REGISTRY/akto-api-protection:$IMAGE_TAG_3 . --push
echo "::set-output name=image::$ECR_REGISTRY/akto-api-protection:$IMAGE_TAG"
if [[ "${{ github.event.inputs.threat_detection}}" == "true" ]]; then
cd apps/threat-detection
docker buildx build --platform linux/arm64/v8,linux/amd64 -t $ECR_REGISTRY/akto-threat-detection:$IMAGE_TAG . --push
fi

if [[ "${{ github.event.inputs.threat_detection_backend}}" == "true" ]]; then
cd ../threat-detection-backend
docker buildx build --platform linux/arm64/v8,linux/amd64 -t $ECR_REGISTRY/akto-threat-detection-backend:$IMAGE_TAG . --push
fi
- name: Configure AWS Credentials for ECR
uses: aws-actions/configure-aws-credentials@v1
Expand All @@ -140,7 +157,7 @@ jobs:
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'
mask-password: "true"
registry-type: public

- name: Push git tag
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@ jobs:
wget -O general.json https://raw.githubusercontent.com/akto-api-security/pii-types/master/general.json
wget -O fintech.json https://raw.githubusercontent.com/akto-api-security/akto/master/pii-types/fintech.json
wget -O filetypes.json https://raw.githubusercontent.com/akto-api-security/akto/master/pii-types/filetypes.json
- name: Prepare Dashboard polaris UI
working-directory: ./apps/dashboard/web/polaris_web
run: npm install && export RELEASE_VERSION=${{steps.docker_tag.outputs.IMAGE_TAG}} && npm run build
- name: Create maxmind directory
run: mkdir -p ./apps/threat-detection-backend/src/main/resources/maxmind
- name: Download Maxmind Country database
working-directory: ./apps/threat-detection-backend/src/main/resources/maxmind
run: |
wget -O Geo-Country.mmdb https://raw.githubusercontent.com/akto-api-security/tests-library/refs/heads/master/resources/Geo-Country.mmdb

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}}
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}}
aws-region: ap-south-1

- name: Deploy polaris site to S3 bucket
run: aws s3 sync ./apps/dashboard/web/polaris_web/web/dist s3://dashboard-on-cdn/polaris_web/${{steps.docker_tag.outputs.IMAGE_TAG}}/dist --delete

- run: mvn package -Dakto-image-tag=${{ github.event.inputs.Tag }} -Dakto-build-time=$(eval "date +%s") -Dakto-release-version=${{steps.docker_tag.outputs.IMAGE_TAG}}
- run: mvn package -Dakto-image-tag=${{ github.event.inputs.Tag }} -Dakto-build-time=$(eval "date +%s") -Dakto-release-version=${{steps.docker_tag.outputs.IMAGE_TAG}} -DskipTests
- name: DockerHub login
env:
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
Expand Down Expand Up @@ -86,10 +87,12 @@ jobs:
docker buildx build --platform linux/arm64/v8,linux/amd64 -t $ECR_REGISTRY/akto-billing:$IMAGE_TAG . --push
cd ../internal
docker buildx build --platform linux/arm64/v8,linux/amd64 -t $ECR_REGISTRY/akto-internal:$IMAGE_TAG . --push
cd ../api-threat-detection
docker buildx build --platform linux/arm64/v8,linux/amd64 -t $ECR_REGISTRY/akto-api-protection:$IMAGE_TAG . --push
cd ../source-code-analyser
docker buildx build --platform linux/arm64/v8,linux/amd64 -t $ECR_REGISTRY/source-code-analyser:$IMAGE_TAG . --push
cd ../threat-detection
docker buildx build --platform linux/arm64/v8,linux/amd64 -t $ECR_REGISTRY/akto-threat-detection:$IMAGE_TAG . --push
cd ../threat-detection-backend
docker buildx build --platform linux/arm64/v8,linux/amd64 -t $ECR_REGISTRY/akto-threat-detection-backend:$IMAGE_TAG . --push

- name: Set up JDK 11
uses: actions/setup-java@v1
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ build: proto-gen
mvn install -DskipTests

build-clean: proto-gen
mvn clean install -DskipTests
mvn clean install -DskipTests
4 changes: 0 additions & 4 deletions apps/api-threat-detection/Dockerfile

This file was deleted.

190 changes: 0 additions & 190 deletions apps/api-threat-detection/pom.xml

This file was deleted.

Loading