Skip to content

Commit

Permalink
adding action docs
Browse files Browse the repository at this point in the history
  • Loading branch information
himynamesdave committed Dec 16, 2024
1 parent cc6c375 commit 968992f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/daily-r2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
set -e
# create a venv
python -m venv cxe2stix_helper-venv
source cxe2stix_helper-venv/bin/activate
python -m venv cve2stix_helper-venv
source cve2stix_helper-venv/bin/activate

# install requirements

Expand All @@ -61,6 +61,6 @@ jobs:
echo NVD_API_KEY must be set && exit 1
fi
source cxe2stix_helper-venv/bin/activate
source cve2stix_helper-venv/bin/activate
python daily_uploader.py
4 changes: 1 addition & 3 deletions daily_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
from cve2stix.main import main as download_bundle
import logging


def upload_file_to_s3(filepath, s3_path):
logging.info("uploading to %s", s3_path)
client = boto3.client('s3', endpoint_url=os.getenv('S3_ENDPOINT_URL'))
with open(filepath, 'rb') as f:
client.upload_fileobj(f, os.getenv('S3_BUCKET_NAME') or "cti-public", s3_path)


celery_process = start_celery("cve2stix.celery")

yesterday = datetime.now(timezone.utc) - timedelta(days=1)
dstr = yesterday.strftime('%Y_%m_%d')
s3_path = f"cve2stix-github-action-output/{yesterday.strftime('%Y-%m')}/cve-bundle-{dstr}-00_00_00-{dstr}-23_59_59.json"
s3_path = f"/{yesterday.strftime('%Y-%m')}/cve-bundle-{dstr}-00_00_00-{dstr}-23_59_59.json"
output_filename = "stix2_objects/cve-bundle.json"

logging.info("downloading bundle for %s", dstr.replace('_', '-'))
Expand Down
7 changes: 4 additions & 3 deletions docs/github-action.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Support for Cloudflare R2 + Github action

We use a Github action to run this script daily to store the bundles generated by cxe2stix_helper on Cloudflare R2.
We use a Github action to run this script daily to store the bundles generated on Cloudflare R2.

The script runs at 0700 UTC everyday (github servers UTC) using cron: `"0 7 * * *"`

Expand All @@ -10,8 +10,9 @@ Essentially the following command is run everyday by the action

```shell
python3 cve2stix.py \
--last_modified_earliest "YESTERDAY (00:00:00)" \
--last_modified_latest "YESTERDAY (23:59:59)" \
mod \
--earliest "YESTERDAY (00:00:00)" \
--latest "YESTERDAY (23:59:59)" \
--file_time_range 1d
```

Expand Down

0 comments on commit 968992f

Please sign in to comment.