Skip to content

Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.

feat: add zizmor (static security analysis for gha), socket fireflow and improved security of gha workflows (#229)

Vlad Sazonau2d262c1a8676
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index 360d4da..94b37cf 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -24,11 +24,21 @@ jobs:
env:
TZ: Europe/Warsaw # we use Europe/Warsaw timezone for consistent date handling across local machines and CI
steps:
- - run: |
- echo "Environment URL - ${{ github.event_name == 'deployment_status' && github.event.deployment_status.environment_url }}"
+ - name: Echo environment URL
+ env:
+ ENVIRONMENT_URL: ${{ github.event_name == 'deployment_status' && github.event.deployment_status.environment_url }}
+ run: |
+ echo "Environment URL - $ENVIRONMENT_URL"
# we use pinned versions because there are safer to use: https://x.com/paulmillr/status/1900948425325031448
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
name: πŸ›ŽοΈ Checkout repository
+ with:
+ persist-credentials: false
+
+ - uses: SocketDev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
+ name: πŸ”’ Setup Socket Firewall
+ with:
+ mode: firewall-free
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
name: πŸ“¦ Setup pnpm
@@ -39,7 +49,7 @@ jobs:
node-version: lts/*
- name: 🚚 Install dependencies
- run: pnpm install
+ run: sfw pnpm install # firewall to block malicious packages from being installed https://docs.socket.dev/docs/socket-firewall-overview
- name: πŸ“¦ Install Playwright browser binaries & OS dependencies
run: pnpm exec playwright install chromium webkit --with-deps
@@ -67,11 +77,14 @@ jobs:
id: pr-url
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPOSITORY: ${{ github.repository }}
+ GH_REPOSITORY_OWNER: ${{ github.repository_owner }}
+ GH_REF_NAME: ${{ github.ref_name }}
run: |
PR_URL=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
- "https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}" \
+ "https://api.github.com/repos/$GH_REPOSITORY/pulls?head=$GH_REPOSITORY_OWNER:$GH_REF_NAME" \
| jq -r '.[0].html_url // empty')
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/knip.yml b/.github/workflows/knip.yml
index 3998c48..2583314 100644
--- a/.github/workflows/knip.yml
+++ b/.github/workflows/knip.yml
@@ -18,6 +18,13 @@ jobs:
# we use pinned versions because there are safer to use: https://x.com/paulmillr/status/1900948425325031448
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
name: πŸ›ŽοΈ Checkout repository
+ with:
+ persist-credentials: false
+
+ - uses: SocketDev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
+ name: πŸ”’ Setup Socket Firewall
+ with:
+ mode: firewall-free
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
name: πŸ“¦ Setup pnpm
@@ -28,7 +35,7 @@ jobs:
node-version: lts/*
- name: 🚚 Install dependencies
- run: pnpm install
+ run: sfw pnpm install # firewall to block malicious packages from being installed https://docs.socket.dev/docs/socket-firewall-overview
- name: πŸ”Ž Run Knip
id: knip
@@ -40,11 +47,14 @@ jobs:
id: pr-url
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPOSITORY: ${{ github.repository }}
+ GH_REPOSITORY_OWNER: ${{ github.repository_owner }}
+ GH_REF_NAME: ${{ github.ref_name }}
run: |
PR_URL=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
- "https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}" \
+ "https://api.github.com/repos/$GH_REPOSITORY/pulls?head=$GH_REPOSITORY_OWNER:$GH_REF_NAME" \
| jq -r '.[0].html_url // empty')
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index a26bf16..4eaf4f7 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -18,6 +18,13 @@ jobs:
# we use pinned versions because there are safer to use: https://x.com/paulmillr/status/1900948425325031448
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
name: πŸ›ŽοΈ Checkout repository
+ with:
+ persist-credentials: false
+
+ - uses: SocketDev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
+ name: πŸ”’ Setup Socket Firewall
+ with:
+ mode: firewall-free
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
name: πŸ“¦ Setup pnpm
@@ -28,7 +35,7 @@ jobs:
node-version: lts/*
- name: 🚚 Install dependencies
- run: pnpm install
+ run: sfw pnpm install # firewall to block malicious packages from being installed https://docs.socket.dev/docs/socket-firewall-overview
- name: πŸ”Ž Run linting
id: lint
@@ -40,11 +47,14 @@ jobs:
id: pr-url
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPOSITORY: ${{ github.repository }}
+ GH_REPOSITORY_OWNER: ${{ github.repository_owner }}
+ GH_REF_NAME: ${{ github.ref_name }}
run: |
PR_URL=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
- "https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}" \
+ "https://api.github.com/repos/$GH_REPOSITORY/pulls?head=$GH_REPOSITORY_OWNER:$GH_REF_NAME" \
| jq -r '.[0].html_url // empty')
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/monthly-recurring-invoice.yml b/.github/workflows/monthly-recurring-invoice.yml
index 3d237ea..5204ff3 100644
--- a/.github/workflows/monthly-recurring-invoice.yml
+++ b/.github/workflows/monthly-recurring-invoice.yml
@@ -17,6 +17,7 @@ on:
jobs:
recurring-invoice:
runs-on: ubuntu-latest
+ permissions: {}
timeout-minutes: 10 # we set a timeout to 5 minutes to avoid the workflow running indefinitely
env:
TZ: Europe/Warsaw # we use Europe/Warsaw timezone for consistent date handling across local machines and CI
@@ -100,10 +101,11 @@ jobs:
echo "$output" >> $GITHUB_OUTPUT
- name: Send date-check notification to Telegram
+ env:
+ WEEKDAY: ${{ steps.date-check.outputs.weekday }}
+ TARGET_DAY: ${{ steps.date-check.outputs.target_day }}
+ SHOULD_RUN: ${{ steps.date-check.outputs.should_run }}
run: |
- WEEKDAY=${{ steps.date-check.outputs.weekday }}
- TARGET_DAY=${{ steps.date-check.outputs.target_day }}
- SHOULD_RUN=${{ steps.date-check.outputs.should_run }}
WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
NOW="$(date '+%d.%m.%Y %H:%M:%S %Z')"
BILLING_PERIOD="$(date '+%B %Y')"
diff --git a/.github/workflows/type-check.yml b/.github/workflows/type-check.yml
index f500531..ddc09f0 100644
--- a/.github/workflows/type-check.yml
+++ b/.github/workflows/type-check.yml
@@ -18,6 +18,13 @@ jobs:
# we use pinned versions because there are safer to use: https://x.com/paulmillr/status/1900948425325031448
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
name: πŸ›ŽοΈ Checkout repository
+ with:
+ persist-credentials: false
+
+ - uses: SocketDev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
+ name: πŸ”’ Setup Socket Firewall
+ with:
+ mode: firewall-free
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
name: πŸ“¦ Setup pnpm
@@ -28,7 +35,7 @@ jobs:
node-version: lts/*
- name: 🚚 Install dependencies
- run: pnpm install
+ run: sfw pnpm install # firewall to block malicious packages from being installed https://docs.socket.dev/docs/socket-firewall-overview
- name: πŸ” Run type check
id: type-check
@@ -40,11 +47,14 @@ jobs:
id: pr-url
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPOSITORY: ${{ github.repository }}
+ GH_REPOSITORY_OWNER: ${{ github.repository_owner }}
+ GH_REF_NAME: ${{ github.ref_name }}
run: |
PR_URL=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
- "https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}" \
+ "https://api.github.com/repos/$GH_REPOSITORY/pulls?head=$GH_REPOSITORY_OWNER:$GH_REF_NAME" \
| jq -r '.[0].html_url // empty')
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index cb00c11..67673ca 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -18,6 +18,13 @@ jobs:
# we use pinned versions because there are safer to use: https://x.com/paulmillr/status/1900948425325031448
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
name: πŸ›ŽοΈ Checkout repository
+ with:
+ persist-credentials: false
+
+ - uses: SocketDev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
+ name: πŸ”’ Setup Socket Firewall
+ with:
+ mode: firewall-free
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
name: πŸ“¦ Setup pnpm
@@ -28,7 +35,7 @@ jobs:
node-version: lts/*
- name: 🚚 Install dependencies
- run: pnpm install
+ run: sfw pnpm install # firewall to block malicious packages from being installed https://docs.socket.dev/docs/socket-firewall-overview
- name: πŸ§ͺ Run Vitest tests
id: vitest
@@ -40,11 +47,14 @@ jobs:
id: pr-url
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPOSITORY: ${{ github.repository }}
+ GH_REPOSITORY_OWNER: ${{ github.repository_owner }}
+ GH_REF_NAME: ${{ github.ref_name }}
run: |
PR_URL=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
- "https://api.github.com/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ github.ref_name }}" \
+ "https://api.github.com/repos/$GH_REPOSITORY/pulls?head=$GH_REPOSITORY_OWNER:$GH_REF_NAME" \
| jq -r '.[0].html_url // empty')
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml
new file mode 100644
index 0000000..a4d2212
--- /dev/null
+++ b/.github/workflows/zizmor.yml
@@ -0,0 +1,71 @@
+name: πŸ”’ zizmor static analysis tool for GitHub Actions # https://docs.zizmor.sh/
+on:
+ push:
+ branches: [main]
+ pull_request:
+ branches: ["**"]
+
+permissions: {}
+
+jobs:
+ zizmor:
+ name: Run zizmor static analysis tool for GitHub Actions
+ timeout-minutes: 5
+ runs-on: ubuntu-latest
+ permissions:
+ security-events: write # Required for upload-sarif to upload SARIF files.
+ contents: read
+ actions: read # Needed for upload-sarif to read workflow run info.
+ steps:
+ # we use pinned versions because there are safer to use: https://x.com/paulmillr/status/1900948425325031448
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ name: πŸ›ŽοΈ Checkout repository
+ with:
+ persist-credentials: false
+
+ - name: πŸ”Ž Run zizmor
+ id: zizmor
+ continue-on-error: true
+ # https://github.com/zizmorcore/zizmor-action
+ uses: zizmorcore/zizmor-action@b1d7e1fb5de872772f31590499237e7cce841e8e # v0.5.3
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: πŸ” Get PR URL
+ if: steps.zizmor.outcome == 'failure'
+ id: pr-url
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPOSITORY: ${{ github.repository }}
+ GH_REPOSITORY_OWNER: ${{ github.repository_owner }}
+ GH_REF_NAME: ${{ github.ref_name }}
+ run: |
+ PR_URL=$(curl -s \
+ -H "Authorization: Bearer $GITHUB_TOKEN" \
+ -H "Accept: application/vnd.github+json" \
+ "https://api.github.com/repos/$GH_REPOSITORY/pulls?head=$GH_REPOSITORY_OWNER:$GH_REF_NAME" \
+ | jq -r '.[0].html_url // empty')
+ echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
+
+ - name: πŸ“§ Send email
+ if: steps.zizmor.outcome == 'failure'
+ # https://github.com/dawidd6/action-send-mail
+ uses: dawidd6/action-send-mail@d38f3f7cd391cdebfe0d38efc3998b935e951c4f # v16
+ with:
+ server_address: smtp.gmail.com
+ server_port: 587
+ from: "GitHub Actions (no-reply) <${{ secrets.EMAIL_USERNAME }}>"
+ to: ${{ secrets.EMAIL_USERNAME }}
+ username: ${{ secrets.EMAIL_USERNAME }}
+ password: ${{ secrets.EMAIL_PASSWORD }}
+ subject: ❌ zizmor Failed for ${{ github.repository }}
+ body: |
+ zizmor security analysis for ${{ github.repository }} has failed.
+
+ For more details, please check:
+ - GitHub Actions run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
+ ${{ steps.pr-url.outputs.pr_url && format('- Pull Request: {0}', steps.pr-url.outputs.pr_url) }}
+
+ - name: ❌ Mark workflow failed on zizmor failure
+ if: steps.zizmor.outcome == 'failure'
+ run: exit 1
diff --git a/KNOWLEDGE-BASE.md b/KNOWLEDGE-BASE.md
new file mode 100644
index 0000000..b37764c
--- /dev/null
+++ b/KNOWLEDGE-BASE.md
@@ -0,0 +1,23 @@
+useful stuff:
+
+- https://github.com/karlhorky/playwright-tricks?tab=readme-ov-file#screenshot-comparison-tests-of-pdfs
+
+react-pdf/renderer quirks:
+
+- https://github.com/diegomura/react-pdf/issues/774#issuecomment-560069810 (Preventing other elements from crashing into a fixed footer)
+
+react-pdf quirks (non-desktop pdf viewer):
+
+- https://github.com/wojtekmaj/react-pdf/issues/1824
+
+issues to follow:
+
+- https://github.com/microsoft/playwright/issues/13873
+- https://github.com/microsoft/playwright/issues/19253
+- https://github.com/wojtekmaj/react-pdf/issues/2026
+
+---
+
+To create GIFs for README.md, you can use:
+
+- https://www.freeconvert.com/mov-to-gif (set width to 1200px and Compression to 1)
diff --git a/README.md b/README.md
index 8489628..56e9f48 100644
--- a/README.md
+++ b/README.md
@@ -199,7 +199,7 @@ Built by [Vlad Sazonau](https://x.com/vladsazonau)
If you find EasyInvoicePDF useful, please consider:
- ⭐ **Star this repository** on GitHub to show your support
-- β˜• [Buy me a coffee](https://buymeacoffee.com/vladsazon) to support the [creator](https://vladsazon.com)
+- β˜• [Buy me a coffee](https://buymeacoffee.com/vladsazon) to support the [creator of the project](https://vladsazon.com)
Your support helps keep this project free and open-source πŸ™
@@ -221,6 +221,7 @@ Your support helps keep this project free and open-source πŸ™
- Analytics: https://umami.is/
- [typescript-plugin-directives](https://www.npmjs.com/package/typescript-plugin-directives)
- [Create Mockups with shots.so](https://shots.so/)
+- zizmor (static analysis tool for GitHub Actions): https://docs.zizmor.sh/
<h2 id="self-host">Quick Start</h2>
diff --git a/TODO.md b/TODO.md
index a50d065..d26af53 100644
--- a/TODO.md
+++ b/TODO.md
@@ -7,18 +7,10 @@ DISCOUNTS FEATURE:
- when discount is applied, in tax column + tax summary table we should show (total amount - discount amount), check stripe example image below
- think about design for default template (check default template example image below)
-example:
-![Per-item default template discount example](..wip/discount-invoice-default-example.png)
-
-example:
-![Per-item stripe template discount example](..wip/discount-invoice-stripe-example.png)
-
---
- [ ] when adding invoice item, generate unique id for the item and store in local storage (should be backward compatible with existing invoice items)
-- [] on mobile, when switching between tabs, scroll to the last position of the invoice form section for better UX
-
- [ ] add unit test for next js api routes (for generate-invoice route)
- [ ] run playwright tests in docker, add local docker UBUNTU setup and re-use docker setup on ci
@@ -33,27 +25,3 @@ IMPORTANT:
etc:
- [ ] Double check if we need to save to local storage in the page.client.tsx (line: 235)
-
-useful stuff:
-
-- https://github.com/karlhorky/playwright-tricks?tab=readme-ov-file#screenshot-comparison-tests-of-pdfs
-
-react-pdf/renderer quirks:
-
-- https://github.com/diegomura/react-pdf/issues/774#issuecomment-560069810 (Preventing other elements from crashing into a fixed footer)
-
-react-pdf quirks (non-desktop pdf viewer):
-
-- https://github.com/wojtekmaj/react-pdf/issues/1824
-
-issues to follow:
-
-- https://github.com/microsoft/playwright/issues/13873
-- https://github.com/microsoft/playwright/issues/19253
-- https://github.com/wojtekmaj/react-pdf/issues/2026
-
----
-
-To create GIFs for README.md, you can use:
-
-- https://www.freeconvert.com/mov-to-gif (set width to 1200px and Compression to 1)
diff --git a/knip.ts b/knip.ts
index 1b62e98..9de7bed 100644
--- a/knip.ts
+++ b/knip.ts
@@ -30,7 +30,7 @@ const config: KnipConfig = {
// ignore tags
// https://knip.dev/reference/configuration#tags
tags: ["-@lintignore"],
- ignoreBinaries: ["act"],
+ ignoreBinaries: ["act", "zizmor"],
};
export default config;
diff --git a/lint-staged.config.js b/lint-staged.config.js
index a8c267a..f78de0b 100644
--- a/lint-staged.config.js
+++ b/lint-staged.config.js
@@ -4,6 +4,7 @@ module.exports = {
"*": () => [
`pnpm run type-check:go`,
`pnpm run lint`,
+ `zizmor .github/`, // zizmor is used to check the security of the GitHub Actions workflows https://docs.zizmor.sh/
`pnpm run knip`,
`pnpm run prettify --write`,
],