Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: CI/CD Pipeline

on:
push:
branches: [ main, master ]
branches: [main, master]
pull_request:
branches: [ main, master ]
branches: [main, master]
repository_dispatch:
types: [manual-trigger]

jobs:
lint-and-test:
Expand Down Expand Up @@ -50,7 +52,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and Load
- name: Build and Load Docker Image
uses: docker/build-push-action@v5
with:
context: .
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: '43 17 * * *'
push:
branches: [ "3.0.0" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "3.0.0" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
with:
cosign-release: 'v2.2.4'

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
2 changes: 1 addition & 1 deletion AttackMapServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Configuration
redis_url = os.getenv('MAP_REDIS_URL', 'redis://127.0.0.1:6379')
web_port = int(os.getenv('MAP_WEB_PORT', '64299'))
version = 'Attack Map Server 2.5.0'
version = 'Attack Map Server 3.0.0'



Expand Down
14 changes: 7 additions & 7 deletions DataServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
es = Elasticsearch(es_url)
redis_ip = os.getenv('MAP_REDIS_HOST', '127.0.0.1')
redis_channel = 'attack-map-production'
version = 'Data Server 2.5.0'
version = 'Data Server 3.0.0'
local_tz = get_localzone()
output_text = os.getenv("CYBERPOT_ATTACKMAP_TEXT", "ENABLED").upper()

Expand Down Expand Up @@ -207,11 +207,11 @@ def update_honeypot_data():
processed_data = []
last = {"1m", "1h", "24h"}
mydelta = 10
# Using timezone-aware UTC datetime (Python 3.14+ requirement)
time_last_request = datetime.datetime.now(datetime.UTC) - datetime.timedelta(seconds=mydelta)
last_stats_time = datetime.datetime.now(datetime.UTC) - datetime.timedelta(seconds=10)
# Using timezone-aware UTC datetime
time_last_request = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(seconds=mydelta)
last_stats_time = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(seconds=10)
while True:
now = datetime.datetime.now(datetime.UTC)
now = datetime.datetime.now(datetime.timezone.utc)
# Get the honeypot stats every 10s (last 1m, 1h, 24h)
if (now - last_stats_time).total_seconds() >= 10:
last_stats_time = now
Expand All @@ -229,7 +229,7 @@ def update_honeypot_data():
# Get the last 100 new honeypot events every 0.5s
# Convert timezone-aware datetime to naive for consistent string formatting with ES
mylast_dt = time_last_request.replace(tzinfo=None)
mynow_dt = (datetime.datetime.now(datetime.UTC) - datetime.timedelta(seconds=mydelta)).replace(tzinfo=None)
mynow_dt = (datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(seconds=mydelta)).replace(tzinfo=None)

mylast = str(mylast_dt).split(" ")
mynow = str(mynow_dt).split(" ")
Expand Down Expand Up @@ -264,7 +264,7 @@ def update_honeypot_data():
res = es.search(index="logstash-*", size=100, query=ES_query)
hits = res['hits']
if len(hits['hits']) != 0:
time_last_request = datetime.datetime.now(datetime.UTC) - datetime.timedelta(seconds=mydelta)
time_last_request = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(seconds=mydelta)
for hit in hits['hits']:
try:
process_datas = process_data(hit)
Expand Down
2 changes: 0 additions & 2 deletions tests/test_DataServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ def test_update_honeypot_data_timing(self, mock_datetime_module, mock_sleep, moc
# We need to mock the class datetime.datetime, but keep timedelta working
mock_datetime_class = MagicMock()
mock_datetime_class.now.side_effect = self._fake_now
mock_datetime_class.UTC = datetime.timezone.utc

# We need to ensure datetime.timedelta is the real one because it's used in the code
mock_datetime_module.datetime = mock_datetime_class
mock_datetime_module.timedelta = datetime.timedelta
mock_datetime_module.timezone = datetime.timezone
mock_datetime_module.UTC = datetime.timezone.utc

# Mock sleep to advance time
mock_sleep.side_effect = self._fake_sleep
Expand Down
Loading