Compare commits

12 Commits
Author SHA1 Message Date
nvidia-stock-bot-ci 80731ea2e1 Bump build version to 4.1.5 [skip ci] 2026-11-28 04:17:10 +00:00
Boteex Bot a905be10bc Pin python Docker tag to 0f9552b (#42)
CI / build-and-scan (push) Successful in 49s
2026-11-28 05:05:16 +01:00
Djeex b4e712f3ac Use the shared cicdeex actions (#41)
CI / build-and-scan (push) Successful in 37s
Co-authored-by: Djeex <[email protected]>
2026-11-22 13:20:38 +01:00
Djeex 32c97d9173 Merge pull request 'Run the weekly scan on Saturday' (#40) from ci-align into main
CI / build-and-scan (push) Successful in 1m48s
2026-11-21 23:48:42 +01:00
Djeex a652900b9e Run the weekly scan on Saturday
CI / build-and-scan (pull_request) Successful in 29s
2026-11-21 22:31:35 +00:00
Djeex 556ac0ba21 Merge pull request 'Use the shared Renovate preset' (#39) from renovate-preset into main
CI / build-and-scan (push) Successful in 31s
2026-11-21 22:12:45 +01:00
Djeex c709e8d960 Use the shared Renovate preset
CI / build-and-scan (pull_request) Successful in 41s
2026-11-21 20:56:56 +00:00
Djeex 302f6f9f95 Update aquasec/trivy Docker tag to v0.76.2 (#38)
CI / build-and-scan (push) Successful in 1m38s
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [aquasec/trivy](https://www.aquasec.com/products/trivy/) ([source](https://github.com/aquasecurity/trivy)) | minor | `0.74.0` → `0.76.2` |

---

### Release Notes

<details>
<summary>aquasecurity/trivy (aquasec/trivy)</summary>

### [`v0.76.2`](https://github.com/aquasecurity/trivy/releases/tag/v0.76.2)

[Compare Source](https://github.com/aquasecurity/trivy/compare/v0.76.1...v0.76.2)

#### 🔐 Security update 🛡️

Trivy v0.76.2 bundles several security fixes:

- Official container images are rebuilt on Alpine 3.24.3, which fixes `musl`/`musl-utils` (CVE-2026-107891), and the build picks up fixed `libcurl` (24 CVEs, including HIGH CVE-2026-92392) and `brotli-libs` (CVE-2026-111497) from the `v3.24` package repository.
- `golang.org/x/net` is bumped to v0.62.0, fixing two vulnerabilities in `golang.org/x/net/html`: CVE-2026-78661 (quadratic complexity when coalescing text nodes) and CVE-2026-97045 (missing ancestor namespace check when rendering raw text).
- `github.com/go-jose/go-jose/v4` is bumped to v4.1.6, fixing [GHSA-mgcc-cww5-fp2q](https://github.com/go-jose/go-jose/security/advisories/GHSA-mgcc-cww5-fp2q).

We recommend upgrading to v0.76.2 and redeploying container images to apply these updates.

#### Changelog

- [`3f6334d`](https://github.com/aquasecurity/trivy/commit/3f6334d223b52188324af3b9923b4249cd206652) release: v0.76.2 \[release/v0.76] ([#&#8203;11552](https://github.com/aquasecurity/trivy/issues/11552))
- [`1cabe83`](https://github.com/aquasecurity/trivy/commit/1cabe83c11ffed6e984ab46be8886e1e01516ead) fix(deps): bump golang.org/x/net from 0.61.0 to 0.62.0 \[backport: release/v0.76] ([#&#8203;11554](https://github.com/aquasecurity/trivy/issues/11554))
- [`be08de4`](https://github.com/aquasecurity/trivy/commit/be08de47d0d76fca7e992c0f47fbcf7853f8a713) chore(deps): bump the common group across 1 directory with 14 updates \[backport: release/v0.76] ([#&#8203;11555](https://github.com/aquasecurity/trivy/issues/11555))
- [`a8537d3`](https://github.com/aquasecurity/trivy/commit/a8537d389cbd0fa215eddfddc27150fc7bc82a6c) fix(deps): bump github.com/go-jose/go-jose/v4 from 4.1.5 to 4.1.6 \[backport: release/v0.76] ([#&#8203;11553](https://github.com/aquasecurity/trivy/issues/11553))
- [`ae26b88`](https://github.com/aquasecurity/trivy/commit/ae26b88c3b3c380808e767dfb63f9b8dcd5f64fd) fix(deps): bump alpine to 3.24.3 in container images \[backport: release/v0.76] ([#&#8203;11551](https://github.com/aquasecurity/trivy/issues/11551))

### [`v0.76.1`](https://github.com/aquasecurity/trivy/releases/tag/v0.76.1)

[Compare Source](https://github.com/aquasecurity/trivy/compare/v0.76.0...v0.76.1)

#### 🔐 Security update: eMudhra CA incident 🛡️

Trivy v0.76.1 includes mitigations for the [eMudhra intermediate CA key compromise](https://blog.cloudflare.com/emudhra-certificate-compromise/).

- Official binaries are built with Go 1.27.3, which includes the certificate distrust mitigation tracked as [CVE-2026-111943](https://go.dev/issue/82345).
- Official container images include an updated Alpine CA trust store that rejects the affected certificate chains.

We recommend upgrading to v0.76.1 and redeploying container images to apply these updates. If you build Trivy from source, use Go 1.27.3 or later and keep your runtime CA trust store up to date.

#### Changelog

- [`e713f67`](https://github.com/aquasecurity/trivy/commit/e713f67f7d54decdcd9b3132c9751833dcced698) release: v0.76.1 \[release/v0.76] ([#&#8203;11445](https://github.com/aquasecurity/trivy/issues/11445))
- [`6647bd6`](https://github.com/aquasecurity/trivy/commit/6647bd6ec5924087956285b773b8cae10508736e) fix(deps): bump the aws group across 1 directory with 6 updates \[backport: release/v0.76] ([#&#8203;11446](https://github.com/aquasecurity/trivy/issues/11446))
- [`e0964c9`](https://github.com/aquasecurity/trivy/commit/e0964c97819b1d6a45b7e0426803745f173fc550) fix(deps): bump the docker group with 3 updates \[backport: release/v0.76] ([#&#8203;11443](https://github.com/aquasecurity/trivy/issues/11443))
- [`992c360`](https://github.com/aquasecurity/trivy/commit/992c360c33d9f9627bb24c1fe3f20815110c88e5) fix(deps): bump the common group with 3 updates \[backport: release/v0.76] ([#&#8203;11442](https://github.com/aquasecurity/trivy/issues/11442))

### [`v0.76.0`](https://github.com/aquasecurity/trivy/blob/HEAD/CHANGELOG.md#0760-2026-10-14)

[Compare Source](https://github.com/aquasecurity/trivy/compare/v0.75.0...v0.76.0)

##### Features

- **crypto:** distinguish DSA algorithms by L and N ([#&#8203;11366](https://github.com/aquasecurity/trivy/issues/11366)) ([bcc9bd4](https://github.com/aquasecurity/trivy/commit/bcc9bd47fa67dd251312d0b361fa568a108f0cac))
- **crypto:** report nominal security levels of algorithms ([#&#8203;11369](https://github.com/aquasecurity/trivy/issues/11369)) ([a67baa8](https://github.com/aquasecurity/trivy/commit/a67baa8d36f5307d5f9fbdfd9bc9977bf74228a7))
- **echo:** support Echo Maven and npm package scanning ([#&#8203;10883](https://github.com/aquasecurity/trivy/issues/10883)) ([7c1b1fa](https://github.com/aquasecurity/trivy/commit/7c1b1fa19f1628132a9e8377fed127682500d87d))
- **vuln:** extend RapidFort scanner to Debian, Oracle, Rocky, Alma, and Amazon ([#&#8203;11285](https://github.com/aquasecurity/trivy/issues/11285)) ([aaebec6](https://github.com/aquasecurity/trivy/commit/aaebec6cf772111b2bd1dca221e0c36e0a952817))

##### Bug Fixes

- **echo:** match +echo.N local segment anywhere in pip versions ([#&#8203;11367](https://github.com/aquasecurity/trivy/issues/11367)) ([bfb43a4](https://github.com/aquasecurity/trivy/commit/bfb43a49642fbdf60f5e794bba5982fdaa433136))
- **php:** keep dependency edges to packages named like PHP extensions ([#&#8203;11051](https://github.com/aquasecurity/trivy/issues/11051)) ([0900c7e](https://github.com/aquasecurity/trivy/commit/0900c7eb5a29f1169a3fdabd6ce4b45da2271400))
- **vex:** avoid panic on CSAF advisory without a CVE ([#&#8203;10990](https://github.com/aquasecurity/trivy/issues/10990)) ([431288f](https://github.com/aquasecurity/trivy/commit/431288f897ff543f19c49274dcc1df1a3bef8664))

### [`v0.75.0`](https://github.com/aquasecurity/trivy/blob/HEAD/CHANGELOG.md#0750-2026-10-01)

[Compare Source](https://github.com/aquasecurity/trivy/compare/v0.74.0...v0.75.0)

##### ⚠ BREAKING CHANGES

- **report:** remove getHostByName from templates ([#&#8203;11206](https://github.com/aquasecurity/trivy/issues/11206))

##### Features

- add cryptographic asset model and parser ([#&#8203;10970](https://github.com/aquasecurity/trivy/issues/10970)) ([64e1715](https://github.com/aquasecurity/trivy/commit/64e17158b838f3154be3c75cd4799d058143ea92))
- **cli:** allow disabling configuration files with empty paths ([#&#8203;11210](https://github.com/aquasecurity/trivy/issues/11210)) ([5f00edd](https://github.com/aquasecurity/trivy/commit/5f00edd05931cb8034242668e3951aa9aa723db1))
- **crypto:** add analyzer and pass assets to the scan report ([#&#8203;11104](https://github.com/aquasecurity/trivy/issues/11104)) ([fb7ad28](https://github.com/aquasecurity/trivy/commit/fb7ad289bdf017e697d7633942774d2c91f7f298))
- **crypto:** add the crypto scanner to the image command ([#&#8203;11144](https://github.com/aquasecurity/trivy/issues/11144)) ([dc9a384](https://github.com/aquasecurity/trivy/commit/dc9a38453595894876b4c2290d3c61279da44c5d))
- **crypto:** describe ML-DSA keys and signature algorithms ([#&#8203;11137](https://github.com/aquasecurity/trivy/issues/11137)) ([20c3c35](https://github.com/aquasecurity/trivy/commit/20c3c3520b01a0083e6155e5e547f803d41ddfd8))
- **crypto:** describe parsed material as cryptographic assets ([#&#8203;11092](https://github.com/aquasecurity/trivy/issues/11092)) ([7d0a892](https://github.com/aquasecurity/trivy/commit/7d0a892930369a387c31c68f4390131be0741022))
- **crypto:** output cryptographic assets in CycloneDX ([#&#8203;11125](https://github.com/aquasecurity/trivy/issues/11125)) ([3897d5c](https://github.com/aquasecurity/trivy/commit/3897d5c35e2dfa4d8d0ed15bf958fe5e943a91b4))
- **crypto:** transfer cryptographic assets in client/server mode ([#&#8203;11141](https://github.com/aquasecurity/trivy/issues/11141)) ([4128b7f](https://github.com/aquasecurity/trivy/commit/4128b7f4ece535c1c0ca60ee5766f5016efd65e0))
- **echo:** add vulnerability detection for Echo-patched Python packages ([#&#8203;10555](https://github.com/aquasecurity/trivy/issues/10555)) ([98787b8](https://github.com/aquasecurity/trivy/commit/98787b870c109531416cea6019a9b55af224a101))

##### Bug Fixes

- avoid panics on malformed dependency files and version-less Amazon Linux release ([#&#8203;10996](https://github.com/aquasecurity/trivy/issues/10996)) ([ef28d95](https://github.com/aquasecurity/trivy/commit/ef28d95fea53a7456ec631635ef8556861faee8a))
- correct grammar and typos in user-facing error messages ([#&#8203;11211](https://github.com/aquasecurity/trivy/issues/11211)) ([a8c8409](https://github.com/aquasecurity/trivy/commit/a8c8409ef130b617524f71a12f6faa4cb44a04ab))
- correct grammar and typos in user-facing error messages and CLI flags ([#&#8203;11281](https://github.com/aquasecurity/trivy/issues/11281)) ([5ba5be0](https://github.com/aquasecurity/trivy/commit/5ba5be055fb0ad060403100c54b2aecae62c7e9e))
- **crypto:** read RSA private keys without validating their math ([#&#8203;11319](https://github.com/aquasecurity/trivy/issues/11319)) ([3683d7d](https://github.com/aquasecurity/trivy/commit/3683d7d497b60084057f8b332176a32b75cb473a))
- **go:** honor go directive when merging go.sum ([#&#8203;11169](https://github.com/aquasecurity/trivy/issues/11169)) ([71190a6](https://github.com/aquasecurity/trivy/commit/71190a68a9108aefa7131ad4249fa077e3d09816))
- **go:** restore stdlib version parsing for vendor-patched Go toolchains ([#&#8203;11119](https://github.com/aquasecurity/trivy/issues/11119)) ([a851889](https://github.com/aquasecurity/trivy/commit/a851889c930eb8a604dec96ad9a783d75e2b6ac6))
- **license:** report unparsable license names with UNKNOWN severity ([#&#8203;11254](https://github.com/aquasecurity/trivy/issues/11254)) ([7b598ab](https://github.com/aquasecurity/trivy/commit/7b598ab7a97bd01c4ad1ab1f80c23a2574915410))
- **license:** use canonical SPDX casing for license.id ([#&#8203;11165](https://github.com/aquasecurity/trivy/issues/11165)) ([89d3acf](https://github.com/aquasecurity/trivy/commit/89d3acfce93a34e2120dbff0f71c947aadce4c83))
- **misconf:** report correct line numbers in multi-document manifests ([#&#8203;11207](https://github.com/aquasecurity/trivy/issues/11207)) ([4eac9a0](https://github.com/aquasecurity/trivy/commit/4eac9a04f2c2b3ae990b9b361d14b65103278c7b))
- **nodejs:** support boolean resolved field in package-lock.json ([#&#8203;11156](https://github.com/aquasecurity/trivy/issues/11156)) ([a2474b8](https://github.com/aquasecurity/trivy/commit/a2474b8410166610633adc7a5a20be1618c63c19))
- **os:** keep the fullest OS version when merging analyzer results ([#&#8203;11039](https://github.com/aquasecurity/trivy/issues/11039)) ([0afeae0](https://github.com/aquasecurity/trivy/commit/0afeae01abcf4a4d6a1538a716a81dae7e2c203f))
- **purl:** classify julia, bottlerocket and centos stream packages ([#&#8203;11326](https://github.com/aquasecurity/trivy/issues/11326)) ([3a1b311](https://github.com/aquasecurity/trivy/commit/3a1b311e63a1b64ab3221bf52683581b77187198))
- **python:** skip pip requirement lines with malformed extras brackets ([#&#8203;11300](https://github.com/aquasecurity/trivy/issues/11300)) ([7e71d21](https://github.com/aquasecurity/trivy/commit/7e71d211f51f2599af7ded5fbfad96b50430446e))
- **python:** support uv workspace lockfiles ([#&#8203;10553](https://github.com/aquasecurity/trivy/issues/10553)) ([a072319](https://github.com/aquasecurity/trivy/commit/a072319acd27e4ef85d73ff7b4c980b5e0646671))
- **report:** remove getHostByName from templates ([#&#8203;11206](https://github.com/aquasecurity/trivy/issues/11206)) ([9b2b830](https://github.com/aquasecurity/trivy/commit/9b2b830877a78ab77999a9fe2c4526b8cd4b922a))
- **repo:** strip credentials from remote repository URL in artifact name ([#&#8203;11213](https://github.com/aquasecurity/trivy/issues/11213)) ([c961eeb](https://github.com/aquasecurity/trivy/commit/c961eebeab1fa21330792abfc818236867e6e5ac))
- **sbom:** skip null entries in SPDX file and package arrays ([#&#8203;11101](https://github.com/aquasecurity/trivy/issues/11101)) ([0aaaa71](https://github.com/aquasecurity/trivy/commit/0aaaa7174d978e04d75d39a9494ff5b0245cdc53))
- **server:** propagate package modularity label, build info and installed files ([#&#8203;11188](https://github.com/aquasecurity/trivy/issues/11188)) ([bf9f5b7](https://github.com/aquasecurity/trivy/commit/bf9f5b781ec7128e145367c8b5f9890117471fff))
- set locations for JSON values sharing a line ([#&#8203;11231](https://github.com/aquasecurity/trivy/issues/11231)) ([e5b5a3a](https://github.com/aquasecurity/trivy/commit/e5b5a3ac5876550eff50b1e14949589d91e01976))
- **terraform:** do not override --skip-files with --skip-dirs ([#&#8203;11191](https://github.com/aquasecurity/trivy/issues/11191)) ([1c8c54f](https://github.com/aquasecurity/trivy/commit/1c8c54fe9e2d18411cd997d5009a7771730f1481))
- **vex:** avoid panic on CSAF relationships without a sub-component ([#&#8203;11067](https://github.com/aquasecurity/trivy/issues/11067)) ([ae561f8](https://github.com/aquasecurity/trivy/commit/ae561f8cca36b4b11434b0a6d171b39ec1ad871e))

##### Performance Improvements

- avoid regrowing the buffer when reading a cached file ([#&#8203;11134](https://github.com/aquasecurity/trivy/issues/11134)) ([25521f4](https://github.com/aquasecurity/trivy/commit/25521f48ea415d3886d5f5cdc820937b25fb302d))
- **crypto:** report repeated x509 material once per file ([#&#8203;11263](https://github.com/aquasecurity/trivy/issues/11263)) ([f6423f6](https://github.com/aquasecurity/trivy/commit/f6423f6053ddbba178f99e1e8878ba1a46bb5d80))
- reuse one JSON unmarshaler per document ([#&#8203;11232](https://github.com/aquasecurity/trivy/issues/11232)) ([e97dfcc](https://github.com/aquasecurity/trivy/commit/e97dfcc1bd777cdc85a2aedb52b761ea543b9ae0))
- **secret:** avoid cloning the logger for every rule ([#&#8203;11133](https://github.com/aquasecurity/trivy/issues/11133)) ([ab3cf86](https://github.com/aquasecurity/trivy/commit/ab3cf8625cf461e5471259e50681d230017b2b65))
- **secret:** replace per-rule keyword search with one Aho-Corasick pass ([#&#8203;11179](https://github.com/aquasecurity/trivy/issues/11179)) ([f372e56](https://github.com/aquasecurity/trivy/commit/f372e564e5ad6d02bf820a90b477913f827e5a1e))
- take JSON line numbers from decoder offsets ([#&#8203;11233](https://github.com/aquasecurity/trivy/issues/11233)) ([7e21433](https://github.com/aquasecurity/trivy/commit/7e21433cb3cdb61118cc7d1704446541f35e8396))

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/Paris)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yNTcuOSIsInVwZGF0ZWRJblZlciI6IjQ0LjI1Ny45IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJib3QiLCJtaW5vciJdfQ==-->

Reviewed-on: https://git.djeex.fr/Djeex/nvidia-stock-bot/pulls/38
Co-authored-by: Djeex <[email protected]>
2026-11-21 19:44:48 +01:00
Djeex 67f94fd2c0 Track CI tool images with Renovate (#37)
CI / build-and-scan (push) Successful in 28s
## Summary
- Custom Renovate manager for the CI tool images pinned in `docker run`/`docker create` commands (Trivy, gitleaks, hadolint), which the default managers do not detect.
- Renovate will now open PRs to bump them; they are not automerged.

## Test plan
- [ ] CI green on this PR
- [ ] After merge, Renovate opens a PR bumping Trivy
- [ ] That PR passes CI before merging

Reviewed-on: #37
Co-authored-by: Djeex <[email protected]>
2026-11-21 18:46:58 +01:00
Djeex 9189c4f639 Pin image digests and add minimum release age (#36)
CI / build-and-scan (push) Successful in 28s
## Summary
- `docker:pinDigests`: Renovate pins image digests and opens digest PRs when a base image is rebuilt, so security fixes are picked up.
- `minimumReleaseAge`: 3 days globally, 7 days for pip.
- Automerge for `pin` and `digest` updates, like patch updates.

## Test plan
- [x] CI green on this PR
- [x] After merge, Renovate opens a pin PR for the Dockerfile digests
- [x] That PR automerges once CI passes

Reviewed-on: #36
Co-authored-by: Djeex <[email protected]>
2026-11-21 18:13:42 +01:00
nvidia-stock-bot-ci 159182e6a1 Bump build version to 4.1.4 [skip ci] 2026-10-30 04:17:26 +00:00
Djeex d0f76b9978 chore(deps): update python docker tag to v3.15.2
CI / build-and-scan (pull_request) Successful in 24s
CI / build-and-scan (push) Successful in 37s
2026-10-30 04:05:21 +00:00
12 changed files with 59 additions and 549 deletions

No files matched your search

+39 -210
View File
@@ -6,7 +6,8 @@ on:
pull_request: pull_request:
branches: [main] branches: [main]
schedule: schedule:
- cron: "0 6 * * 1" # Saturday 05:00 UTC: 06:00 in Paris in winter, 07:00 in summer (Gitea runs cron in UTC).
- cron: "0 5 * * 6"
jobs: jobs:
build-and-scan: build-and-scan:
@@ -18,20 +19,20 @@ jobs:
fetch-depth: 0 fetch-depth: 0
persist-credentials: false persist-credentials: false
- name: Get shared actions
uses: actions/checkout@v7
with:
repository: labeex/cicdeex
ref: 1.1.0
token: ${{ secrets.CICDEEX_TOKEN }}
path: .cicdeex
persist-credentials: false
- name: Scan for secrets - name: Scan for secrets
run: | uses: ./.cicdeex/secret-scan
# docker cp, not a build COPY: a repo's own .dockerignore (e.g. one that
# excludes .git for prod builds) would otherwise silently give an empty,
# falsely-clean scan.
CID=$(docker create zricethezav/gitleaks:v8.30.1 detect --source=/repo --no-banner -v)
docker cp . "$CID:/repo"
docker start -a "$CID"
STATUS=$?
docker rm "$CID" > /dev/null
exit $STATUS
- name: Lint Dockerfile with hadolint - name: Lint Dockerfile with hadolint
run: docker run --rm -i hadolint/hadolint:v2.15.1-alpine hadolint --failure-threshold error - < Dockerfile uses: ./.cicdeex/hadolint
- name: Build Docker image - name: Build Docker image
run: | run: |
@@ -80,210 +81,38 @@ jobs:
- name: Scan with Trivy (critical - blocking) - name: Scan with Trivy (critical - blocking)
id: trivy_critical id: trivy_critical
continue-on-error: true continue-on-error: true
run: | uses: ./.cicdeex/trivy
docker run --rm \ with:
-e DOCKER_HOST=tcp://dockerhost:2375 \ image: nvidia-stock-bot:ci
--add-host=dockerhost:host-gateway \
aquasec/trivy:0.74.0 image --exit-code 1 --severity CRITICAL nvidia-stock-bot:ci
- name: Handle CRITICAL findings - name: Handle CRITICAL findings
if: steps.trivy_critical.outcome == 'failure' if: steps.trivy_critical.outcome == 'failure'
run: | uses: ./.cicdeex/remediate
if [ "${{ github.event_name }}" != "schedule" ]; then with:
echo "::error::CRITICAL vulnerabilities found, failing the build." push-token: ${{ secrets.CI_PUSH_TOKEN }}
exit 1
fi
echo "Scheduled scan found CRITICAL vulnerabilities — attempting an automatic apk upgrade + rescan."
sed -i '/^FROM .* AS base$/a RUN apk upgrade --no-cache' Dockerfile
docker build -t nvidia-stock-bot:remediated .
if docker run --rm \
-e DOCKER_HOST=tcp://dockerhost:2375 \
--add-host=dockerhost:host-gateway \
aquasec/trivy:0.74.0 image --exit-code 1 --severity CRITICAL nvidia-stock-bot:remediated; then
echo "apk upgrade clears the CRITICAL finding(s) — opening a PR for review."
BRANCH="auto/cve-fix-$(date +%Y%m%d)-$(echo "${{ github.sha }}" | cut -c1-7)"
git config user.name "nvidia-stock-bot-ci"
git config user.email "[email protected]"
git checkout -b "$BRANCH"
git add Dockerfile
git commit -m "Auto-remediate CRITICAL CVE via apk upgrade"
git config --unset-all http.https://git.djeex.fr/.extraheader || true
git push "https://Djeex:${{ secrets.CI_PUSH_TOKEN }}@git.djeex.fr/Djeex/nvidia-stock-bot.git" "HEAD:$BRANCH"
PR_JSON=$(curl -s -X POST \
-H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg head "$BRANCH" '{title: "🔒 Auto: remediate CRITICAL CVE via apk upgrade", head: $head, base: "main", body: "Opened automatically by the scheduled CVE scan. An `apk upgrade --no-cache` cleared the CRITICAL Trivy finding(s) in a rebuild — review the diff and merge to publish the fix."}')" \
"https://git.djeex.fr/api/v1/repos/Djeex/nvidia-stock-bot/pulls")
echo "PR API response: $(echo "$PR_JSON" | jq -r '.html_url // .message // "unknown"')"
else
echo "::error::apk upgrade does not clear the CRITICAL finding(s) — no automatic fix available, needs manual review."
exit 1
fi
- name: Scan with Trivy (high - informative) - name: Scan with Trivy (high - informative)
run: | uses: ./.cicdeex/trivy
docker run --rm \ with:
-e DOCKER_HOST=tcp://dockerhost:2375 \ image: nvidia-stock-bot:ci
--add-host=dockerhost:host-gateway \ severity: HIGH
aquasec/trivy:0.74.0 image --exit-code 0 --severity HIGH nvidia-stock-bot:ci exit-code: "0"
- name: Publish tagged image - name: Publish tagged image
id: publish
if: github.event_name == 'push' && github.ref == 'refs/heads/main' if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: | uses: ./.cicdeex/publish
BEFORE="${{ github.event.before }}" with:
if [ -n "$BEFORE" ] && [ "$BEFORE" != "0000000000000000000000000000000000000000" ] && git cat-file -e "$BEFORE" 2>/dev/null; then image: nvidia-stock-bot:ci
BASE_REF="$BEFORE" paths: '^(Dockerfile|VERSION)$|^app/'
else push-token: ${{ secrets.CI_PUSH_TOKEN }}
BASE_REF="HEAD~1" registry-token: ${{ secrets.REGISTRY_TOKEN }}
fi github-mirror: "true"
CHANGED=$(git diff --name-only "$BASE_REF" "${{ github.sha }}") github-token: ${{ secrets.GH_TOKEN }}
echo "Changed files:"
echo "$CHANGED"
if ! echo "$CHANGED" | grep -qE '^(Dockerfile|VERSION)$|^app/'; then - name: Notify failures
echo "No container-relevant file changed, skipping publish." if: always()
exit 0 uses: ./.cicdeex/notify
fi with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
if echo "$CHANGED" | grep -qE '^VERSION$'; then status: ${{ job.status }}
echo "VERSION was manually edited in this push, using it as-is."
else
echo "VERSION untouched but container files changed, auto-bumping the build number (Z)."
OLD_VERSION=$(tr -d '[:space:]' < VERSION)
IFS='.' read -r MAJOR MINOR PATCH <<< "$OLD_VERSION"
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
echo "$NEW_VERSION" > VERSION
git config user.name "nvidia-stock-bot-ci"
git config user.email "[email protected]"
git add VERSION
git commit -m "Bump build version to $NEW_VERSION [skip ci]"
# Belt and suspenders: actions/checkout can leave its own ephemeral
# credential injected as an extraheader, which would silently override
# the URL-embedded token below. persist-credentials:false on checkout
# should already prevent this, but strip it here too just in case.
git config --unset-all http.https://git.djeex.fr/.extraheader || true
git push "https://Djeex:${{ secrets.CI_PUSH_TOKEN }}@git.djeex.fr/Djeex/nvidia-stock-bot.git" HEAD:main
fi
VERSION=$(tr -d '[:space:]' < VERSION)
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
MINOR_TAG="${MAJOR}.${MINOR}"
IMAGE=git.djeex.fr/djeex/nvidia-stock-bot
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.djeex.fr -u Djeex --password-stdin
# Retag the already-built, already-scanned image — never rebuild for publish,
# so what ships is byte-for-byte what Trivy just scanned.
docker tag nvidia-stock-bot:ci "$IMAGE:latest"
docker tag nvidia-stock-bot:ci "$IMAGE:$MINOR_TAG"
docker tag nvidia-stock-bot:ci "$IMAGE:$VERSION"
docker push "$IMAGE:latest"
docker push "$IMAGE:$MINOR_TAG"
docker push "$IMAGE:$VERSION"
GHCR_IMAGE=ghcr.io/djeex/nvidia-stock-bot
echo "${{ secrets.GH_TOKEN }}" | docker login ghcr.io -u Djeex --password-stdin
docker tag nvidia-stock-bot:ci "$GHCR_IMAGE:latest"
docker tag nvidia-stock-bot:ci "$GHCR_IMAGE:$MINOR_TAG"
docker tag nvidia-stock-bot:ci "$GHCR_IMAGE:$VERSION"
docker push "$GHCR_IMAGE:latest"
docker push "$GHCR_IMAGE:$MINOR_TAG"
docker push "$GHCR_IMAGE:$VERSION"
TRIGGER_MSG=$(git log -1 --format=%s "${{ github.sha }}")
PR_NUM=$(echo "$TRIGGER_MSG" | grep -oE '#[0-9]+' | head -1 | tr -d '#' || true)
CATEGORY="🔧 Maintenance"
CHANGE_TITLE="$TRIGGER_MSG"
if [ -n "$PR_NUM" ]; then
PR_JSON=$(curl -s -H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
"https://git.djeex.fr/api/v1/repos/Djeex/nvidia-stock-bot/pulls/$PR_NUM")
PR_TITLE=$(echo "$PR_JSON" | jq -r '.title // empty' 2>/dev/null || true)
LABELS=$(echo "$PR_JSON" | jq -r '.labels[]?.name' 2>/dev/null || true)
if [ -n "$PR_TITLE" ]; then
CHANGE_TITLE="$PR_TITLE"
fi
if echo "$LABELS" | grep -qx 'bug'; then
CATEGORY="⚠️ Hotfix"
elif echo "$LABELS" | grep -qx 'major'; then
CATEGORY="💥 Breaking change"
elif echo "$LABELS" | grep -qx 'minor'; then
CATEGORY="✨ Update"
fi
fi
REPO_URL="https://git.djeex.fr/Djeex/nvidia-stock-bot"
COMMIT_LIST=$(git log --no-merges --format="- %s ([%h](${REPO_URL}/commit/%H))" "$BASE_REF".."${{ github.sha }}")
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
SOURCE_LINE="[${SHORT_SHA}](${REPO_URL}/commit/${{ github.sha }})"
if [ -n "$PR_NUM" ]; then
SOURCE_LINE="[#${PR_NUM}](${REPO_URL}/pulls/${PR_NUM}) · ${SOURCE_LINE}"
fi
BODY=$(cat <<EOF
## Changelog
### ${CATEGORY}
${CHANGE_TITLE}
**Source:** ${SOURCE_LINE}
**Image:** \`${IMAGE}:${VERSION}\`
**Commits:**
${COMMIT_LIST}
EOF
)
JSON_PAYLOAD=$(jq -n \
--arg tag "$VERSION" \
--arg name "$VERSION" \
--arg body "$BODY" \
'{tag_name: $tag, name: $name, target_commitish: "main", body: $body}')
curl -s -o /dev/null -w "Release API response: %{http_code}\n" -X POST \
-H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
"https://git.djeex.fr/api/v1/repos/Djeex/nvidia-stock-bot/releases"
MIRROR_NOTICE="_This github repo is a mirror of https://git.djeex.fr/Djeex/nvidia-stock-bot. You'll find full package, PR, history and release note there._"
GH_BODY=$(printf '%s\n\n%s' "$MIRROR_NOTICE" "$BODY")
GH_JSON_PAYLOAD=$(jq -n \
--arg tag "$VERSION" \
--arg name "$VERSION" \
--arg body "$GH_BODY" \
--arg sha "${{ github.sha }}" \
'{tag_name: $tag, name: $name, target_commitish: $sha, body: $body}')
GH_STATUS=0
for i in 1 2 3 4 5; do
GH_STATUS=$(curl -s -o /tmp/gh_release.json -w "%{http_code}" -X POST \
-H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
-H "Content-Type: application/json" \
-d "$GH_JSON_PAYLOAD" \
"https://api.github.com/repos/Djeex/nvidia-stock-bot/releases")
if [ "$GH_STATUS" = "201" ]; then
break
fi
echo "GitHub Release attempt $i failed (HTTP $GH_STATUS) — mirror may not have synced this commit yet, retrying in 15s..."
sleep 15
done
echo "GitHub Release API response: $GH_STATUS"
if [ "$GH_STATUS" != "201" ]; then
cat /tmp/gh_release.json 2>/dev/null || true
fi
+1 -1
View File
@@ -1,4 +1,4 @@
FROM python:3.15.1-alpine AS base FROM python:3.15.2-alpine@sha256:0f9552bb28711333da16915ec146f5e6bb44a7fdac9ced15dc17c2e0206346dd AS base
RUN apk add --no-cache ca-certificates RUN apk add --no-cache ca-certificates
+6 -56
View File
@@ -8,7 +8,7 @@
<img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvidia-stock-bot-logo.png" alt="Nvidia Stock Bot" width="300"> <img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvidia-stock-bot-logo.png" alt="Nvidia Stock Bot" width="300">
</div> </div>
**🤖 Nvidia Stock Bot** - A bot that alerts you in real-time about **Nvidia RTX FE** GPU stock availability through Discord and/or Telegram notifications. **🤖 Nvidia Stock Bot** - A bot that alerts you in real-time about **Nvidia RTX FE** GPU stock availability through Discord notifications.
> [!NOTE] > [!NOTE]
>_Github repo is a mirror of https://git.djeex.fr/Djeex/nvidia-stock-bot. You'll find full package, history and release note there. LLM used for bugs check and languages files generation._ >_Github repo is a mirror of https://git.djeex.fr/Djeex/nvidia-stock-bot. You'll find full package, history and release note there. LLM used for bugs check and languages files generation._
@@ -25,7 +25,6 @@
- [🐳 Docker Installation without cloning the repo (quick)](#-docker-installation-without-the-repo-quick) - [🐳 Docker Installation without cloning the repo (quick)](#-docker-installation-without-the-repo-quick)
- [🐙 Docker Installation with the repo (developer)](#-docker-installation-with-the-repo) - [🐙 Docker Installation with the repo (developer)](#-docker-installation-with-the-repo)
- [🐍 Python Installation (developer)](#-python-installation) - [🐍 Python Installation (developer)](#-python-installation)
- [📨 Notification channels](#-notification-channels)
- [🐞 Common issues](#-common-issues) - [🐞 Common issues](#-common-issues)
- [❓ How it works](#-how-it-works) - [❓ How it works](#-how-it-works)
- [🧑‍💻 Contributors](#-contributors) - [🧑‍💻 Contributors](#-contributors)
@@ -37,8 +36,6 @@
- Discord `@everyone` or specified role on SKU change (possible imminent drop) - Discord `@everyone` or specified role on SKU change (possible imminent drop)
- Discord `@everyone` or specified role notification when stock is detected, including model, price, and link - Discord `@everyone` or specified role notification when stock is detected, including model, price, and link
- Silent Discord notification when no stock is detected - Silent Discord notification when no stock is detected
- Telegram notifications (stock, out of stock, SKU change) in the same language as Discord
- Discord and Telegram are both optional and can be used together or separately
- Selectable notification server name in notification footer - Selectable notification server name in notification footer
- Selectable check frequency - Selectable check frequency
- Test mode to check without sending notifications - Test mode to check without sending notifications
@@ -64,9 +61,7 @@ services:
environment: environment:
# Minimal environment variables # Minimal environment variables
- PRODUCT_NAMES= # Exact GPU name (e.g. 'RTX 5080, RTX 5090') - PRODUCT_NAMES= # Exact GPU name (e.g. 'RTX 5080, RTX 5090')
- DISCORD_WEBHOOK_URL= # Your Discord webhook URL (optional) - DISCORD_WEBHOOK_URL= # Your Discord webhook URL
- TELEGRAM_BOT_TOKEN= # Your Telegram bot token (optional)
- TELEGRAM_CHAT_ID= # Your Telegram chat ID (optional)
- COUNTRY= # Set your country (e.g. 'US') - COUNTRY= # Set your country (e.g. 'US')
- PYTHONUNBUFFERED=1 # Enables real-time log output - PYTHONUNBUFFERED=1 # Enables real-time log output
``` ```
@@ -76,9 +71,7 @@ services:
| Variable | Description | Possible Values | Default Value | | Variable | Description | Possible Values | Default Value |
|---------------------|-------------------------------------------------|------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------| |---------------------|-------------------------------------------------|------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| `PRODUCT_NAMES` | The exact GPU names you're searching for | `RTX 5080, RTX 5090` | | | `PRODUCT_NAMES` | The exact GPU names you're searching for | `RTX 5080, RTX 5090` | |
| `DISCORD_WEBHOOK_URL` | Your Discord webhook URL. Optional: if empty, Discord notifications are disabled (a warning is logged) | A valid URL | | | `DISCORD_WEBHOOK_URL` | Your Discord webhook URL | A valid URL | |
| `TELEGRAM_BOT_TOKEN` | Token of your Telegram bot (created with @BotFather). Optional, must be set together with `TELEGRAM_CHAT_ID`; if empty, Telegram notifications are disabled (a warning is logged) | `123456:ABC-DEF...` | |
| `TELEGRAM_CHAT_ID` | ID of the Telegram chat, group or channel receiving the notifications | `123456789`, `-1001234567890` | |
| `COUNTRY` | Your country (only one). API localization, Discord notification currency and language will be set accordingly | `GB`, `US`, `CA`, `BE`, `NL`, `DK`, `DE`, `ES`, `FR`, `IT`, `NO`, `AT`, `PL`, `FI`, `SE`, `KR`, `JP` | `US` | | `COUNTRY` | Your country (only one). API localization, Discord notification currency and language will be set accordingly | `GB`, `US`, `CA`, `BE`, `NL`, `DK`, `DE`, `ES`, `FR`, `IT`, `NO`, `AT`, `PL`, `FI`, `SE`, `KR`, `JP` | `US` |
| `DISCORD_SERVER_NAME` | The name of your server, displayed in notification's footer | A text | Shared for free | | `DISCORD_SERVER_NAME` | The name of your server, displayed in notification's footer | A text | Shared for free |
| `DISCORD_ROLES` | List of Discord roles ID in the same order than `PRODUCT_NAMES` values, found in your discord server settings (with user profile developer mode enabled) | `<@&12345><@&6789>` | @everyone | | `DISCORD_ROLES` | List of Discord roles ID in the same order than `PRODUCT_NAMES` values, found in your discord server settings (with user profile developer mode enabled) | `<@&12345><@&6789>` | @everyone |
@@ -123,7 +116,7 @@ docker build -t nvidia-stock-bot .
``` ```
- Then go to `nvidia-stock-bot/docker` and edit the `.env` file with: - Then go to `nvidia-stock-bot/docker` and edit the `.env` file with:
- Your Discord webhook URL and/or your Telegram bot token and chat ID - Your Discord webhook URL
- The API and product URLs - The API and product URLs
- Stock checking frequency (default: 60s; lowering too much may get your IP blocked by Nvidia) - Stock checking frequency (default: 60s; lowering too much may get your IP blocked by Nvidia)
@@ -157,12 +150,10 @@ Instructions to directly run the Python script. Note: the bot stops when you clo
git clone https://git.djeex.fr/Djeex/nvidia-stock-bot.git git clone https://git.djeex.fr/Djeex/nvidia-stock-bot.git
``` ```
- Navigate to `nvidia-stock-bot` and create a virtual environment (e.g., `python3 -m venv env_name`) - Navigate to `nvidia-stock-bot` and create a virtual environment (e.g., `python3 -m venv env_name`)
- Export the environment variables with your webhook and/or Telegram settings and refresh time, for example: - Export the environment variables with your webhook and refresh time, for exemple:
```sh ```sh
export DISCORD_WEBHOOK_URL="https://your_discord_url" # optional export DISCORD_WEBHOOK_URL="https://your_discord_url"
export TELEGRAM_BOT_TOKEN="123456:ABC-DEF" # optional
export TELEGRAM_CHAT_ID="123456789" # optional
export COUNTRY=US export COUNTRY=US
export PRODUCT_NAMES=RTX 5080, RTX 5090 export PRODUCT_NAMES=RTX 5080, RTX 5090
export DISCORD_ROLES=<@&12345>, <@&6789> export DISCORD_ROLES=<@&12345>, <@&6789>
@@ -177,42 +168,6 @@ export PYTHONUNBUFFERED=1
python nvidia-stock-bot.py python nvidia-stock-bot.py
``` ```
## 📨 Notification channels
Discord and Telegram are both optional and independent: configure one, both or none. The bot never stops because a channel is missing. For each channel that is not configured, a warning is written in the logs at startup:
```
[WARNING] ⚠️ DISCORD IS NOT CONFIGURED: no Discord notification will be sent.
[WARNING] ⚠️ TELEGRAM IS NOT CONFIGURED: no Telegram notification will be sent.
[WARNING] 🚨 NO NOTIFICATION CHANNEL CONFIGURED: the bot will run but will not alert you!
```
**Discord**
Set `DISCORD_WEBHOOK_URL` (and optionally `DISCORD_ROLES` and `DISCORD_SERVER_NAME`).
**Telegram**
1. Create a bot with [@BotFather](https://t.me/BotFather) and copy its token (`TELEGRAM_BOT_TOKEN`).
2. Send a message to the bot, or add it to your group / channel (as administrator for a channel). Otherwise Telegram rejects the messages.
3. Get your chat ID (`TELEGRAM_CHAT_ID`), for example by opening `https://api.telegram.org/bot<TOKEN>/getUpdates` after writing to the bot. Group and channel IDs are negative (e.g. `-1001234567890`).
4. Set both `TELEGRAM_BOT_TOKEN` and `TELEGRAM_CHAT_ID`. If only one of them is set, Telegram is disabled and a warning is logged.
`DISCORD_SERVER_NAME` is also used in the footer of Telegram messages. Discord roles (`DISCORD_ROLES`) have no effect on Telegram.
**Testing the notifications**
`TEST_MODE=true` disables all sending, so it can't be used to check a channel. To send real test messages without touching the Nvidia API, call the notifier from the running container (keep `TEST_MODE` to `False`):
```sh
docker exec nvidia-stock-bot python -c "
import notifier as n
u = 'https://marketplace.nvidia.com'
n.send_telegram_notification('RTX 5090', u, '1999')
n.send_discord_notification('RTX 5090', u, '1999')
"
```
## 🐞 Common issues ## 🐞 Common issues
Error when trying to reach product API url : Error when trying to reach product API url :
@@ -220,11 +175,6 @@ Error when trying to reach product API url :
- Your IP may be blacklisted by nvidia. Try to use a VPN. - Your IP may be blacklisted by nvidia. Try to use a VPN.
- nvidia API may be down - nvidia API may be down
No Telegram message received:
- Check the logs: the Telegram API error (e.g. `chat not found`, `Forbidden`) is displayed there
- The bot must have received a message from you, or be a member of the group / channel
- `TELEGRAM_BOT_TOKEN` and `TELEGRAM_CHAT_ID` must both be set
## ❓ How it works ## ❓ How it works
<div align="center" > <div align="center" >
+1 -1
View File
@@ -1 +1 @@
4.2.0 4.1.5
+6 -33
View File
@@ -25,11 +25,9 @@ logging.info("=" * 60)
# Env variables # Env variables
try: try:
DISCORD_WEBHOOK_URL = (os.environ.get("DISCORD_WEBHOOK_URL") or "").strip() DISCORD_WEBHOOK_URL = os.environ["DISCORD_WEBHOOK_URL"]
DISCORD_SERVER_NAME = os.environ.get("DISCORD_SERVER_NAME", "Shared for free") DISCORD_SERVER_NAME = os.environ.get("DISCORD_SERVER_NAME", "Shared for free")
DISCORD_ROLES = os.environ.get("DISCORD_ROLES") DISCORD_ROLES = os.environ.get("DISCORD_ROLES")
TELEGRAM_BOT_TOKEN = (os.environ.get("TELEGRAM_BOT_TOKEN") or "").strip()
TELEGRAM_CHAT_ID = (os.environ.get("TELEGRAM_CHAT_ID") or "").strip()
COUNTRY = os.environ.get("COUNTRY") or "US" COUNTRY = os.environ.get("COUNTRY") or "US"
REFRESH_TIME = int(os.environ.get("REFRESH_TIME") or 30) REFRESH_TIME = int(os.environ.get("REFRESH_TIME") or 30)
TEST_MODE = os.environ.get("TEST_MODE", "False").lower() == "true" TEST_MODE = os.environ.get("TEST_MODE", "False").lower() == "true"
@@ -49,34 +47,15 @@ if TEST_MODE:
if not PRODUCT_NAMES: if not PRODUCT_NAMES:
logging.error("❌ PRODUCT_NAMES is required but not defined.") logging.error("❌ PRODUCT_NAMES is required but not defined.")
sys.exit(1) sys.exit(1)
if not DISCORD_WEBHOOK_URL:
# Notification channels: each one is optional, but at least one must be configured logging.error("❌ DISCORD_WEBHOOK_URL is required but not defined.")
if bool(TELEGRAM_BOT_TOKEN) != bool(TELEGRAM_CHAT_ID): sys.exit(1)
logging.warning(
"⚠️ TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID must both be defined. Telegram is disabled."
)
TELEGRAM_BOT_TOKEN = TELEGRAM_CHAT_ID = ""
DISCORD_ENABLED = bool(DISCORD_WEBHOOK_URL)
TELEGRAM_ENABLED = bool(TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID)
if not DISCORD_ENABLED:
logging.warning("⚠️ DISCORD IS NOT CONFIGURED: no Discord notification will be sent.")
if not TELEGRAM_ENABLED:
logging.warning("⚠️ TELEGRAM IS NOT CONFIGURED: no Telegram notification will be sent.")
if not DISCORD_ENABLED and not TELEGRAM_ENABLED:
logging.warning(
"🚨 NO NOTIFICATION CHANNEL CONFIGURED: the bot will run but will not alert you! "
"Define DISCORD_WEBHOOK_URL and/or TELEGRAM_BOT_TOKEN + TELEGRAM_CHAT_ID."
)
PRODUCT_NAMES = [name.strip() for name in PRODUCT_NAMES.split(",")] PRODUCT_NAMES = [name.strip() for name in PRODUCT_NAMES.split(",")]
# Role mapping # Role mapping
DISCORD_ROLE_MAP = {} DISCORD_ROLE_MAP = {}
if not DISCORD_ENABLED: if not DISCORD_ROLES or not DISCORD_ROLES.strip():
pass
elif not DISCORD_ROLES or not DISCORD_ROLES.strip():
logging.warning("⚠️ DISCORD_ROLES not defined or empty. Defaulting all roles to @everyone.") logging.warning("⚠️ DISCORD_ROLES not defined or empty. Defaulting all roles to @everyone.")
for name in PRODUCT_NAMES: for name in PRODUCT_NAMES:
DISCORD_ROLE_MAP[name] = "@everyone" DISCORD_ROLE_MAP[name] = "@everyone"
@@ -93,9 +72,7 @@ else:
# Masked webhook in terminal # Masked webhook in terminal
match = re.search(r"/(\d+)/(.*)", DISCORD_WEBHOOK_URL) match = re.search(r"/(\d+)/(.*)", DISCORD_WEBHOOK_URL)
if not DISCORD_ENABLED: if match:
wh_masked_url = "[Disabled]"
elif match:
webhook_id = match.group(1) webhook_id = match.group(1)
webhook_token = match.group(2) webhook_token = match.group(2)
masked_webhook_id = webhook_id[: len(webhook_id) - 10] + "*" * 10 masked_webhook_id = webhook_id[: len(webhook_id) - 10] + "*" * 10
@@ -221,10 +198,6 @@ imminent_drop = loc["imminent_drop"]
logging.info(f"GPU: {PRODUCT_NAMES}") logging.info(f"GPU: {PRODUCT_NAMES}")
logging.info(f"Discord Webhook URL: {wh_masked_url}") logging.info(f"Discord Webhook URL: {wh_masked_url}")
logging.info(f"Discord Role Mention: {DISCORD_ROLES}") logging.info(f"Discord Role Mention: {DISCORD_ROLES}")
logging.info(
"Telegram: %s",
f"enabled (chat {TELEGRAM_CHAT_ID})" if TELEGRAM_ENABLED else "[Disabled]",
)
logging.info(f"API URL SKU: {API_URL_SKU}") logging.info(f"API URL SKU: {API_URL_SKU}")
logging.info(f"API URL Stock: {API_URL_STOCK}") logging.info(f"API URL Stock: {API_URL_STOCK}")
logging.info(f"Product URL: {PRODUCT_URL}") logging.info(f"Product URL: {PRODUCT_URL}")
-10
View File
@@ -9,9 +9,6 @@ from notifier import (
send_discord_notification, send_discord_notification,
send_out_of_stock_notification, send_out_of_stock_notification,
send_sku_change_notification, send_sku_change_notification,
send_telegram_notification,
send_telegram_out_of_stock_notification,
send_telegram_sku_change_notification,
) )
# HTTP session # HTTP session
@@ -67,9 +64,6 @@ def check_rtx_50_founders():
if old_sku and old_sku != product_sku and not first_run_dict[product_name]: if old_sku and old_sku != product_sku and not first_run_dict[product_name]:
logging.warning(f"⚠️ SKU changed for {product_name}: {old_sku} → {product_sku}") logging.warning(f"⚠️ SKU changed for {product_name}: {old_sku} → {product_sku}")
send_sku_change_notification(product_name, old_sku, product_sku, PRODUCT_URL) send_sku_change_notification(product_name, old_sku, product_sku, PRODUCT_URL)
send_telegram_sku_change_notification(
product_name, old_sku, product_sku, PRODUCT_URL
)
last_sku_dict[product_name] = product_sku last_sku_dict[product_name] = product_sku
first_run_dict[product_name] = False first_run_dict[product_name] = False
@@ -115,14 +109,10 @@ def check_rtx_50_founders():
if currently_in_stock and not previously_in_stock: if currently_in_stock and not previously_in_stock:
send_discord_notification(product_name, PRODUCT_URL, products_price) send_discord_notification(product_name, PRODUCT_URL, products_price)
send_telegram_notification(product_name, PRODUCT_URL, products_price)
global_stock_status_dict[(product_name, upc_upper)] = True global_stock_status_dict[(product_name, upc_upper)] = True
logging.info(f"[{product_name}] {upc} is now in stock!") logging.info(f"[{product_name}] {upc} is now in stock!")
elif not currently_in_stock and previously_in_stock: elif not currently_in_stock and previously_in_stock:
send_out_of_stock_notification(product_name, PRODUCT_URL, products_price) send_out_of_stock_notification(product_name, PRODUCT_URL, products_price)
send_telegram_out_of_stock_notification(
product_name, PRODUCT_URL, products_price
)
global_stock_status_dict[(product_name, upc_upper)] = False global_stock_status_dict[(product_name, upc_upper)] = False
logging.info(f"[{product_name}] {upc} is now out of stock.") logging.info(f"[{product_name}] {upc} is now out of stock.")
elif currently_in_stock: elif currently_in_stock:
-108
View File
@@ -1,18 +1,12 @@
import html
import logging import logging
import re
import time import time
import requests import requests
from env_config import ( from env_config import (
DISCORD_ENABLED,
DISCORD_ROLE_MAP, DISCORD_ROLE_MAP,
DISCORD_SERVER_NAME, DISCORD_SERVER_NAME,
DISCORD_WEBHOOK_URL, DISCORD_WEBHOOK_URL,
TELEGRAM_BOT_TOKEN,
TELEGRAM_CHAT_ID,
TELEGRAM_ENABLED,
TEST_MODE, TEST_MODE,
buy_now, buy_now,
currency, currency,
@@ -30,27 +24,8 @@ AVATAR = "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img
THUMBNAIL = "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg" THUMBNAIL = "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg"
_MD_LINK = re.compile(r"\[([^\]]*)\]\(([^)\s]*)\)")
_MD_BOLD = re.compile(r"\*\*(.+?)\*\*")
_MD_CODE = re.compile(r"`(.+?)`")
_EMOJI_SHORTCODES = {":point_right:": "👉"}
def _md_to_telegram_html(text):
"""Convert the Discord markdown of the translations to Telegram HTML."""
text = html.escape(text)
text = _MD_LINK.sub(lambda m: f'<a href="{m.group(2)}">{m.group(1)}</a>', text)
text = _MD_BOLD.sub(lambda m: f"<b>{m.group(1)}</b>", text)
text = _MD_CODE.sub(lambda m: f"<code>{m.group(1)}</code>", text)
for shortcode, emoji in _EMOJI_SHORTCODES.items():
text = text.replace(shortcode, emoji)
return text
# In stock # In stock
def send_discord_notification(gpu_name, product_link, products_price): def send_discord_notification(gpu_name, product_link, products_price):
if not DISCORD_ENABLED:
return
timestamp = int(time.time()) timestamp = int(time.time())
if TEST_MODE: if TEST_MODE:
logging.info(f"[TEST MODE] Notification: {gpu_name} available!") logging.info(f"[TEST MODE] Notification: {gpu_name} available!")
@@ -91,8 +66,6 @@ def send_discord_notification(gpu_name, product_link, products_price):
# Out of stock # Out of stock
def send_out_of_stock_notification(gpu_name, product_link, products_price): def send_out_of_stock_notification(gpu_name, product_link, products_price):
if not DISCORD_ENABLED:
return
timestamp = int(time.time()) timestamp = int(time.time())
if TEST_MODE: if TEST_MODE:
logging.info(f"[TEST MODE] Out of stock: {gpu_name}") logging.info(f"[TEST MODE] Out of stock: {gpu_name}")
@@ -127,8 +100,6 @@ def send_out_of_stock_notification(gpu_name, product_link, products_price):
# SKU change # SKU change
def send_sku_change_notification(gpu_name, old_sku, new_sku, product_link): def send_sku_change_notification(gpu_name, old_sku, new_sku, product_link):
if not DISCORD_ENABLED:
return
timestamp = int(time.time()) timestamp = int(time.time())
if TEST_MODE: if TEST_MODE:
logging.info(f"[TEST MODE] SKU change: {old_sku} → {new_sku}") logging.info(f"[TEST MODE] SKU change: {old_sku} → {new_sku}")
@@ -163,82 +134,3 @@ def send_sku_change_notification(gpu_name, old_sku, new_sku, product_link):
logging.error(f"❌ Webhook error: {response.status_code} - {response.text}") logging.error(f"❌ Webhook error: {response.status_code} - {response.text}")
except Exception as e: except Exception as e:
logging.error(f"🚨 Error sending webhook: {e}") logging.error(f"🚨 Error sending webhook: {e}")
# Telegram
def _send_telegram(text, success_log):
if TEST_MODE:
logging.info(f"[TEST MODE] Telegram message: {text}")
return
url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
payload = {
"chat_id": TELEGRAM_CHAT_ID,
"text": text,
"parse_mode": "HTML",
"disable_web_page_preview": True,
}
try:
response = requests.post(url, json=payload, timeout=10)
if response.status_code == 200:
logging.info(success_log)
else:
logging.error(f"❌ Telegram error: {response.status_code} - {response.text}")
except Exception as e:
# The exception message may contain the bot token (it is part of the URL)
logging.error(f"🚨 Error sending Telegram message: {type(e).__name__}")
def _telegram_footer():
return html.escape(footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME))
def _telegram_time():
return html.escape(time.strftime("%Y-%m-%d %H:%M:%S %Z"))
def send_telegram_notification(gpu_name, product_link, products_price):
if not TELEGRAM_ENABLED:
return
title = html.escape(in_stock_title.format(gpu_name=gpu_name))
description = _md_to_telegram_html(buy_now.format(product_link=product_link))
price = html.escape(f"{currency}{products_price}")
text = (
f"<b>{title}</b>\n"
f"{description}\n\n"
f"{html.escape(price_label)}: <code>{price}</code>\n"
f"{html.escape(time_label)}: {_telegram_time()}\n\n"
f"<i>{_telegram_footer()}</i>"
)
_send_telegram(text, "✅ Notification sent to Telegram.")
def send_telegram_out_of_stock_notification(gpu_name, product_link, products_price):
if not TELEGRAM_ENABLED:
return
title = html.escape(out_of_stock_title.format(gpu_name=gpu_name))
text = (
f'<b><a href="{html.escape(product_link)}">{title}</a></b>\n'
f"{html.escape(time_label)}: {_telegram_time()}\n\n"
f"<i>{_telegram_footer()}</i>"
)
_send_telegram(text, "✅ Out-of-stock notification sent to Telegram.")
def send_telegram_sku_change_notification(gpu_name, old_sku, new_sku, product_link):
if not TELEGRAM_ENABLED:
return
alert = html.escape(imminent_drop.format(DISCORD_ROLE="").strip())
title = html.escape(sku_change_title.format(gpu_name=gpu_name))
description = _md_to_telegram_html(
sku_description.format(old_sku=old_sku, new_sku=new_sku)
)
text = (
f"{alert}\n"
f'<b><a href="{html.escape(product_link)}">{title}</a></b>\n'
f"{description}\n"
f"{html.escape(time_label)}: {_telegram_time()}\n\n"
f"<i>{_telegram_footer()}</i>"
)
_send_telegram(text, "✅ SKU change notification sent to Telegram.")
+1 -3
View File
@@ -1,5 +1,3 @@
PRODUCT_NAMES= # Exact GPU name (e.g. "RTX 5080, RTX 5090") PRODUCT_NAMES= # Exact GPU name (e.g. "RTX 5080, RTX 5090")
DISCORD_WEBHOOK_URL= # Your Discord webhook URL (optional) DISCORD_WEBHOOK_URL= # Your Discord webhook URL
TELEGRAM_BOT_TOKEN= # Your Telegram bot token (optional)
TELEGRAM_CHAT_ID= # Your Telegram chat ID (optional)
COUNTRY= # Set your country (e.g. 'US') COUNTRY= # Set your country (e.g. 'US')
-2
View File
@@ -9,7 +9,5 @@ services:
# Minimal environment variables # Minimal environment variables
- PRODUCT_NAMES=${PRODUCT_NAMES} - PRODUCT_NAMES=${PRODUCT_NAMES}
- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL} - DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}
- TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN}
- TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID}
- COUNTRY=${COUNTRY} - COUNTRY=${COUNTRY}
- PYTHONUNBUFFERED=1 - PYTHONUNBUFFERED=1
+1 -26
View File
@@ -1,29 +1,4 @@
{ {
"$schema": "https://docs.renovatebot.com/renovate-schema.json", "$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"], "extends": ["local>labeex/renovateex"]
"timezone": "Europe/Paris",
"labels": ["bot"],
"vulnerabilityAlerts": {
"addLabels": ["bug"]
},
"packageRules": [
{
"matchManagers": ["pip_requirements"],
"matchUpdateTypes": ["patch", "minor"],
"automerge": true
},
{
"matchManagers": ["dockerfile"],
"matchUpdateTypes": ["patch"],
"automerge": true
},
{
"matchUpdateTypes": ["major"],
"addLabels": ["major"]
},
{
"matchUpdateTypes": ["minor"],
"addLabels": ["minor"]
}
]
} }
+3 -24
View File
@@ -11,8 +11,6 @@ ENV_KEYS = [
"DISCORD_WEBHOOK_URL", "DISCORD_WEBHOOK_URL",
"DISCORD_SERVER_NAME", "DISCORD_SERVER_NAME",
"DISCORD_ROLES", "DISCORD_ROLES",
"TELEGRAM_BOT_TOKEN",
"TELEGRAM_CHAT_ID",
"COUNTRY", "COUNTRY",
"REFRESH_TIME", "REFRESH_TIME",
"TEST_MODE", "TEST_MODE",
@@ -29,28 +27,9 @@ def _reload_env_config(monkeypatch, env):
return importlib.import_module(MODULE_NAME) return importlib.import_module(MODULE_NAME)
def test_no_notification_channel_does_not_exit(monkeypatch, caplog): def test_missing_webhook_exits(monkeypatch):
cfg = _reload_env_config(monkeypatch, {"PRODUCT_NAMES": "RTX 5090"}) with pytest.raises(SystemExit):
assert not cfg.DISCORD_ENABLED _reload_env_config(monkeypatch, {"PRODUCT_NAMES": "RTX 5090"})
assert not cfg.TELEGRAM_ENABLED
assert "DISCORD IS NOT CONFIGURED" in caplog.text
assert "TELEGRAM IS NOT CONFIGURED" in caplog.text
def test_telegram_only_is_enabled(monkeypatch):
cfg = _reload_env_config(
monkeypatch,
{"PRODUCT_NAMES": "RTX 5090", "TELEGRAM_BOT_TOKEN": "123:abc", "TELEGRAM_CHAT_ID": "-100"},
)
assert cfg.TELEGRAM_ENABLED
assert not cfg.DISCORD_ENABLED
def test_telegram_partial_config_is_disabled(monkeypatch):
cfg = _reload_env_config(
monkeypatch, {"PRODUCT_NAMES": "RTX 5090", "TELEGRAM_BOT_TOKEN": "123:abc"}
)
assert not cfg.TELEGRAM_ENABLED
def test_missing_product_names_exits(monkeypatch): def test_missing_product_names_exits(monkeypatch):
+1 -75
View File
@@ -4,13 +4,10 @@ import sys
VALID_WEBHOOK = "https://discord.com/api/webhooks/123456789012345678/abcdef" VALID_WEBHOOK = "https://discord.com/api/webhooks/123456789012345678/abcdef"
def _import_notifier(monkeypatch, test_mode="False", discord_roles=None, keep_discord=True): def _import_notifier(monkeypatch, test_mode="False", discord_roles=None):
if keep_discord:
monkeypatch.setenv("DISCORD_WEBHOOK_URL", VALID_WEBHOOK) monkeypatch.setenv("DISCORD_WEBHOOK_URL", VALID_WEBHOOK)
monkeypatch.setenv("PRODUCT_NAMES", "RTX 5090 Founders Edition") monkeypatch.setenv("PRODUCT_NAMES", "RTX 5090 Founders Edition")
monkeypatch.setenv("TEST_MODE", test_mode) monkeypatch.setenv("TEST_MODE", test_mode)
if not keep_discord:
monkeypatch.delenv("DISCORD_WEBHOOK_URL", raising=False)
if discord_roles is not None: if discord_roles is not None:
monkeypatch.setenv("DISCORD_ROLES", discord_roles) monkeypatch.setenv("DISCORD_ROLES", discord_roles)
else: else:
@@ -188,74 +185,3 @@ def test_sku_change_notification_mentions_role_and_skus(monkeypatch):
description = captured["json"]["embeds"][0]["description"] description = captured["json"]["embeds"][0]["description"]
assert "old-sku-123" in description assert "old-sku-123" in description
assert "new-sku-456" in description assert "new-sku-456" in description
def _import_telegram_notifier(monkeypatch, with_discord=False):
if not with_discord:
monkeypatch.delenv("DISCORD_WEBHOOK_URL", raising=False)
monkeypatch.setenv("TELEGRAM_BOT_TOKEN", "123:abc")
monkeypatch.setenv("TELEGRAM_CHAT_ID", "-100123")
return _import_notifier(monkeypatch, test_mode="False", keep_discord=with_discord)
def test_telegram_in_stock_posts_to_bot_api(monkeypatch):
notifier = _import_telegram_notifier(monkeypatch)
captured = {}
def fake_post(url, json=None, **kwargs):
captured["url"] = url
captured["json"] = json
return FakeResponse(status_code=200)
monkeypatch.setattr(notifier.requests, "post", fake_post)
notifier.send_telegram_notification("RTX 5090 Founders Edition", "https://example.com/buy", "1999")
assert captured["url"] == "https://api.telegram.org/bot123:abc/sendMessage"
assert captured["json"]["chat_id"] == "-100123"
assert "RTX 5090 Founders Edition" in captured["json"]["text"]
assert "https://example.com/buy" in captured["json"]["text"]
def test_telegram_disabled_sends_nothing(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
calls = []
monkeypatch.setattr(notifier.requests, "post", lambda *a, **k: calls.append(a))
notifier.send_telegram_notification("RTX 5090 Founders Edition", "https://example.com", "1999")
notifier.send_telegram_out_of_stock_notification("RTX 5090", "https://example.com", "1999")
notifier.send_telegram_sku_change_notification("RTX 5090", "a", "b", "https://example.com")
assert calls == []
def test_discord_disabled_sends_nothing(monkeypatch):
notifier = _import_telegram_notifier(monkeypatch)
calls = []
monkeypatch.setattr(notifier.requests, "post", lambda *a, **k: calls.append(a))
notifier.send_discord_notification("RTX 5090 Founders Edition", "https://example.com", "1999")
assert calls == []
def test_telegram_error_does_not_leak_token_or_raise(monkeypatch, caplog):
notifier = _import_telegram_notifier(monkeypatch)
def raise_error(*a, **k):
raise notifier.requests.exceptions.ConnectionError("https://api.telegram.org/bot123:abc/")
monkeypatch.setattr(notifier.requests, "post", raise_error)
notifier.send_telegram_out_of_stock_notification("RTX 5090", "https://example.com", "1999")
assert "123:abc" not in caplog.text
def test_telegram_sku_change_and_http_error(monkeypatch):
notifier = _import_telegram_notifier(monkeypatch)
monkeypatch.setattr(
notifier.requests, "post", lambda *a, **k: FakeResponse(status_code=400, text="bad")
)
notifier.send_telegram_sku_change_notification("RTX 5090", "old", "new", "https://example.com")