Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eafe68e58 |
@@ -1,75 +0,0 @@
|
|||||||
# Node modules and build artifacts
|
|
||||||
node_modules
|
|
||||||
frontend/node_modules
|
|
||||||
frontend/dist
|
|
||||||
frontend/build
|
|
||||||
frontend/.vite
|
|
||||||
frontend/.tauri
|
|
||||||
frontend/src-tauri/target
|
|
||||||
|
|
||||||
# Gradle build artifacts
|
|
||||||
.gradle
|
|
||||||
build
|
|
||||||
bin
|
|
||||||
target
|
|
||||||
out
|
|
||||||
|
|
||||||
# Git
|
|
||||||
.git
|
|
||||||
.gitignore
|
|
||||||
|
|
||||||
# IDE
|
|
||||||
.vscode
|
|
||||||
.idea
|
|
||||||
*.iml
|
|
||||||
*.iws
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
# Logs
|
|
||||||
*.log
|
|
||||||
logs
|
|
||||||
|
|
||||||
# Environment files
|
|
||||||
.env
|
|
||||||
.env.*
|
|
||||||
!.env.example
|
|
||||||
|
|
||||||
# OS files
|
|
||||||
.DS_Store
|
|
||||||
Thumbs.db
|
|
||||||
|
|
||||||
# Java compiled files
|
|
||||||
*.class
|
|
||||||
*.jar
|
|
||||||
*.war
|
|
||||||
*.ear
|
|
||||||
|
|
||||||
# Test reports
|
|
||||||
test-results
|
|
||||||
coverage
|
|
||||||
|
|
||||||
# Docker
|
|
||||||
docker-compose.override.yml
|
|
||||||
.dockerignore
|
|
||||||
|
|
||||||
# Temporary files
|
|
||||||
tmp
|
|
||||||
temp
|
|
||||||
*.tmp
|
|
||||||
*.swp
|
|
||||||
*~
|
|
||||||
|
|
||||||
# Runtime database and config files (locked by running app)
|
|
||||||
app/core/configs/**
|
|
||||||
stirling/**
|
|
||||||
stirling-pdf-DB*.mv.db
|
|
||||||
stirling-pdf-DB*.trace.db
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
*.md
|
|
||||||
!README.md
|
|
||||||
docs
|
|
||||||
|
|
||||||
# CI/CD
|
|
||||||
.github
|
|
||||||
.gitlab-ci.yml
|
|
||||||
+8
-5
@@ -2,17 +2,20 @@
|
|||||||
* @Frooodle @Ludy87 @jbrunton96 @ConnorYoh
|
* @Frooodle @Ludy87 @jbrunton96 @ConnorYoh
|
||||||
|
|
||||||
# Backend
|
# Backend
|
||||||
/app/** @DarioGii @Frooodle @Ludy87 @jbrunton96 @ConnorYoh @balazs-szucs
|
/app/** @DarioGii @Frooodle @Ludy87 @jbrunton96 @ConnorYoh
|
||||||
|
|
||||||
|
#V1 frontend
|
||||||
|
/app/core/src/main/resources/static/** @reecebrowne @ConnorYoh @EthanHealy01 @jbrunton96 @Frooodle @Ludy87
|
||||||
|
/app/core/src/main/resources/templates/** @reecebrowne @ConnorYoh @EthanHealy01 @jbrunton96 @Frooodle @Ludy87
|
||||||
|
|
||||||
#V2 frontend
|
#V2 frontend
|
||||||
/frontend/** @reecebrowne @ConnorYoh @EthanHealy01 @jbrunton96 @Frooodle @balazs-szucs
|
/frontend/** @reecebrowne @ConnorYoh @EthanHealy01 @jbrunton96 @Frooodle
|
||||||
/app/core/src/main/resources/static/** @reecebrowne @ConnorYoh @EthanHealy01 @jbrunton96 @Frooodle @Ludy87 @balazs-szucs
|
|
||||||
|
|
||||||
#V2 docker
|
#V2 docker
|
||||||
/docker/backend/** @Frooodle @Ludy87 @DarioGii
|
/docker/backend/** @Frooodle @Ludy87 @DarioGii @Ludy87
|
||||||
/docker/frontend/** @reecebrowne @ConnorYoh @EthanHealy01 @jbrunton96 @Frooodle @Ludy87
|
/docker/frontend/** @reecebrowne @ConnorYoh @EthanHealy01 @jbrunton96 @Frooodle @Ludy87
|
||||||
/docker/compose/** @reecebrowne @ConnorYoh @EthanHealy01 @DarioGii @jbrunton96 @Frooodle @Ludy87
|
/docker/compose/** @reecebrowne @ConnorYoh @EthanHealy01 @DarioGii @jbrunton96 @Frooodle @Ludy87
|
||||||
|
|
||||||
|
|
||||||
#GHA (All users)
|
#GHA (All users)
|
||||||
/.github/** @reecebrowne @ConnorYoh @EthanHealy01 @DarioGii @jbrunton96 @Frooodle @Ludy87 @balazs-szucs
|
/.github/** @reecebrowne @ConnorYoh @EthanHealy01 @DarioGii @jbrunton96 @Frooodle @Ludy87
|
||||||
|
|||||||
+12
-41
@@ -2,28 +2,26 @@ build: &build
|
|||||||
- build.gradle
|
- build.gradle
|
||||||
- app/(common|core|proprietary)/build.gradle
|
- app/(common|core|proprietary)/build.gradle
|
||||||
|
|
||||||
openapi: &openapi
|
app: &app
|
||||||
- *build
|
|
||||||
- app/(common|core|proprietary)/src/main/java/**
|
- app/(common|core|proprietary)/src/main/java/**
|
||||||
|
|
||||||
docker: &docker
|
openapi: &openapi
|
||||||
- Dockerfile
|
- build.gradle
|
||||||
- Dockerfile.fat
|
- app/(common|core|proprietary)/build.gradle
|
||||||
- Dockerfile.ultra-lite
|
- app/(common|core|proprietary)/src/main/java/**
|
||||||
- ".github/workflows/build.yml"
|
|
||||||
- scripts/init.sh
|
|
||||||
- scripts/init-without-ocr.sh
|
|
||||||
- exampleYmlFiles/**
|
|
||||||
|
|
||||||
project: &project
|
project: &project
|
||||||
- app/(common|core|proprietary)/src/(main|test)/java/**
|
- app/(common|core|proprietary)/src/(main|test)/java/**
|
||||||
- *build
|
- app/(common|core|proprietary)/build.gradle
|
||||||
- "app/(common|core|proprietary)/src/(main|test)/resources/**/!(messages_*.properties|*.md)*"
|
- 'app/(common|core|proprietary)/src/(main|test)/resources/**/!(messages_*.properties|*.md)*'
|
||||||
- exampleYmlFiles/**
|
- exampleYmlFiles/**
|
||||||
- gradle/**
|
- gradle/**
|
||||||
- libs/**
|
- libs/**
|
||||||
- "testing/**/!(requirements*.txt|requirements*.in)*"
|
- testing/**
|
||||||
- *docker
|
- build.gradle
|
||||||
|
- Dockerfile
|
||||||
|
- Dockerfile.fat
|
||||||
|
- Dockerfile.ultra-lite
|
||||||
- gradle.properties
|
- gradle.properties
|
||||||
- gradlew
|
- gradlew
|
||||||
- gradlew.bat
|
- gradlew.bat
|
||||||
@@ -31,30 +29,3 @@ project: &project
|
|||||||
- settings.gradle
|
- settings.gradle
|
||||||
- frontend/**
|
- frontend/**
|
||||||
- docker/**
|
- docker/**
|
||||||
- scripts/RestartHelper.java
|
|
||||||
|
|
||||||
frontend: &frontend
|
|
||||||
- frontend/**
|
|
||||||
- .github/workflows/testdriver.yml
|
|
||||||
- testing/**
|
|
||||||
- docker/**
|
|
||||||
- scripts/translations/*.py
|
|
||||||
- scripts/build-tauri-jlink.bat
|
|
||||||
- scripts/build-tauri-jlink.sh
|
|
||||||
- scripts/convert_cff_to_ttf.py
|
|
||||||
- scripts/harvest_type3_fonts.py
|
|
||||||
- scripts/ignore_translation.toml
|
|
||||||
- scripts/index_type3_catalogue.py
|
|
||||||
- scripts/summarize_type3_signatures.py
|
|
||||||
- scripts/type3_to_cff.py
|
|
||||||
- scripts/update_type3_library.py
|
|
||||||
|
|
||||||
licenses-frontend: &licenses-frontend
|
|
||||||
- ".github/workflows/frontend-backend-licenses-update.yml"
|
|
||||||
- "frontend/package.json"
|
|
||||||
- "frontend/package-lock.json"
|
|
||||||
- "frontend/scripts/generate-licenses.js"
|
|
||||||
|
|
||||||
licenses-backend: &licenses-backend
|
|
||||||
- ".github/workflows/frontend-backend-licenses-update.yml"
|
|
||||||
- *build
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
allow-ghsas: GHSA-wrw7-89jp-8q8g
|
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
{
|
{
|
||||||
"label_changer": [
|
|
||||||
"Frooodle",
|
|
||||||
"Ludy87",
|
|
||||||
"balazs-szucs"
|
|
||||||
],
|
|
||||||
"repo_devs": [
|
"repo_devs": [
|
||||||
"Frooodle",
|
"Frooodle",
|
||||||
"sf298",
|
"sf298",
|
||||||
@@ -13,8 +8,6 @@
|
|||||||
"reecebrowne",
|
"reecebrowne",
|
||||||
"DarioGii",
|
"DarioGii",
|
||||||
"ConnorYoh",
|
"ConnorYoh",
|
||||||
"EthanHealy01",
|
"EthanHealy01"
|
||||||
"jbrunton96",
|
|
||||||
"balazs-szucs"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-49
@@ -6,65 +6,18 @@
|
|||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: "gradle" # See documentation for possible values
|
- package-ecosystem: "gradle" # See documentation for possible values
|
||||||
directories:
|
directory: "/" # Location of package manifests
|
||||||
- "/" # Location of package manifests
|
|
||||||
- "/app/common"
|
|
||||||
- "/app/core"
|
|
||||||
- "/app/proprietary"
|
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
rebase-strategy: "auto"
|
rebase-strategy: "auto"
|
||||||
|
|
||||||
- package-ecosystem: "docker"
|
- package-ecosystem: "docker"
|
||||||
directory: "/" # Location of Dockerfile
|
directory: "/" # Location of Dockerfile
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
rebase-strategy: "auto"
|
|
||||||
|
|
||||||
- package-ecosystem: github-actions
|
- package-ecosystem: github-actions
|
||||||
directory: /
|
directory: /
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
rebase-strategy: "auto"
|
|
||||||
|
|
||||||
- package-ecosystem: npm
|
|
||||||
directory: /devTools
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
rebase-strategy: "auto"
|
|
||||||
|
|
||||||
- package-ecosystem: docker
|
|
||||||
directory: /docker/backend
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
rebase-strategy: "auto"
|
|
||||||
|
|
||||||
- package-ecosystem: docker
|
|
||||||
directory: /docker/embedded
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
rebase-strategy: "auto"
|
|
||||||
|
|
||||||
- package-ecosystem: docker
|
|
||||||
directory: /docker/frontend
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
rebase-strategy: "auto"
|
|
||||||
|
|
||||||
- package-ecosystem: npm
|
|
||||||
directory: /frontend
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
rebase-strategy: "auto"
|
|
||||||
|
|
||||||
- package-ecosystem: cargo
|
|
||||||
directory: /frontend/src-tauri
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
rebase-strategy: "auto"
|
|
||||||
|
|
||||||
- package-ecosystem: pip
|
|
||||||
directory: /testing/cucumber
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
rebase-strategy: "auto"
|
|
||||||
|
|||||||
@@ -46,31 +46,26 @@ labels:
|
|||||||
- label: 'API'
|
- label: 'API'
|
||||||
title: '.*openapi.*|.*swagger.*|.*api.*'
|
title: '.*openapi.*|.*swagger.*|.*api.*'
|
||||||
|
|
||||||
- label: 'v3'
|
- label: 'v2'
|
||||||
base-branch: 'V3'
|
base-branch: 'V2'
|
||||||
|
|
||||||
- label: 'Translation'
|
- label: 'Translation'
|
||||||
files:
|
files:
|
||||||
- 'frontend/public/locales/[a-zA-Z]{2}-[a-zA-Z\-]{2,7}/translation.toml'
|
- 'app/core/src/main/resources/messages_[a-zA-Z_]{2}_[a-zA-Z_]{2,7}.properties'
|
||||||
- 'scripts/ignore_translation.toml'
|
- 'scripts/ignore_translation.toml'
|
||||||
- 'scripts/remove_translation_keys.sh'
|
- 'app/core/src/main/resources/templates/fragments/languages.html'
|
||||||
- 'scripts/replace_translation_line.sh'
|
- '.github/scripts/check_language_properties.py'
|
||||||
- 'scripts/translations/.*'
|
|
||||||
- '.github/scripts/check_language_toml.py'
|
|
||||||
- 'scripts/counter_translation_v3.py'
|
|
||||||
|
|
||||||
- label: 'Front End'
|
- label: 'Front End'
|
||||||
files:
|
files:
|
||||||
|
- 'app/core/src/main/resources/templates/.*'
|
||||||
|
- 'app/proprietary/src/main/resources/templates/.*'
|
||||||
- 'app/core/src/main/resources/static/.*'
|
- 'app/core/src/main/resources/static/.*'
|
||||||
- 'app/proprietary/src/main/resources/static/.*'
|
- 'app/proprietary/src/main/resources/static/.*'
|
||||||
|
- 'app/core/src/main/java/stirling/software/SPDF/controller/web/.*'
|
||||||
|
- 'app/core/src/main/java/stirling/software/SPDF/UI/.*'
|
||||||
|
- 'app/proprietary/src/main/java/stirling/software/proprietary/security/controller/web/.*'
|
||||||
- 'frontend/**'
|
- 'frontend/**'
|
||||||
- 'frontend/.*'
|
|
||||||
- 'frontend/**/.*'
|
|
||||||
|
|
||||||
- label: 'Tauri'
|
|
||||||
files:
|
|
||||||
- 'frontend/src-tauri/**'
|
|
||||||
- 'frontend/src-tauri/.*'
|
|
||||||
|
|
||||||
- label: 'Java'
|
- label: 'Java'
|
||||||
files:
|
files:
|
||||||
|
|||||||
@@ -84,9 +84,6 @@
|
|||||||
- name: "v2"
|
- name: "v2"
|
||||||
color: "FFFF00"
|
color: "FFFF00"
|
||||||
description: "Issues or pull requests related to the v2 branch"
|
description: "Issues or pull requests related to the v2 branch"
|
||||||
- name: "v3"
|
|
||||||
color: "FFA500"
|
|
||||||
description: "Issues or pull requests related to the v3 branch"
|
|
||||||
- name: "wontfix"
|
- name: "wontfix"
|
||||||
description: "This will not be worked on"
|
description: "This will not be worked on"
|
||||||
color: "FFFFFF"
|
color: "FFFFFF"
|
||||||
@@ -187,17 +184,3 @@
|
|||||||
- name: "codex"
|
- name: "codex"
|
||||||
color: "ededed"
|
color: "ededed"
|
||||||
description: "chatgpt AI generated code"
|
description: "chatgpt AI generated code"
|
||||||
- name: "break-change"
|
|
||||||
color: "FF0000"
|
|
||||||
description: "This PR introduces a breaking API change."
|
|
||||||
- name: "Rust"
|
|
||||||
color: "DEA584"
|
|
||||||
description: "Pull requests that update Rust code"
|
|
||||||
from_name: "rust"
|
|
||||||
- name: "Tauri"
|
|
||||||
color: "24C8FF"
|
|
||||||
description: "Pull requests that update Tauri code"
|
|
||||||
from_name: "tauri"
|
|
||||||
- name: "license-review-required"
|
|
||||||
color: "EDEDED"
|
|
||||||
description: "This PR requires a license review"
|
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ Closes #(issue_number)
|
|||||||
- [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed)
|
- [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed)
|
||||||
- [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only)
|
- [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only)
|
||||||
|
|
||||||
### Translations (if applicable)
|
|
||||||
|
|
||||||
- [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)
|
|
||||||
|
|
||||||
### UI Changes (if applicable)
|
### UI Changes (if applicable)
|
||||||
|
|
||||||
- [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR)
|
- [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR)
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
changelog:
|
changelog:
|
||||||
categories:
|
categories:
|
||||||
- title: Breaking Changes
|
|
||||||
labels:
|
|
||||||
- break-change
|
|
||||||
|
|
||||||
- title: Bug Fixes
|
- title: Bug Fixes
|
||||||
labels:
|
labels:
|
||||||
- Bug
|
- Bug
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
Author: Ludy87
|
Author: Ludy87
|
||||||
Description: This script processes TOML translation files for localization checks. It compares translation files in a branch with
|
Description: This script processes JSON translation files for localization checks. It compares translation files in a branch with
|
||||||
a reference file to ensure consistency. The script performs two main checks:
|
a reference file to ensure consistency. The script performs two main checks:
|
||||||
1. Verifies that the number of translation keys in the translation files matches the reference file.
|
1. Verifies that the number of translation keys in the translation files matches the reference file.
|
||||||
2. Ensures that all keys in the translation files are present in the reference file and vice versa.
|
2. Ensures that all keys in the translation files are present in the reference file and vice versa.
|
||||||
@@ -9,26 +9,23 @@ The script also provides functionality to update the translation files to match
|
|||||||
adjusting the format.
|
adjusting the format.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
python check_language_toml.py --reference-file <path_to_reference_file> --branch <branch_name> [--actor <actor_name>] [--files <list_of_changed_files>]
|
python check_language_json.py --reference-file <path_to_reference_file> --branch <branch_name> [--actor <actor_name>] [--files <list_of_changed_files>]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Sample for Windows:
|
# Sample for Windows:
|
||||||
# python .github/scripts/check_language_toml.py --reference-file frontend/public/locales/en-GB/translation.toml --branch "" --files frontend/public/locales/de-DE/translation.toml frontend/public/locales/fr-FR/translation.toml
|
# python .github/scripts/check_language_json.py --reference-file frontend/public/locales/en-GB/translation.json --branch "" --files frontend/public/locales/de-DE/translation.json frontend/public/locales/fr-FR/translation.json
|
||||||
|
|
||||||
import argparse
|
import copy
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
import argparse
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
import json
|
||||||
|
|
||||||
import tomllib # Python 3.11+ (stdlib)
|
|
||||||
import tomli_w # For writing TOML files
|
|
||||||
|
|
||||||
|
|
||||||
def find_duplicate_keys(file_path, keys=None, prefix=""):
|
def find_duplicate_keys(file_path, keys=None, prefix=""):
|
||||||
"""
|
"""
|
||||||
Identifies duplicate keys in a TOML file (including nested keys).
|
Identifies duplicate keys in a JSON file (including nested keys).
|
||||||
:param file_path: Path to the TOML file.
|
:param file_path: Path to the JSON file.
|
||||||
:param keys: Dictionary to track keys (used for recursion).
|
:param keys: Dictionary to track keys (used for recursion).
|
||||||
:param prefix: Prefix for nested keys.
|
:param prefix: Prefix for nested keys.
|
||||||
:return: List of tuples (key, first_occurrence_path, duplicate_path).
|
:return: List of tuples (key, first_occurrence_path, duplicate_path).
|
||||||
@@ -38,10 +35,8 @@ def find_duplicate_keys(file_path, keys=None, prefix=""):
|
|||||||
|
|
||||||
duplicates = []
|
duplicates = []
|
||||||
|
|
||||||
# Load TOML file
|
with open(file_path, "r", encoding="utf-8") as file:
|
||||||
file_path = Path(file_path)
|
data = json.load(file)
|
||||||
with file_path.open("rb") as file:
|
|
||||||
data = tomllib.load(file)
|
|
||||||
|
|
||||||
def process_dict(obj, current_prefix=""):
|
def process_dict(obj, current_prefix=""):
|
||||||
for key, value in obj.items():
|
for key, value in obj.items():
|
||||||
@@ -59,19 +54,18 @@ def find_duplicate_keys(file_path, keys=None, prefix=""):
|
|||||||
return duplicates
|
return duplicates
|
||||||
|
|
||||||
|
|
||||||
# Maximum size for TOML files (e.g., 570 KB)
|
# Maximum size for JSON files (e.g., 500 KB)
|
||||||
MAX_FILE_SIZE = 570 * 1024
|
MAX_FILE_SIZE = 500 * 1024
|
||||||
|
|
||||||
|
|
||||||
def parse_toml_file(file_path):
|
def parse_json_file(file_path):
|
||||||
"""
|
"""
|
||||||
Parses a TOML translation file and returns a flat dictionary of all keys.
|
Parses a JSON translation file and returns a flat dictionary of all keys.
|
||||||
:param file_path: Path to the TOML file.
|
:param file_path: Path to the JSON file.
|
||||||
:return: Dictionary with flattened keys.
|
:return: Dictionary with flattened keys.
|
||||||
"""
|
"""
|
||||||
file_path = Path(file_path)
|
with open(file_path, "r", encoding="utf-8") as file:
|
||||||
with file_path.open("rb") as file:
|
data = json.load(file)
|
||||||
data = tomllib.load(file)
|
|
||||||
|
|
||||||
def flatten_dict(d, parent_key="", sep="."):
|
def flatten_dict(d, parent_key="", sep="."):
|
||||||
items = {}
|
items = {}
|
||||||
@@ -105,43 +99,38 @@ def unflatten_dict(d, sep="."):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def write_toml_file(file_path, updated_properties):
|
def write_json_file(file_path, updated_properties):
|
||||||
"""
|
"""
|
||||||
Writes updated properties back to the TOML file.
|
Writes updated properties back to the JSON file.
|
||||||
:param file_path: Path to the TOML file.
|
:param file_path: Path to the JSON file.
|
||||||
:param updated_properties: Dictionary of updated properties to write.
|
:param updated_properties: Dictionary of updated properties to write.
|
||||||
"""
|
"""
|
||||||
nested_data = unflatten_dict(updated_properties)
|
nested_data = unflatten_dict(updated_properties)
|
||||||
|
|
||||||
file_path = Path(file_path)
|
with open(file_path, "w", encoding="utf-8", newline="\n") as file:
|
||||||
with file_path.open("wb") as file:
|
json.dump(nested_data, file, ensure_ascii=False, indent=2)
|
||||||
tomli_w.dump(nested_data, file)
|
file.write("\n") # Add trailing newline
|
||||||
|
|
||||||
|
|
||||||
def update_missing_keys(reference_file, file_list, branch=""):
|
def update_missing_keys(reference_file, file_list, branch=""):
|
||||||
"""
|
"""
|
||||||
Updates missing keys in the translation files based on the reference file.
|
Updates missing keys in the translation files based on the reference file.
|
||||||
:param reference_file: Path to the reference TOML file.
|
:param reference_file: Path to the reference JSON file.
|
||||||
:param file_list: List of translation files to update.
|
:param file_list: List of translation files to update.
|
||||||
:param branch: Branch where the files are located.
|
:param branch: Branch where the files are located.
|
||||||
"""
|
"""
|
||||||
reference_file = Path(reference_file)
|
reference_properties = parse_json_file(reference_file)
|
||||||
reference_properties = parse_toml_file(reference_file)
|
|
||||||
branch_path = Path(branch) if branch else Path()
|
|
||||||
|
|
||||||
for file_path in file_list:
|
for file_path in file_list:
|
||||||
file_path = Path(file_path)
|
basename_current_file = os.path.basename(os.path.join(branch, file_path))
|
||||||
language_dir = file_path.parent.name
|
|
||||||
reference_lang_dir = reference_file.parent.name
|
|
||||||
if (
|
if (
|
||||||
language_dir == reference_lang_dir
|
basename_current_file == os.path.basename(reference_file)
|
||||||
or file_path.suffix != ".toml"
|
or not file_path.endswith(".json")
|
||||||
or file_path.parents[1].name != "locales"
|
or not os.path.dirname(file_path).endswith("locales")
|
||||||
):
|
):
|
||||||
print(f"Skipping file: {file_path}")
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
current_properties = parse_toml_file(branch_path / file_path)
|
current_properties = parse_json_file(os.path.join(branch, file_path))
|
||||||
updated_properties = {}
|
updated_properties = {}
|
||||||
|
|
||||||
for ref_key, ref_value in reference_properties.items():
|
for ref_key, ref_value in reference_properties.items():
|
||||||
@@ -152,29 +141,26 @@ def update_missing_keys(reference_file, file_list, branch=""):
|
|||||||
# Add missing key with reference value
|
# Add missing key with reference value
|
||||||
updated_properties[ref_key] = ref_value
|
updated_properties[ref_key] = ref_value
|
||||||
|
|
||||||
write_toml_file(branch_path / file_path, updated_properties)
|
write_json_file(os.path.join(branch, file_path), updated_properties)
|
||||||
|
|
||||||
|
|
||||||
def check_for_missing_keys(reference_file, file_list, branch):
|
def check_for_missing_keys(reference_file, file_list, branch):
|
||||||
update_missing_keys(reference_file, file_list, branch)
|
update_missing_keys(reference_file, file_list, branch)
|
||||||
|
|
||||||
|
|
||||||
def read_toml_keys(file_path):
|
def read_json_keys(file_path):
|
||||||
file_path = Path(file_path)
|
if os.path.isfile(file_path) and os.path.exists(file_path):
|
||||||
if file_path.is_file():
|
return parse_json_file(file_path)
|
||||||
return parse_toml_file(file_path)
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def check_for_differences(reference_file, file_list, branch, actor):
|
def check_for_differences(reference_file, file_list, branch, actor):
|
||||||
reference_branch = branch
|
reference_branch = branch
|
||||||
reference_file = Path(reference_file)
|
basename_reference_file = os.path.basename(reference_file)
|
||||||
basename_reference_file = reference_file.name
|
|
||||||
branch_path = Path(branch) if branch else Path()
|
|
||||||
|
|
||||||
report = []
|
report = []
|
||||||
report.append(f"#### 🔄 Reference Branch: `{reference_branch}`")
|
report.append(f"#### 🔄 Reference Branch: `{reference_branch}`")
|
||||||
reference_keys = read_toml_keys(reference_file)
|
reference_keys = read_json_keys(reference_file)
|
||||||
has_differences = False
|
has_differences = False
|
||||||
|
|
||||||
only_reference_file = True
|
only_reference_file = True
|
||||||
@@ -184,44 +170,39 @@ def check_for_differences(reference_file, file_list, branch, actor):
|
|||||||
if len(file_list) == 1:
|
if len(file_list) == 1:
|
||||||
file_arr = file_list[0].split()
|
file_arr = file_list[0].split()
|
||||||
|
|
||||||
base_dir = Path.cwd() / "frontend" / "public" / "locales"
|
base_dir = os.path.abspath(
|
||||||
|
os.path.join(os.getcwd(), "frontend", "public", "locales")
|
||||||
|
)
|
||||||
|
|
||||||
for file_path in file_arr:
|
for file_path in file_arr:
|
||||||
file_path = Path(file_path)
|
file_normpath = os.path.normpath(file_path)
|
||||||
file_normpath = file_path
|
absolute_path = os.path.abspath(file_normpath)
|
||||||
absolute_path = file_normpath.resolve()
|
|
||||||
|
|
||||||
basename_current_file = (branch_path / file_normpath).name
|
|
||||||
locale_dir = file_normpath.parent.name
|
|
||||||
report.append(f"#### 📃 **File Check:** `{locale_dir}/{basename_current_file}`")
|
|
||||||
|
|
||||||
# Verify that file is within the expected directory
|
# Verify that file is within the expected directory
|
||||||
if not absolute_path.is_relative_to(base_dir):
|
if not absolute_path.startswith(base_dir):
|
||||||
has_differences = True
|
raise ValueError(f"Unsafe file found: {file_normpath}")
|
||||||
report.append(
|
|
||||||
f"\n⚠️ Unsafe file found: `{locale_dir}/{basename_current_file}`\n\n---\n"
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Verify file size before processing
|
# Verify file size before processing
|
||||||
if (branch_path / file_normpath).stat().st_size > MAX_FILE_SIZE:
|
if os.path.getsize(os.path.join(branch, file_normpath)) > MAX_FILE_SIZE:
|
||||||
has_differences = True
|
raise ValueError(
|
||||||
report.append(
|
f"The file {file_normpath} is too large and could pose a security risk."
|
||||||
f"\n⚠️ The file `{locale_dir}/{basename_current_file}` is too large and could pose a security risk.\n\n---\n"
|
|
||||||
)
|
)
|
||||||
continue
|
|
||||||
|
|
||||||
if basename_current_file == basename_reference_file and locale_dir == "en-GB":
|
basename_current_file = os.path.basename(os.path.join(branch, file_normpath))
|
||||||
continue
|
locale_dir = os.path.basename(os.path.dirname(file_normpath))
|
||||||
|
|
||||||
if (
|
if (
|
||||||
file_normpath.suffix != ".toml"
|
basename_current_file == basename_reference_file
|
||||||
or basename_current_file != "translation.toml"
|
and locale_dir == "en-GB"
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not file_normpath.endswith(".json") or basename_current_file != "translation.json":
|
||||||
|
continue
|
||||||
|
|
||||||
only_reference_file = False
|
only_reference_file = False
|
||||||
current_keys = read_toml_keys(branch_path / file_path)
|
report.append(f"#### 📃 **File Check:** `{locale_dir}/{basename_current_file}`")
|
||||||
|
current_keys = read_json_keys(os.path.join(branch, file_path))
|
||||||
reference_key_count = len(reference_keys)
|
reference_key_count = len(reference_keys)
|
||||||
current_key_count = len(current_keys)
|
current_key_count = len(current_keys)
|
||||||
|
|
||||||
@@ -266,13 +247,13 @@ def check_for_differences(reference_file, file_list, branch, actor):
|
|||||||
else:
|
else:
|
||||||
report.append("2. **Test Status:** ✅ **_Passed_**")
|
report.append("2. **Test Status:** ✅ **_Passed_**")
|
||||||
|
|
||||||
if find_duplicate_keys(branch_path / file_normpath):
|
if find_duplicate_keys(os.path.join(branch, file_normpath)):
|
||||||
has_differences = True
|
has_differences = True
|
||||||
output = "\n".join(
|
output = "\n".join(
|
||||||
[
|
[
|
||||||
f" - `{key}`: first at {first}, duplicate at `{duplicate}`"
|
f" - `{key}`: first at {first}, duplicate at `{duplicate}`"
|
||||||
for key, first, duplicate in find_duplicate_keys(
|
for key, first, duplicate in find_duplicate_keys(
|
||||||
branch_path / file_normpath
|
os.path.join(branch, file_normpath)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -291,7 +272,7 @@ def check_for_differences(reference_file, file_list, branch, actor):
|
|||||||
report.append("## ❌ Overall Check Status: **_Failed_**")
|
report.append("## ❌ Overall Check Status: **_Failed_**")
|
||||||
report.append("")
|
report.append("")
|
||||||
report.append(
|
report.append(
|
||||||
f"@{actor} please check your translation if it conforms to the standard. Follow the format of [en-GB/translation.toml](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/frontend/public/locales/en-GB/translation.toml)"
|
f"@{actor} please check your translation if it conforms to the standard. Follow the format of [en-GB/translation.json](https://github.com/Stirling-Tools/Stirling-PDF/blob/V2/frontend/public/locales/en-GB/translation.json)"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
report.append("## ✅ Overall Check Status: **_Success_**")
|
report.append("## ✅ Overall Check Status: **_Success_**")
|
||||||
@@ -305,9 +286,7 @@ def check_for_differences(reference_file, file_list, branch, actor):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(description="Find missing keys")
|
||||||
description="Find missing keys in TOML translation files"
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--actor",
|
"--actor",
|
||||||
required=False,
|
required=False,
|
||||||
@@ -358,9 +337,9 @@ if __name__ == "__main__":
|
|||||||
"public",
|
"public",
|
||||||
"locales",
|
"locales",
|
||||||
"*",
|
"*",
|
||||||
"translation.toml",
|
"translation.json",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
update_missing_keys(args.reference_file, file_list)
|
update_missing_keys(args.reference_file, file_list)
|
||||||
else:
|
else:
|
||||||
check_for_differences(args.reference_file, file_list, args.branch, args.actor)
|
check_for_differences(args.reference_file, file_list, args.branch, args.actor)
|
||||||
@@ -0,0 +1,403 @@
|
|||||||
|
"""
|
||||||
|
Author: Ludy87
|
||||||
|
Description: This script processes .properties files for localization checks. It compares translation files in a branch with
|
||||||
|
a reference file to ensure consistency. The script performs two main checks:
|
||||||
|
1. Verifies that the number of lines (including comments and empty lines) in the translation files matches the reference file.
|
||||||
|
2. Ensures that all keys in the translation files are present in the reference file and vice versa.
|
||||||
|
|
||||||
|
The script also provides functionality to update the translation files to match the reference file by adding missing keys and
|
||||||
|
adjusting the format.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python check_language_properties.py --reference-file <path_to_reference_file> --branch <branch_name> [--actor <actor_name>] [--files <list_of_changed_files>]
|
||||||
|
"""
|
||||||
|
# Sample for Windows:
|
||||||
|
# python .github/scripts/check_language_properties.py --reference-file src\main\resources\messages_en_GB.properties --branch "" --files src\main\resources\messages_de_DE.properties src\main\resources\messages_uk_UA.properties
|
||||||
|
|
||||||
|
import copy
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def find_duplicate_keys(file_path):
|
||||||
|
"""
|
||||||
|
Identifies duplicate keys in a .properties file.
|
||||||
|
:param file_path: Path to the .properties file.
|
||||||
|
:return: List of tuples (key, first_occurrence_line, duplicate_line).
|
||||||
|
"""
|
||||||
|
keys = {}
|
||||||
|
duplicates = []
|
||||||
|
|
||||||
|
with open(file_path, "r", encoding="utf-8") as file:
|
||||||
|
for line_number, line in enumerate(file, start=1):
|
||||||
|
stripped_line = line.strip()
|
||||||
|
|
||||||
|
# Skip empty lines and comments
|
||||||
|
if not stripped_line or stripped_line.startswith("#"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Split the line into key and value
|
||||||
|
if "=" in stripped_line:
|
||||||
|
key, _ = stripped_line.split("=", 1)
|
||||||
|
key = key.strip()
|
||||||
|
|
||||||
|
# Check if the key already exists
|
||||||
|
if key in keys:
|
||||||
|
duplicates.append((key, keys[key], line_number))
|
||||||
|
else:
|
||||||
|
keys[key] = line_number
|
||||||
|
|
||||||
|
return duplicates
|
||||||
|
|
||||||
|
|
||||||
|
# Maximum size for properties files (e.g., 200 KB)
|
||||||
|
MAX_FILE_SIZE = 200 * 1024
|
||||||
|
|
||||||
|
|
||||||
|
def parse_properties_file(file_path):
|
||||||
|
"""
|
||||||
|
Parses a .properties file and returns a structured list of its contents.
|
||||||
|
:param file_path: Path to the .properties file.
|
||||||
|
:return: List of dictionaries representing each line in the file.
|
||||||
|
"""
|
||||||
|
properties_list = []
|
||||||
|
with open(file_path, "r", encoding="utf-8") as file:
|
||||||
|
for line_number, line in enumerate(file, start=1):
|
||||||
|
stripped_line = line.strip()
|
||||||
|
|
||||||
|
# Handle empty lines
|
||||||
|
if not stripped_line:
|
||||||
|
properties_list.append(
|
||||||
|
{"line_number": line_number, "type": "empty", "content": ""}
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Handle comments
|
||||||
|
if stripped_line.startswith("#"):
|
||||||
|
properties_list.append(
|
||||||
|
{
|
||||||
|
"line_number": line_number,
|
||||||
|
"type": "comment",
|
||||||
|
"content": stripped_line,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Handle key-value pairs
|
||||||
|
match = re.match(r"^([^=]+)=(.*)$", line)
|
||||||
|
if match:
|
||||||
|
key, value = match.groups()
|
||||||
|
properties_list.append(
|
||||||
|
{
|
||||||
|
"line_number": line_number,
|
||||||
|
"type": "entry",
|
||||||
|
"key": key.strip(),
|
||||||
|
"value": value.strip(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return properties_list
|
||||||
|
|
||||||
|
|
||||||
|
def write_json_file(file_path, updated_properties):
|
||||||
|
"""
|
||||||
|
Writes updated properties back to the file in their original format.
|
||||||
|
:param file_path: Path to the .properties file.
|
||||||
|
:param updated_properties: List of updated properties to write.
|
||||||
|
"""
|
||||||
|
updated_lines = {entry["line_number"]: entry for entry in updated_properties}
|
||||||
|
|
||||||
|
# Sort lines by their numbers and retain comments and empty lines
|
||||||
|
all_lines = sorted(set(updated_lines.keys()))
|
||||||
|
|
||||||
|
original_format = []
|
||||||
|
for line in all_lines:
|
||||||
|
if line in updated_lines:
|
||||||
|
entry = updated_lines[line]
|
||||||
|
else:
|
||||||
|
entry = None
|
||||||
|
ref_entry = updated_lines[line]
|
||||||
|
if ref_entry["type"] in ["comment", "empty"]:
|
||||||
|
original_format.append(ref_entry)
|
||||||
|
elif entry is None:
|
||||||
|
# Add missing entries from the reference file
|
||||||
|
original_format.append(ref_entry)
|
||||||
|
elif entry["type"] == "entry":
|
||||||
|
# Replace entries with those from the current JSON
|
||||||
|
original_format.append(entry)
|
||||||
|
|
||||||
|
# Write the updated content back to the file
|
||||||
|
with open(file_path, "w", encoding="utf-8", newline="\n") as file:
|
||||||
|
for entry in original_format:
|
||||||
|
if entry["type"] == "comment":
|
||||||
|
file.write(f"{entry['content']}\n")
|
||||||
|
elif entry["type"] == "empty":
|
||||||
|
file.write(f"{entry['content']}\n")
|
||||||
|
elif entry["type"] == "entry":
|
||||||
|
file.write(f"{entry['key']}={entry['value']}\n")
|
||||||
|
|
||||||
|
|
||||||
|
def update_missing_keys(reference_file, file_list, branch=""):
|
||||||
|
"""
|
||||||
|
Updates missing keys in the translation files based on the reference file.
|
||||||
|
:param reference_file: Path to the reference .properties file.
|
||||||
|
:param file_list: List of translation files to update.
|
||||||
|
:param branch: Branch where the files are located.
|
||||||
|
"""
|
||||||
|
reference_properties = parse_properties_file(reference_file)
|
||||||
|
for file_path in file_list:
|
||||||
|
basename_current_file = os.path.basename(os.path.join(branch, file_path))
|
||||||
|
if (
|
||||||
|
basename_current_file == os.path.basename(reference_file)
|
||||||
|
or not file_path.endswith(".properties")
|
||||||
|
or not basename_current_file.startswith("messages_")
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
|
||||||
|
current_properties = parse_properties_file(os.path.join(branch, file_path))
|
||||||
|
updated_properties = []
|
||||||
|
for ref_entry in reference_properties:
|
||||||
|
ref_entry_copy = copy.deepcopy(ref_entry)
|
||||||
|
for current_entry in current_properties:
|
||||||
|
if current_entry["type"] == "entry":
|
||||||
|
if ref_entry_copy["type"] != "entry":
|
||||||
|
continue
|
||||||
|
if ref_entry_copy["key"].lower() == current_entry["key"].lower():
|
||||||
|
ref_entry_copy["value"] = current_entry["value"]
|
||||||
|
updated_properties.append(ref_entry_copy)
|
||||||
|
write_json_file(os.path.join(branch, file_path), updated_properties)
|
||||||
|
|
||||||
|
|
||||||
|
def check_for_missing_keys(reference_file, file_list, branch):
|
||||||
|
update_missing_keys(reference_file, file_list, branch)
|
||||||
|
|
||||||
|
|
||||||
|
def read_properties(file_path):
|
||||||
|
if os.path.isfile(file_path) and os.path.exists(file_path):
|
||||||
|
with open(file_path, "r", encoding="utf-8") as file:
|
||||||
|
return file.read().splitlines()
|
||||||
|
return [""]
|
||||||
|
|
||||||
|
|
||||||
|
def check_for_differences(reference_file, file_list, branch, actor):
|
||||||
|
reference_branch = reference_file.split("/")[0]
|
||||||
|
basename_reference_file = os.path.basename(reference_file)
|
||||||
|
|
||||||
|
report = []
|
||||||
|
report.append(f"#### 🔄 Reference Branch: `{reference_branch}`")
|
||||||
|
reference_lines = read_properties(reference_file)
|
||||||
|
has_differences = False
|
||||||
|
|
||||||
|
only_reference_file = True
|
||||||
|
|
||||||
|
file_arr = file_list
|
||||||
|
|
||||||
|
if len(file_list) == 1:
|
||||||
|
file_arr = file_list[0].split()
|
||||||
|
base_dir = os.path.abspath(
|
||||||
|
os.path.join(os.getcwd(), "app", "core", "src", "main", "resources")
|
||||||
|
)
|
||||||
|
|
||||||
|
for file_path in file_arr:
|
||||||
|
file_normpath = os.path.normpath(file_path)
|
||||||
|
absolute_path = os.path.abspath(file_normpath)
|
||||||
|
# Verify that file is within the expected directory
|
||||||
|
if not absolute_path.startswith(base_dir):
|
||||||
|
raise ValueError(f"Unsafe file found: {file_normpath}")
|
||||||
|
# Verify file size before processing
|
||||||
|
if os.path.getsize(os.path.join(branch, file_normpath)) > MAX_FILE_SIZE:
|
||||||
|
raise ValueError(
|
||||||
|
f"The file {file_normpath} is too large and could pose a security risk."
|
||||||
|
)
|
||||||
|
|
||||||
|
basename_current_file = os.path.basename(os.path.join(branch, file_normpath))
|
||||||
|
if (
|
||||||
|
basename_current_file == basename_reference_file
|
||||||
|
or (
|
||||||
|
# only local windows command
|
||||||
|
not file_normpath.startswith(
|
||||||
|
os.path.join(
|
||||||
|
"", "app", "core", "src", "main", "resources", "messages_"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
and not file_normpath.startswith(
|
||||||
|
os.path.join(
|
||||||
|
os.getcwd(),
|
||||||
|
"app",
|
||||||
|
"core",
|
||||||
|
"src",
|
||||||
|
"main",
|
||||||
|
"resources",
|
||||||
|
"messages_",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
or not file_normpath.endswith(".properties")
|
||||||
|
or not basename_current_file.startswith("messages_")
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
only_reference_file = False
|
||||||
|
report.append(f"#### 📃 **File Check:** `{basename_current_file}`")
|
||||||
|
current_lines = read_properties(os.path.join(branch, file_path))
|
||||||
|
reference_line_count = len(reference_lines)
|
||||||
|
current_line_count = len(current_lines)
|
||||||
|
|
||||||
|
if reference_line_count != current_line_count:
|
||||||
|
report.append("")
|
||||||
|
report.append("1. **Test Status:** ❌ **_Failed_**")
|
||||||
|
report.append(" - **Issue:**")
|
||||||
|
has_differences = True
|
||||||
|
if reference_line_count > current_line_count:
|
||||||
|
report.append(
|
||||||
|
f" - **_Mismatched line count_**: {reference_line_count} (reference) vs {current_line_count} (current). Comments, empty lines, or translation strings are missing."
|
||||||
|
)
|
||||||
|
elif reference_line_count < current_line_count:
|
||||||
|
report.append(
|
||||||
|
f" - **_Too many lines_**: {reference_line_count} (reference) vs {current_line_count} (current). Please verify if there is an additional line that needs to be removed."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
report.append("1. **Test Status:** ✅ **_Passed_**")
|
||||||
|
|
||||||
|
# Check for missing or extra keys
|
||||||
|
current_keys = []
|
||||||
|
reference_keys = []
|
||||||
|
for line in current_lines:
|
||||||
|
if not line.startswith("#") and line != "" and "=" in line:
|
||||||
|
key, _ = line.split("=", 1)
|
||||||
|
current_keys.append(key)
|
||||||
|
for line in reference_lines:
|
||||||
|
if not line.startswith("#") and line != "" and "=" in line:
|
||||||
|
key, _ = line.split("=", 1)
|
||||||
|
reference_keys.append(key)
|
||||||
|
|
||||||
|
current_keys_set = set(current_keys)
|
||||||
|
reference_keys_set = set(reference_keys)
|
||||||
|
missing_keys = current_keys_set.difference(reference_keys_set)
|
||||||
|
extra_keys = reference_keys_set.difference(current_keys_set)
|
||||||
|
missing_keys_list = list(missing_keys)
|
||||||
|
extra_keys_list = list(extra_keys)
|
||||||
|
|
||||||
|
if missing_keys_list or extra_keys_list:
|
||||||
|
has_differences = True
|
||||||
|
missing_keys_str = "`, `".join(missing_keys_list)
|
||||||
|
extra_keys_str = "`, `".join(extra_keys_list)
|
||||||
|
report.append("2. **Test Status:** ❌ **_Failed_**")
|
||||||
|
report.append(" - **Issue:**")
|
||||||
|
if missing_keys_list:
|
||||||
|
spaces_keys_list = []
|
||||||
|
for key in missing_keys_list:
|
||||||
|
if " " in key:
|
||||||
|
spaces_keys_list.append(key)
|
||||||
|
if spaces_keys_list:
|
||||||
|
spaces_keys_str = "`, `".join(spaces_keys_list)
|
||||||
|
report.append(
|
||||||
|
f" - **_Keys containing unnecessary spaces_**: `{spaces_keys_str}`!"
|
||||||
|
)
|
||||||
|
report.append(
|
||||||
|
f" - **_Extra keys in `{basename_current_file}`_**: `{missing_keys_str}` that are not present in **_`{basename_reference_file}`_**."
|
||||||
|
)
|
||||||
|
if extra_keys_list:
|
||||||
|
report.append(
|
||||||
|
f" - **_Missing keys in `{basename_reference_file}`_**: `{extra_keys_str}` that are not present in **_`{basename_current_file}`_**."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
report.append("2. **Test Status:** ✅ **_Passed_**")
|
||||||
|
|
||||||
|
if find_duplicate_keys(os.path.join(branch, file_normpath)):
|
||||||
|
has_differences = True
|
||||||
|
output = "\n".join(
|
||||||
|
[
|
||||||
|
f" - `{key}`: first at line {first}, duplicate at `line {duplicate}`"
|
||||||
|
for key, first, duplicate in find_duplicate_keys(
|
||||||
|
os.path.join(branch, file_normpath)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
report.append("3. **Test Status:** ❌ **_Failed_**")
|
||||||
|
report.append(" - **Issue:**")
|
||||||
|
report.append(" - duplicate entries were found:")
|
||||||
|
report.append(output)
|
||||||
|
else:
|
||||||
|
report.append("3. **Test Status:** ✅ **_Passed_**")
|
||||||
|
|
||||||
|
report.append("")
|
||||||
|
report.append("---")
|
||||||
|
report.append("")
|
||||||
|
if has_differences:
|
||||||
|
report.append("## ❌ Overall Check Status: **_Failed_**")
|
||||||
|
report.append("")
|
||||||
|
report.append(
|
||||||
|
f"@{actor} please check your translation if it conforms to the standard. Follow the format of [messages_en_GB.properties](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/app/core/src/main/resources/messages_en_GB.properties)"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
report.append("## ✅ Overall Check Status: **_Success_**")
|
||||||
|
report.append("")
|
||||||
|
report.append(
|
||||||
|
f"Thanks @{actor} for your help in keeping the translations up to date."
|
||||||
|
)
|
||||||
|
|
||||||
|
if not only_reference_file:
|
||||||
|
print("\n".join(report))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser(description="Find missing keys")
|
||||||
|
parser.add_argument(
|
||||||
|
"--actor",
|
||||||
|
required=False,
|
||||||
|
help="Actor from PR.",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--reference-file",
|
||||||
|
required=True,
|
||||||
|
help="Path to the reference file.",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--branch",
|
||||||
|
type=str,
|
||||||
|
required=True,
|
||||||
|
help="Branch name.",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--check-file",
|
||||||
|
type=str,
|
||||||
|
required=False,
|
||||||
|
help="List of changed files, separated by spaces.",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--files",
|
||||||
|
nargs="+",
|
||||||
|
required=False,
|
||||||
|
help="List of changed files, separated by spaces.",
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Sanitize --actor input to avoid injection attacks
|
||||||
|
if args.actor:
|
||||||
|
args.actor = re.sub(r"[^a-zA-Z0-9_\\-]", "", args.actor)
|
||||||
|
|
||||||
|
# Sanitize --branch input to avoid injection attacks
|
||||||
|
if args.branch:
|
||||||
|
args.branch = re.sub(r"[^a-zA-Z0-9\\-]", "", args.branch)
|
||||||
|
|
||||||
|
file_list = args.files
|
||||||
|
if file_list is None:
|
||||||
|
if args.check_file:
|
||||||
|
file_list = [args.check_file]
|
||||||
|
else:
|
||||||
|
file_list = glob.glob(
|
||||||
|
os.path.join(
|
||||||
|
os.getcwd(),
|
||||||
|
"app",
|
||||||
|
"core",
|
||||||
|
"src",
|
||||||
|
"main",
|
||||||
|
"resources",
|
||||||
|
"messages_*.properties",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
update_missing_keys(args.reference_file, file_list)
|
||||||
|
else:
|
||||||
|
check_for_differences(args.reference_file, file_list, args.branch, args.actor)
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
pip
|
|
||||||
setuptools
|
|
||||||
WeasyPrint
|
|
||||||
pdf2image
|
|
||||||
pillow
|
|
||||||
unoserver
|
|
||||||
opencv-python-headless
|
|
||||||
pre-commit
|
|
||||||
brotli @ git+https://github.com/google/brotli.git@028fb5a23661f123017c060daa546b55cf4bde29
|
|
||||||
@@ -1,556 +0,0 @@
|
|||||||
#
|
|
||||||
# This file is autogenerated by pip-compile with Python 3.12
|
|
||||||
# by the following command:
|
|
||||||
#
|
|
||||||
# pip-compile --allow-unsafe --generate-hashes --output-file='.github\scripts\requirements_dev.txt' --strip-extras '.github\scripts\requirements_dev.in'
|
|
||||||
#
|
|
||||||
# WARNING: pip install will require the following package to be hashed.
|
|
||||||
# Consider using a hashable URL like https://github.com/jazzband/pip-tools/archive/SOMECOMMIT.zip
|
|
||||||
# CVE-2025-6176 mitigation: pin brotli to a specific commit
|
|
||||||
brotli @ git+https://github.com/google/brotli.git@028fb5a23661f123017c060daa546b55cf4bde29
|
|
||||||
# via
|
|
||||||
# -r .github/scripts/requirements_dev.in
|
|
||||||
# fonttools
|
|
||||||
cffi==2.0.0 \
|
|
||||||
--hash=sha256:00bdf7acc5f795150faa6957054fbbca2439db2f775ce831222b66f192f03beb \
|
|
||||||
--hash=sha256:07b271772c100085dd28b74fa0cd81c8fb1a3ba18b21e03d7c27f3436a10606b \
|
|
||||||
--hash=sha256:087067fa8953339c723661eda6b54bc98c5625757ea62e95eb4898ad5e776e9f \
|
|
||||||
--hash=sha256:0a1527a803f0a659de1af2e1fd700213caba79377e27e4693648c2923da066f9 \
|
|
||||||
--hash=sha256:0cf2d91ecc3fcc0625c2c530fe004f82c110405f101548512cce44322fa8ac44 \
|
|
||||||
--hash=sha256:0f6084a0ea23d05d20c3edcda20c3d006f9b6f3fefeac38f59262e10cef47ee2 \
|
|
||||||
--hash=sha256:12873ca6cb9b0f0d3a0da705d6086fe911591737a59f28b7936bdfed27c0d47c \
|
|
||||||
--hash=sha256:19f705ada2530c1167abacb171925dd886168931e0a7b78f5bffcae5c6b5be75 \
|
|
||||||
--hash=sha256:1cd13c99ce269b3ed80b417dcd591415d3372bcac067009b6e0f59c7d4015e65 \
|
|
||||||
--hash=sha256:1e3a615586f05fc4065a8b22b8152f0c1b00cdbc60596d187c2a74f9e3036e4e \
|
|
||||||
--hash=sha256:1f72fb8906754ac8a2cc3f9f5aaa298070652a0ffae577e0ea9bd480dc3c931a \
|
|
||||||
--hash=sha256:1fc9ea04857caf665289b7a75923f2c6ed559b8298a1b8c49e59f7dd95c8481e \
|
|
||||||
--hash=sha256:203a48d1fb583fc7d78a4c6655692963b860a417c0528492a6bc21f1aaefab25 \
|
|
||||||
--hash=sha256:2081580ebb843f759b9f617314a24ed5738c51d2aee65d31e02f6f7a2b97707a \
|
|
||||||
--hash=sha256:21d1152871b019407d8ac3985f6775c079416c282e431a4da6afe7aefd2bccbe \
|
|
||||||
--hash=sha256:24b6f81f1983e6df8db3adc38562c83f7d4a0c36162885ec7f7b77c7dcbec97b \
|
|
||||||
--hash=sha256:256f80b80ca3853f90c21b23ee78cd008713787b1b1e93eae9f3d6a7134abd91 \
|
|
||||||
--hash=sha256:28a3a209b96630bca57cce802da70c266eb08c6e97e5afd61a75611ee6c64592 \
|
|
||||||
--hash=sha256:2c8f814d84194c9ea681642fd164267891702542f028a15fc97d4674b6206187 \
|
|
||||||
--hash=sha256:2de9a304e27f7596cd03d16f1b7c72219bd944e99cc52b84d0145aefb07cbd3c \
|
|
||||||
--hash=sha256:38100abb9d1b1435bc4cc340bb4489635dc2f0da7456590877030c9b3d40b0c1 \
|
|
||||||
--hash=sha256:3925dd22fa2b7699ed2617149842d2e6adde22b262fcbfada50e3d195e4b3a94 \
|
|
||||||
--hash=sha256:3e17ed538242334bf70832644a32a7aae3d83b57567f9fd60a26257e992b79ba \
|
|
||||||
--hash=sha256:3e837e369566884707ddaf85fc1744b47575005c0a229de3327f8f9a20f4efeb \
|
|
||||||
--hash=sha256:3f4d46d8b35698056ec29bca21546e1551a205058ae1a181d871e278b0b28165 \
|
|
||||||
--hash=sha256:44d1b5909021139fe36001ae048dbdde8214afa20200eda0f64c068cac5d5529 \
|
|
||||||
--hash=sha256:45d5e886156860dc35862657e1494b9bae8dfa63bf56796f2fb56e1679fc0bca \
|
|
||||||
--hash=sha256:4647afc2f90d1ddd33441e5b0e85b16b12ddec4fca55f0d9671fef036ecca27c \
|
|
||||||
--hash=sha256:4671d9dd5ec934cb9a73e7ee9676f9362aba54f7f34910956b84d727b0d73fb6 \
|
|
||||||
--hash=sha256:53f77cbe57044e88bbd5ed26ac1d0514d2acf0591dd6bb02a3ae37f76811b80c \
|
|
||||||
--hash=sha256:5eda85d6d1879e692d546a078b44251cdd08dd1cfb98dfb77b670c97cee49ea0 \
|
|
||||||
--hash=sha256:5fed36fccc0612a53f1d4d9a816b50a36702c28a2aa880cb8a122b3466638743 \
|
|
||||||
--hash=sha256:61d028e90346df14fedc3d1e5441df818d095f3b87d286825dfcbd6459b7ef63 \
|
|
||||||
--hash=sha256:66f011380d0e49ed280c789fbd08ff0d40968ee7b665575489afa95c98196ab5 \
|
|
||||||
--hash=sha256:6824f87845e3396029f3820c206e459ccc91760e8fa24422f8b0c3d1731cbec5 \
|
|
||||||
--hash=sha256:6c6c373cfc5c83a975506110d17457138c8c63016b563cc9ed6e056a82f13ce4 \
|
|
||||||
--hash=sha256:6d02d6655b0e54f54c4ef0b94eb6be0607b70853c45ce98bd278dc7de718be5d \
|
|
||||||
--hash=sha256:6d50360be4546678fc1b79ffe7a66265e28667840010348dd69a314145807a1b \
|
|
||||||
--hash=sha256:730cacb21e1bdff3ce90babf007d0a0917cc3e6492f336c2f0134101e0944f93 \
|
|
||||||
--hash=sha256:737fe7d37e1a1bffe70bd5754ea763a62a066dc5913ca57e957824b72a85e205 \
|
|
||||||
--hash=sha256:74a03b9698e198d47562765773b4a8309919089150a0bb17d829ad7b44b60d27 \
|
|
||||||
--hash=sha256:7553fb2090d71822f02c629afe6042c299edf91ba1bf94951165613553984512 \
|
|
||||||
--hash=sha256:7a66c7204d8869299919db4d5069a82f1561581af12b11b3c9f48c584eb8743d \
|
|
||||||
--hash=sha256:7cc09976e8b56f8cebd752f7113ad07752461f48a58cbba644139015ac24954c \
|
|
||||||
--hash=sha256:81afed14892743bbe14dacb9e36d9e0e504cd204e0b165062c488942b9718037 \
|
|
||||||
--hash=sha256:8941aaadaf67246224cee8c3803777eed332a19d909b47e29c9842ef1e79ac26 \
|
|
||||||
--hash=sha256:89472c9762729b5ae1ad974b777416bfda4ac5642423fa93bd57a09204712322 \
|
|
||||||
--hash=sha256:8ea985900c5c95ce9db1745f7933eeef5d314f0565b27625d9a10ec9881e1bfb \
|
|
||||||
--hash=sha256:8eca2a813c1cb7ad4fb74d368c2ffbbb4789d377ee5bb8df98373c2cc0dee76c \
|
|
||||||
--hash=sha256:92b68146a71df78564e4ef48af17551a5ddd142e5190cdf2c5624d0c3ff5b2e8 \
|
|
||||||
--hash=sha256:9332088d75dc3241c702d852d4671613136d90fa6881da7d770a483fd05248b4 \
|
|
||||||
--hash=sha256:94698a9c5f91f9d138526b48fe26a199609544591f859c870d477351dc7b2414 \
|
|
||||||
--hash=sha256:9a67fc9e8eb39039280526379fb3a70023d77caec1852002b4da7e8b270c4dd9 \
|
|
||||||
--hash=sha256:9de40a7b0323d889cf8d23d1ef214f565ab154443c42737dfe52ff82cf857664 \
|
|
||||||
--hash=sha256:a05d0c237b3349096d3981b727493e22147f934b20f6f125a3eba8f994bec4a9 \
|
|
||||||
--hash=sha256:afb8db5439b81cf9c9d0c80404b60c3cc9c3add93e114dcae767f1477cb53775 \
|
|
||||||
--hash=sha256:b18a3ed7d5b3bd8d9ef7a8cb226502c6bf8308df1525e1cc676c3680e7176739 \
|
|
||||||
--hash=sha256:b1e74d11748e7e98e2f426ab176d4ed720a64412b6a15054378afdb71e0f37dc \
|
|
||||||
--hash=sha256:b21e08af67b8a103c71a250401c78d5e0893beff75e28c53c98f4de42f774062 \
|
|
||||||
--hash=sha256:b4c854ef3adc177950a8dfc81a86f5115d2abd545751a304c5bcf2c2c7283cfe \
|
|
||||||
--hash=sha256:b882b3df248017dba09d6b16defe9b5c407fe32fc7c65a9c69798e6175601be9 \
|
|
||||||
--hash=sha256:baf5215e0ab74c16e2dd324e8ec067ef59e41125d3eade2b863d294fd5035c92 \
|
|
||||||
--hash=sha256:c649e3a33450ec82378822b3dad03cc228b8f5963c0c12fc3b1e0ab940f768a5 \
|
|
||||||
--hash=sha256:c654de545946e0db659b3400168c9ad31b5d29593291482c43e3564effbcee13 \
|
|
||||||
--hash=sha256:c6638687455baf640e37344fe26d37c404db8b80d037c3d29f58fe8d1c3b194d \
|
|
||||||
--hash=sha256:c8d3b5532fc71b7a77c09192b4a5a200ea992702734a2e9279a37f2478236f26 \
|
|
||||||
--hash=sha256:cb527a79772e5ef98fb1d700678fe031e353e765d1ca2d409c92263c6d43e09f \
|
|
||||||
--hash=sha256:cf364028c016c03078a23b503f02058f1814320a56ad535686f90565636a9495 \
|
|
||||||
--hash=sha256:d48a880098c96020b02d5a1f7d9251308510ce8858940e6fa99ece33f610838b \
|
|
||||||
--hash=sha256:d68b6cef7827e8641e8ef16f4494edda8b36104d79773a334beaa1e3521430f6 \
|
|
||||||
--hash=sha256:d9b29c1f0ae438d5ee9acb31cadee00a58c46cc9c0b2f9038c6b0b3470877a8c \
|
|
||||||
--hash=sha256:d9b97165e8aed9272a6bb17c01e3cc5871a594a446ebedc996e2397a1c1ea8ef \
|
|
||||||
--hash=sha256:da68248800ad6320861f129cd9c1bf96ca849a2771a59e0344e88681905916f5 \
|
|
||||||
--hash=sha256:da902562c3e9c550df360bfa53c035b2f241fed6d9aef119048073680ace4a18 \
|
|
||||||
--hash=sha256:dbd5c7a25a7cb98f5ca55d258b103a2054f859a46ae11aaf23134f9cc0d356ad \
|
|
||||||
--hash=sha256:dd4f05f54a52fb558f1ba9f528228066954fee3ebe629fc1660d874d040ae5a3 \
|
|
||||||
--hash=sha256:de8dad4425a6ca6e4e5e297b27b5c824ecc7581910bf9aee86cb6835e6812aa7 \
|
|
||||||
--hash=sha256:e11e82b744887154b182fd3e7e8512418446501191994dbf9c9fc1f32cc8efd5 \
|
|
||||||
--hash=sha256:e6e73b9e02893c764e7e8d5bb5ce277f1a009cd5243f8228f75f842bf937c534 \
|
|
||||||
--hash=sha256:f73b96c41e3b2adedc34a7356e64c8eb96e03a3782b535e043a986276ce12a49 \
|
|
||||||
--hash=sha256:f93fd8e5c8c0a4aa1f424d6173f14a892044054871c771f8566e4008eaa359d2 \
|
|
||||||
--hash=sha256:fc33c5141b55ed366cfaad382df24fe7dcbc686de5be719b207bb248e3053dc5 \
|
|
||||||
--hash=sha256:fc7de24befaeae77ba923797c7c87834c73648a05a4bde34b3b7e5588973a453 \
|
|
||||||
--hash=sha256:fe562eb1a64e67dd297ccc4f5addea2501664954f2692b69a76449ec7913ecbf
|
|
||||||
# via weasyprint
|
|
||||||
cfgv==3.4.0 \
|
|
||||||
--hash=sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9 \
|
|
||||||
--hash=sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560
|
|
||||||
# via pre-commit
|
|
||||||
cssselect2==0.8.0 \
|
|
||||||
--hash=sha256:46fc70ebc41ced7a32cd42d58b1884d72ade23d21e5a4eaaf022401c13f0e76e \
|
|
||||||
--hash=sha256:7674ffb954a3b46162392aee2a3a0aedb2e14ecf99fcc28644900f4e6e3e9d3a
|
|
||||||
# via weasyprint
|
|
||||||
distlib==0.4.0 \
|
|
||||||
--hash=sha256:9659f7d87e46584a30b5780e43ac7a2143098441670ff0a49d5f9034c54a6c16 \
|
|
||||||
--hash=sha256:feec40075be03a04501a973d81f633735b4b69f98b05450592310c0f401a4e0d
|
|
||||||
# via virtualenv
|
|
||||||
filelock==3.20.0 \
|
|
||||||
--hash=sha256:339b4732ffda5cd79b13f4e2711a31b0365ce445d95d243bb996273d072546a2 \
|
|
||||||
--hash=sha256:711e943b4ec6be42e1d4e6690b48dc175c822967466bb31c0c293f34334c13f4
|
|
||||||
# via virtualenv
|
|
||||||
fonttools==4.60.1 \
|
|
||||||
--hash=sha256:022beaea4b73a70295b688f817ddc24ed3e3418b5036ffcd5658141184ef0d0c \
|
|
||||||
--hash=sha256:026290e4ec76583881763fac284aca67365e0be9f13a7fb137257096114cb3bc \
|
|
||||||
--hash=sha256:0b0835ed15dd5b40d726bb61c846a688f5b4ce2208ec68779bc81860adb5851a \
|
|
||||||
--hash=sha256:0eae96373e4b7c9e45d099d7a523444e3554360927225c1cdae221a58a45b856 \
|
|
||||||
--hash=sha256:122e1a8ada290423c493491d002f622b1992b1ab0b488c68e31c413390dc7eb2 \
|
|
||||||
--hash=sha256:1410155d0e764a4615774e5c2c6fc516259fe3eca5882f034eb9bfdbee056259 \
|
|
||||||
--hash=sha256:145daa14bf24824b677b9357c5e44fd8895c2a8f53596e1b9ea3496081dc692c \
|
|
||||||
--hash=sha256:1525796c3ffe27bb6268ed2a1bb0dcf214d561dfaf04728abf01489eb5339dce \
|
|
||||||
--hash=sha256:154cb6ee417e417bf5f7c42fe25858c9140c26f647c7347c06f0cc2d47eff003 \
|
|
||||||
--hash=sha256:2299df884c11162617a66b7c316957d74a18e3758c0274762d2cc87df7bc0272 \
|
|
||||||
--hash=sha256:2409d5fb7b55fd70f715e6d34e7a6e4f7511b8ad29a49d6df225ee76da76dd77 \
|
|
||||||
--hash=sha256:268ecda8ca6cb5c4f044b1fb9b3b376e8cd1b361cef275082429dc4174907038 \
|
|
||||||
--hash=sha256:282dafa55f9659e8999110bd8ed422ebe1c8aecd0dc396550b038e6c9a08b8ea \
|
|
||||||
--hash=sha256:2ee06fc57512144d8b0445194c2da9f190f61ad51e230f14836286470c99f854 \
|
|
||||||
--hash=sha256:3630e86c484263eaac71d117085d509cbcf7b18f677906824e4bace598fb70d2 \
|
|
||||||
--hash=sha256:398447f3d8c0c786cbf1209711e79080a40761eb44b27cdafffb48f52bcec258 \
|
|
||||||
--hash=sha256:4ba4bd646e86de16160f0fb72e31c3b9b7d0721c3e5b26b9fa2fc931dfdb2652 \
|
|
||||||
--hash=sha256:5664fd1a9ea7f244487ac8f10340c4e37664675e8667d6fee420766e0fb3cf08 \
|
|
||||||
--hash=sha256:583b7f8e3c49486e4d489ad1deacfb8d5be54a8ef34d6df824f6a171f8511d99 \
|
|
||||||
--hash=sha256:596ecaca36367027d525b3b426d8a8208169d09edcf8c7506aceb3a38bfb55c7 \
|
|
||||||
--hash=sha256:5c1015318e4fec75dd4943ad5f6a206d9727adf97410d58b7e32ab644a807914 \
|
|
||||||
--hash=sha256:66929e2ea2810c6533a5184f938502cfdaea4bc3efb7130d8cc02e1c1b4108d6 \
|
|
||||||
--hash=sha256:6ec722ee589e89a89f5b7574f5c45604030aa6ae24cb2c751e2707193b466fed \
|
|
||||||
--hash=sha256:6f68576bb4bbf6060c7ab047b1574a1ebe5c50a17de62830079967b211059ebb \
|
|
||||||
--hash=sha256:7473a8ed9ed09aeaa191301244a5a9dbe46fe0bf54f9d6cd21d83044c3321217 \
|
|
||||||
--hash=sha256:7b0c6d57ab00dae9529f3faf187f2254ea0aa1e04215cf2f1a8ec277c96661bc \
|
|
||||||
--hash=sha256:7b4c32e232a71f63a5d00259ca3d88345ce2a43295bb049d21061f338124246f \
|
|
||||||
--hash=sha256:8177ec9676ea6e1793c8a084a90b65a9f778771998eb919d05db6d4b1c0b114c \
|
|
||||||
--hash=sha256:839565cbf14645952d933853e8ade66a463684ed6ed6c9345d0faf1f0e868877 \
|
|
||||||
--hash=sha256:875cb7764708b3132637f6c5fb385b16eeba0f7ac9fa45a69d35e09b47045801 \
|
|
||||||
--hash=sha256:8a44788d9d91df72d1a5eac49b31aeb887a5f4aab761b4cffc4196c74907ea85 \
|
|
||||||
--hash=sha256:8b4eb332f9501cb1cd3d4d099374a1e1306783ff95489a1026bde9eb02ccc34a \
|
|
||||||
--hash=sha256:906306ac7afe2156fcf0042173d6ebbb05416af70f6b370967b47f8f00103bbb \
|
|
||||||
--hash=sha256:992775c9fbe2cf794786fa0ffca7f09f564ba3499b8fe9f2f80bd7197db60383 \
|
|
||||||
--hash=sha256:996a4d1834524adbb423385d5a629b868ef9d774670856c63c9a0408a3063401 \
|
|
||||||
--hash=sha256:9a52f254ce051e196b8fe2af4634c2d2f02c981756c6464dc192f1b6050b4e28 \
|
|
||||||
--hash=sha256:9d0ced62b59e0430b3690dbc5373df1c2aa7585e9a8ce38eff87f0fd993c5b01 \
|
|
||||||
--hash=sha256:a140761c4ff63d0cb9256ac752f230460ee225ccef4ad8f68affc723c88e2036 \
|
|
||||||
--hash=sha256:a184b2ea57b13680ab6d5fbde99ccef152c95c06746cb7718c583abd8f945ccc \
|
|
||||||
--hash=sha256:a3db56f153bd4c5c2b619ab02c5db5192e222150ce5a1bc10f16164714bc39ac \
|
|
||||||
--hash=sha256:a46b2f450bc79e06ef3b6394f0c68660529ed51692606ad7f953fc2e448bc903 \
|
|
||||||
--hash=sha256:a884aef09d45ba1206712c7dbda5829562d3fea7726935d3289d343232ecb0d3 \
|
|
||||||
--hash=sha256:b2cf105cee600d2de04ca3cfa1f74f1127f8455b71dbad02b9da6ec266e116d6 \
|
|
||||||
--hash=sha256:b33a7884fabd72bdf5f910d0cf46be50dce86a0362a65cfc746a4168c67eb96c \
|
|
||||||
--hash=sha256:b42d86938e8dda1cd9a1a87a6d82f1818eaf933348429653559a458d027446da \
|
|
||||||
--hash=sha256:b6379e7546ba4ae4b18f8ae2b9bc5960936007a1c0e30b342f662577e8bc3299 \
|
|
||||||
--hash=sha256:c7420a2696a44650120cdd269a5d2e56a477e2bfa9d95e86229059beb1c19e15 \
|
|
||||||
--hash=sha256:c8651e0d4b3bdeda6602b85fdc2abbefc1b41e573ecb37b6779c4ca50753a199 \
|
|
||||||
--hash=sha256:d066ea419f719ed87bc2c99a4a4bfd77c2e5949cb724588b9dd58f3fd90b92bf \
|
|
||||||
--hash=sha256:e6c58beb17380f7c2ea181ea11e7db8c0ceb474c9dd45f48e71e2cb577d146a1 \
|
|
||||||
--hash=sha256:e852d9dda9f93ad3651ae1e3bb770eac544ec93c3807888798eccddf84596537 \
|
|
||||||
--hash=sha256:ec3681a0cb34c255d76dd9d865a55f260164adb9fa02628415cdc2d43ee2c05d \
|
|
||||||
--hash=sha256:ee0c0b3b35b34f782afc673d503167157094a16f442ace7c6c5e0ca80b08f50c \
|
|
||||||
--hash=sha256:eedacb5c5d22b7097482fa834bda0dafa3d914a4e829ec83cdea2a01f8c813c4 \
|
|
||||||
--hash=sha256:ef00af0439ebfee806b25f24c8f92109157ff3fac5731dc7867957812e87b8d9 \
|
|
||||||
--hash=sha256:f0e8817c7d1a0c2eedebf57ef9a9896f3ea23324769a9a2061a80fe8852705ed \
|
|
||||||
--hash=sha256:f3d5be054c461d6a2268831f04091dc82753176f6ea06dc6047a5e168265a987 \
|
|
||||||
--hash=sha256:f4b5c37a5f40e4d733d3bbaaef082149bee5a5ea3156a785ff64d949bd1353fa
|
|
||||||
# via weasyprint
|
|
||||||
identify==2.6.15 \
|
|
||||||
--hash=sha256:1181ef7608e00704db228516541eb83a88a9f94433a8c80bb9b5bd54b1d81757 \
|
|
||||||
--hash=sha256:e4f4864b96c6557ef2a1e1c951771838f4edc9df3a72ec7118b338801b11c7bf
|
|
||||||
# via pre-commit
|
|
||||||
nodeenv==1.9.1 \
|
|
||||||
--hash=sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f \
|
|
||||||
--hash=sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9
|
|
||||||
# via pre-commit
|
|
||||||
numpy==2.2.6 \
|
|
||||||
--hash=sha256:038613e9fb8c72b0a41f025a7e4c3f0b7a1b5d768ece4796b674c8f3fe13efff \
|
|
||||||
--hash=sha256:0678000bb9ac1475cd454c6b8c799206af8107e310843532b04d49649c717a47 \
|
|
||||||
--hash=sha256:0811bb762109d9708cca4d0b13c4f67146e3c3b7cf8d34018c722adb2d957c84 \
|
|
||||||
--hash=sha256:0b605b275d7bd0c640cad4e5d30fa701a8d59302e127e5f79138ad62762c3e3d \
|
|
||||||
--hash=sha256:0bca768cd85ae743b2affdc762d617eddf3bcf8724435498a1e80132d04879e6 \
|
|
||||||
--hash=sha256:1bc23a79bfabc5d056d106f9befb8d50c31ced2fbc70eedb8155aec74a45798f \
|
|
||||||
--hash=sha256:287cc3162b6f01463ccd86be154f284d0893d2b3ed7292439ea97eafa8170e0b \
|
|
||||||
--hash=sha256:37c0ca431f82cd5fa716eca9506aefcabc247fb27ba69c5062a6d3ade8cf8f49 \
|
|
||||||
--hash=sha256:37e990a01ae6ec7fe7fa1c26c55ecb672dd98b19c3d0e1d1f326fa13cb38d163 \
|
|
||||||
--hash=sha256:389d771b1623ec92636b0786bc4ae56abafad4a4c513d36a55dce14bd9ce8571 \
|
|
||||||
--hash=sha256:3d70692235e759f260c3d837193090014aebdf026dfd167834bcba43e30c2a42 \
|
|
||||||
--hash=sha256:41c5a21f4a04fa86436124d388f6ed60a9343a6f767fced1a8a71c3fbca038ff \
|
|
||||||
--hash=sha256:481b49095335f8eed42e39e8041327c05b0f6f4780488f61286ed3c01368d491 \
|
|
||||||
--hash=sha256:4eeaae00d789f66c7a25ac5f34b71a7035bb474e679f410e5e1a94deb24cf2d4 \
|
|
||||||
--hash=sha256:55a4d33fa519660d69614a9fad433be87e5252f4b03850642f88993f7b2ca566 \
|
|
||||||
--hash=sha256:5a6429d4be8ca66d889b7cf70f536a397dc45ba6faeb5f8c5427935d9592e9cf \
|
|
||||||
--hash=sha256:5bd4fc3ac8926b3819797a7c0e2631eb889b4118a9898c84f585a54d475b7e40 \
|
|
||||||
--hash=sha256:5beb72339d9d4fa36522fc63802f469b13cdbe4fdab4a288f0c441b74272ebfd \
|
|
||||||
--hash=sha256:6031dd6dfecc0cf9f668681a37648373bddd6421fff6c66ec1624eed0180ee06 \
|
|
||||||
--hash=sha256:71594f7c51a18e728451bb50cc60a3ce4e6538822731b2933209a1f3614e9282 \
|
|
||||||
--hash=sha256:74d4531beb257d2c3f4b261bfb0fc09e0f9ebb8842d82a7b4209415896adc680 \
|
|
||||||
--hash=sha256:7befc596a7dc9da8a337f79802ee8adb30a552a94f792b9c9d18c840055907db \
|
|
||||||
--hash=sha256:894b3a42502226a1cac872f840030665f33326fc3dac8e57c607905773cdcde3 \
|
|
||||||
--hash=sha256:8e41fd67c52b86603a91c1a505ebaef50b3314de0213461c7a6e99c9a3beff90 \
|
|
||||||
--hash=sha256:8e9ace4a37db23421249ed236fdcdd457d671e25146786dfc96835cd951aa7c1 \
|
|
||||||
--hash=sha256:8fc377d995680230e83241d8a96def29f204b5782f371c532579b4f20607a289 \
|
|
||||||
--hash=sha256:9551a499bf125c1d4f9e250377c1ee2eddd02e01eac6644c080162c0c51778ab \
|
|
||||||
--hash=sha256:b0544343a702fa80c95ad5d3d608ea3599dd54d4632df855e4c8d24eb6ecfa1c \
|
|
||||||
--hash=sha256:b093dd74e50a8cba3e873868d9e93a85b78e0daf2e98c6797566ad8044e8363d \
|
|
||||||
--hash=sha256:b412caa66f72040e6d268491a59f2c43bf03eb6c96dd8f0307829feb7fa2b6fb \
|
|
||||||
--hash=sha256:b4f13750ce79751586ae2eb824ba7e1e8dba64784086c98cdbbcc6a42112ce0d \
|
|
||||||
--hash=sha256:b64d8d4d17135e00c8e346e0a738deb17e754230d7e0810ac5012750bbd85a5a \
|
|
||||||
--hash=sha256:ba10f8411898fc418a521833e014a77d3ca01c15b0c6cdcce6a0d2897e6dbbdf \
|
|
||||||
--hash=sha256:bd48227a919f1bafbdda0583705e547892342c26fb127219d60a5c36882609d1 \
|
|
||||||
--hash=sha256:c1f9540be57940698ed329904db803cf7a402f3fc200bfe599334c9bd84a40b2 \
|
|
||||||
--hash=sha256:c820a93b0255bc360f53eca31a0e676fd1101f673dda8da93454a12e23fc5f7a \
|
|
||||||
--hash=sha256:ce47521a4754c8f4593837384bd3424880629f718d87c5d44f8ed763edd63543 \
|
|
||||||
--hash=sha256:d042d24c90c41b54fd506da306759e06e568864df8ec17ccc17e9e884634fd00 \
|
|
||||||
--hash=sha256:de749064336d37e340f640b05f24e9e3dd678c57318c7289d222a8a2f543e90c \
|
|
||||||
--hash=sha256:e1dda9c7e08dc141e0247a5b8f49cf05984955246a327d4c48bda16821947b2f \
|
|
||||||
--hash=sha256:e29554e2bef54a90aa5cc07da6ce955accb83f21ab5de01a62c8478897b264fd \
|
|
||||||
--hash=sha256:e3143e4451880bed956e706a3220b4e5cf6172ef05fcc397f6f36a550b1dd868 \
|
|
||||||
--hash=sha256:e8213002e427c69c45a52bbd94163084025f533a55a59d6f9c5b820774ef3303 \
|
|
||||||
--hash=sha256:efd28d4e9cd7d7a8d39074a4d44c63eda73401580c5c76acda2ce969e0a38e83 \
|
|
||||||
--hash=sha256:f0fd6321b839904e15c46e0d257fdd101dd7f530fe03fd6359c1ea63738703f3 \
|
|
||||||
--hash=sha256:f1372f041402e37e5e633e586f62aa53de2eac8d98cbfb822806ce4bbefcb74d \
|
|
||||||
--hash=sha256:f2618db89be1b4e05f7a1a847a9c1c0abd63e63a1607d892dd54668dd92faf87 \
|
|
||||||
--hash=sha256:f447e6acb680fd307f40d3da4852208af94afdfab89cf850986c3ca00562f4fa \
|
|
||||||
--hash=sha256:f92729c95468a2f4f15e9bb94c432a9229d0d50de67304399627a943201baa2f \
|
|
||||||
--hash=sha256:f9f1adb22318e121c5c69a09142811a201ef17ab257a1e66ca3025065b7f53ae \
|
|
||||||
--hash=sha256:fc0c5673685c508a142ca65209b4e79ed6740a4ed6b2267dbba90f34b0b3cfda \
|
|
||||||
--hash=sha256:fc7b73d02efb0e18c000e9ad8b83480dfcd5dfd11065997ed4c6747470ae8915 \
|
|
||||||
--hash=sha256:fd83c01228a688733f1ded5201c678f0c53ecc1006ffbc404db9f7a899ac6249 \
|
|
||||||
--hash=sha256:fe27749d33bb772c80dcd84ae7e8df2adc920ae8297400dabec45f0dedb3f6de \
|
|
||||||
--hash=sha256:fee4236c876c4e8369388054d02d0e9bb84821feb1a64dd59e137e6511a551f8
|
|
||||||
# via opencv-python-headless
|
|
||||||
opencv-python-headless==4.12.0.88 \
|
|
||||||
--hash=sha256:1e58d664809b3350c1123484dd441e1667cd7bed3086db1b9ea1b6f6cb20b50e \
|
|
||||||
--hash=sha256:236c8df54a90f4d02076e6f9c1cc763d794542e886c576a6fee46ec8ff75a7a9 \
|
|
||||||
--hash=sha256:365bb2e486b50feffc2d07a405b953a8f3e8eaa63865bc650034e5c71e7a5154 \
|
|
||||||
--hash=sha256:86b413bdd6c6bf497832e346cd5371995de148e579b9774f8eba686dee3f5528 \
|
|
||||||
--hash=sha256:aeb4b13ecb8b4a0beb2668ea07928160ea7c2cd2d9b5ef571bbee6bafe9cc8d0 \
|
|
||||||
--hash=sha256:cfdc017ddf2e59b6c2f53bc12d74b6b0be7ded4ec59083ea70763921af2b6c09 \
|
|
||||||
--hash=sha256:fde2cf5c51e4def5f2132d78e0c08f9c14783cd67356922182c6845b9af87dbd
|
|
||||||
# via -r .github/scripts/requirements_dev.in
|
|
||||||
pdf2image==1.17.0 \
|
|
||||||
--hash=sha256:eaa959bc116b420dd7ec415fcae49b98100dda3dd18cd2fdfa86d09f112f6d57 \
|
|
||||||
--hash=sha256:ecdd58d7afb810dffe21ef2b1bbc057ef434dabbac6c33778a38a3f7744a27e2
|
|
||||||
# via -r .github/scripts/requirements_dev.in
|
|
||||||
pillow==12.0.0 \
|
|
||||||
--hash=sha256:0869154a2d0546545cde61d1789a6524319fc1897d9ee31218eae7a60ccc5643 \
|
|
||||||
--hash=sha256:09f2d0abef9e4e2f349305a4f8cc784a8a6c2f58a8c4892eea13b10a943bd26e \
|
|
||||||
--hash=sha256:0b817e7035ea7f6b942c13aa03bb554fc44fea70838ea21f8eb31c638326584e \
|
|
||||||
--hash=sha256:0fd00cac9c03256c8b2ff58f162ebcd2587ad3e1f2e397eab718c47e24d231cc \
|
|
||||||
--hash=sha256:110486b79f2d112cf6add83b28b627e369219388f64ef2f960fef9ebaf54c642 \
|
|
||||||
--hash=sha256:1979f4566bb96c1e50a62d9831e2ea2d1211761e5662afc545fa766f996632f6 \
|
|
||||||
--hash=sha256:1ac11e8ea4f611c3c0147424eae514028b5e9077dd99ab91e1bd7bc33ff145e1 \
|
|
||||||
--hash=sha256:1b1b133e6e16105f524a8dec491e0586d072948ce15c9b914e41cdadd209052b \
|
|
||||||
--hash=sha256:1ee80a59f6ce048ae13cda1abf7fbd2a34ab9ee7d401c46be3ca685d1999a399 \
|
|
||||||
--hash=sha256:21f241bdd5080a15bc86d3466a9f6074a9c2c2b314100dd896ac81ee6db2f1ba \
|
|
||||||
--hash=sha256:266cd5f2b63ff316d5a1bba46268e603c9caf5606d44f38c2873c380950576ad \
|
|
||||||
--hash=sha256:26d9f7d2b604cd23aba3e9faf795787456ac25634d82cd060556998e39c6fa47 \
|
|
||||||
--hash=sha256:27f95b12453d165099c84f8a8bfdfd46b9e4bda9e0e4b65f0635430027f55739 \
|
|
||||||
--hash=sha256:2c54c1a783d6d60595d3514f0efe9b37c8808746a66920315bfd34a938d7994b \
|
|
||||||
--hash=sha256:2fa5f0b6716fc88f11380b88b31fe591a06c6315e955c096c35715788b339e3f \
|
|
||||||
--hash=sha256:32ed80ea8a90ee3e6fa08c21e2e091bba6eda8eccc83dbc34c95169507a91f10 \
|
|
||||||
--hash=sha256:3830c769decf88f1289680a59d4f4c46c72573446352e2befec9a8512104fa52 \
|
|
||||||
--hash=sha256:38df9b4bfd3db902c9c2bd369bcacaf9d935b2fff73709429d95cc41554f7b3d \
|
|
||||||
--hash=sha256:3adfb466bbc544b926d50fe8f4a4e6abd8c6bffd28a26177594e6e9b2b76572b \
|
|
||||||
--hash=sha256:3e42edad50b6909089750e65c91aa09aaf1e0a71310d383f11321b27c224ed8a \
|
|
||||||
--hash=sha256:4078242472387600b2ce8d93ade8899c12bf33fa89e55ec89fe126e9d6d5d9e9 \
|
|
||||||
--hash=sha256:455247ac8a4cfb7b9bc45b7e432d10421aea9fc2e74d285ba4072688a74c2e9d \
|
|
||||||
--hash=sha256:4cc6b3b2efff105c6a1656cfe59da4fdde2cda9af1c5e0b58529b24525d0a098 \
|
|
||||||
--hash=sha256:4cf7fed4b4580601c4345ceb5d4cbf5a980d030fd5ad07c4d2ec589f95f09905 \
|
|
||||||
--hash=sha256:5193fde9a5f23c331ea26d0cf171fbf67e3f247585f50c08b3e205c7aeb4589b \
|
|
||||||
--hash=sha256:5269cc1caeedb67e6f7269a42014f381f45e2e7cd42d834ede3c703a1d915fe3 \
|
|
||||||
--hash=sha256:53561a4ddc36facb432fae7a9d8afbfaf94795414f5cdc5fc52f28c1dca90371 \
|
|
||||||
--hash=sha256:55f818bd74fe2f11d4d7cbc65880a843c4075e0ac7226bc1a23261dbea531953 \
|
|
||||||
--hash=sha256:58eea5ebe51504057dd95c5b77d21700b77615ab0243d8152793dc00eb4faf01 \
|
|
||||||
--hash=sha256:5d5c411a8eaa2299322b647cd932586b1427367fd3184ffbb8f7a219ea2041ca \
|
|
||||||
--hash=sha256:6846bd2d116ff42cba6b646edf5bf61d37e5cbd256425fa089fee4ff5c07a99e \
|
|
||||||
--hash=sha256:6ace95230bfb7cd79ef66caa064bbe2f2a1e63d93471c3a2e1f1348d9f22d6b7 \
|
|
||||||
--hash=sha256:6e51b71417049ad6ab14c49608b4a24d8fb3fe605e5dfabfe523b58064dc3d27 \
|
|
||||||
--hash=sha256:71db6b4c1653045dacc1585c1b0d184004f0d7e694c7b34ac165ca70c0838082 \
|
|
||||||
--hash=sha256:7438839e9e053ef79f7112c881cef684013855016f928b168b81ed5835f3e75e \
|
|
||||||
--hash=sha256:759de84a33be3b178a64c8ba28ad5c135900359e85fb662bc6e403ad4407791d \
|
|
||||||
--hash=sha256:792a2c0be4dcc18af9d4a2dfd8a11a17d5e25274a1062b0ec1c2d79c76f3e7f8 \
|
|
||||||
--hash=sha256:7d87ef5795da03d742bf49439f9ca4d027cde49c82c5371ba52464aee266699a \
|
|
||||||
--hash=sha256:7dfb439562f234f7d57b1ac6bc8fe7f838a4bd49c79230e0f6a1da93e82f1fad \
|
|
||||||
--hash=sha256:7fa22993bac7b77b78cae22bad1e2a987ddf0d9015c63358032f84a53f23cdc3 \
|
|
||||||
--hash=sha256:805ebf596939e48dbb2e4922a1d3852cfc25c38160751ce02da93058b48d252a \
|
|
||||||
--hash=sha256:82240051c6ca513c616f7f9da06e871f61bfd7805f566275841af15015b8f98d \
|
|
||||||
--hash=sha256:87d4f8125c9988bfbed67af47dd7a953e2fc7b0cc1e7800ec6d2080d490bb353 \
|
|
||||||
--hash=sha256:8d8ca2b210ada074d57fcee40c30446c9562e542fc46aedc19baf758a93532ee \
|
|
||||||
--hash=sha256:8dc232e39d409036af549c86f24aed8273a40ffa459981146829a324e0848b4b \
|
|
||||||
--hash=sha256:90387104ee8400a7b4598253b4c406f8958f59fcf983a6cea2b50d59f7d63d0b \
|
|
||||||
--hash=sha256:905b0365b210c73afb0ebe9101a32572152dfd1c144c7e28968a331b9217b94a \
|
|
||||||
--hash=sha256:99353a06902c2e43b43e8ff74ee65a7d90307d82370604746738a1e0661ccca7 \
|
|
||||||
--hash=sha256:99a7f72fb6249302aa62245680754862a44179b545ded638cf1fef59befb57ef \
|
|
||||||
--hash=sha256:9f0b04c6b8584c2c193babcccc908b38ed29524b29dd464bc8801bf10d746a3a \
|
|
||||||
--hash=sha256:9fe611163f6303d1619bbcb653540a4d60f9e55e622d60a3108be0d5b441017a \
|
|
||||||
--hash=sha256:a3475b96f5908b3b16c47533daaa87380c491357d197564e0ba34ae75c0f3257 \
|
|
||||||
--hash=sha256:a6597ff2b61d121172f5844b53f21467f7082f5fb385a9a29c01414463f93b07 \
|
|
||||||
--hash=sha256:a7921c5a6d31b3d756ec980f2f47c0cfdbce0fc48c22a39347a895f41f4a6ea4 \
|
|
||||||
--hash=sha256:aa5129de4e174daccbc59d0a3b6d20eaf24417d59851c07ebb37aeb02947987c \
|
|
||||||
--hash=sha256:aeaefa96c768fc66818730b952a862235d68825c178f1b3ffd4efd7ad2edcb7c \
|
|
||||||
--hash=sha256:afbefa430092f71a9593a99ab6a4e7538bc9eabbf7bf94f91510d3503943edc4 \
|
|
||||||
--hash=sha256:aff9e4d82d082ff9513bdd6acd4f5bd359f5b2c870907d2b0a9c5e10d40c88fe \
|
|
||||||
--hash=sha256:b22bd8c974942477156be55a768f7aa37c46904c175be4e158b6a86e3a6b7ca8 \
|
|
||||||
--hash=sha256:b290fd8aa38422444d4b50d579de197557f182ef1068b75f5aa8558638b8d0a5 \
|
|
||||||
--hash=sha256:b2e4b27a6e15b04832fe9bf292b94b5ca156016bbc1ea9c2c20098a0320d6cf6 \
|
|
||||||
--hash=sha256:b583dc9070312190192631373c6c8ed277254aa6e6084b74bdd0a6d3b221608e \
|
|
||||||
--hash=sha256:b87843e225e74576437fd5b6a4c2205d422754f84a06942cfaf1dc32243e45a8 \
|
|
||||||
--hash=sha256:bc91a56697869546d1b8f0a3ff35224557ae7f881050e99f615e0119bf934b4e \
|
|
||||||
--hash=sha256:bd87e140e45399c818fac4247880b9ce719e4783d767e030a883a970be632275 \
|
|
||||||
--hash=sha256:bde737cff1a975b70652b62d626f7785e0480918dece11e8fef3c0cf057351c3 \
|
|
||||||
--hash=sha256:bdee52571a343d721fb2eb3b090a82d959ff37fc631e3f70422e0c2e029f3e76 \
|
|
||||||
--hash=sha256:bee2a6db3a7242ea309aa7ee8e2780726fed67ff4e5b40169f2c940e7eb09227 \
|
|
||||||
--hash=sha256:beeae3f27f62308f1ddbcfb0690bf44b10732f2ef43758f169d5e9303165d3f9 \
|
|
||||||
--hash=sha256:c50f36a62a22d350c96e49ad02d0da41dbd17ddc2e29750dbdba4323f85eb4a5 \
|
|
||||||
--hash=sha256:c607c90ba67533e1b2355b821fef6764d1dd2cbe26b8c1005ae84f7aea25ff79 \
|
|
||||||
--hash=sha256:c7b2a63fd6d5246349f3d3f37b14430d73ee7e8173154461785e43036ffa96ca \
|
|
||||||
--hash=sha256:c828a1ae702fc712978bda0320ba1b9893d99be0badf2647f693cc01cf0f04fa \
|
|
||||||
--hash=sha256:c85de1136429c524e55cfa4e033b4a7940ac5c8ee4d9401cc2d1bf48154bbc7b \
|
|
||||||
--hash=sha256:c98fa880d695de164b4135a52fd2e9cd7b7c90a9d8ac5e9e443a24a95ef9248e \
|
|
||||||
--hash=sha256:cae81479f77420d217def5f54b5b9d279804d17e982e0f2fa19b1d1e14ab5197 \
|
|
||||||
--hash=sha256:d034140032870024e6b9892c692fe2968493790dd57208b2c37e3fb35f6df3ab \
|
|
||||||
--hash=sha256:d120c38a42c234dc9a8c5de7ceaaf899cf33561956acb4941653f8bdc657aa79 \
|
|
||||||
--hash=sha256:d4827615da15cd59784ce39d3388275ec093ae3ee8d7f0c089b76fa87af756c2 \
|
|
||||||
--hash=sha256:d49e2314c373f4c2b39446fb1a45ed333c850e09d0c59ac79b72eb3b95397363 \
|
|
||||||
--hash=sha256:d52610d51e265a51518692045e372a4c363056130d922a7351429ac9f27e70b0 \
|
|
||||||
--hash=sha256:d64317d2587c70324b79861babb9c09f71fbb780bad212018874b2c013d8600e \
|
|
||||||
--hash=sha256:d77153e14b709fd8b8af6f66a3afbb9ed6e9fc5ccf0b6b7e1ced7b036a228782 \
|
|
||||||
--hash=sha256:d7e091d464ac59d2c7ad8e7e08105eaf9dafbc3883fd7265ffccc2baad6ac925 \
|
|
||||||
--hash=sha256:dd333073e0cacdc3089525c7df7d39b211bcdf31fc2824e49d01c6b6187b07d0 \
|
|
||||||
--hash=sha256:e5d8efac84c9afcb40914ab49ba063d94f5dbdf5066db4482c66a992f47a3a3b \
|
|
||||||
--hash=sha256:f135c702ac42262573fe9714dfe99c944b4ba307af5eb507abef1667e2cbbced \
|
|
||||||
--hash=sha256:f13711b1a5ba512d647a0e4ba79280d3a9a045aaf7e0cc6fbe96b91d4cdf6b0c \
|
|
||||||
--hash=sha256:f4f1231b7dec408e8670264ce63e9c71409d9583dd21d32c163e25213ee2a344 \
|
|
||||||
--hash=sha256:fa3ed2a29a9e9d2d488b4da81dcb54720ac3104a20bf0bd273f1e4648aff5af9 \
|
|
||||||
--hash=sha256:fb3096c30df99fd01c7bf8e544f392103d0795b9f98ba71a8054bcbf56b255f1
|
|
||||||
# via
|
|
||||||
# -r .github/scripts/requirements_dev.in
|
|
||||||
# pdf2image
|
|
||||||
# weasyprint
|
|
||||||
platformdirs==4.5.0 \
|
|
||||||
--hash=sha256:70ddccdd7c99fc5942e9fc25636a8b34d04c24b335100223152c2803e4063312 \
|
|
||||||
--hash=sha256:e578a81bb873cbb89a41fcc904c7ef523cc18284b7e3b3ccf06aca1403b7ebd3
|
|
||||||
# via virtualenv
|
|
||||||
pre-commit==4.3.0 \
|
|
||||||
--hash=sha256:2b0747ad7e6e967169136edffee14c16e148a778a54e4f967921aa1ebf2308d8 \
|
|
||||||
--hash=sha256:499fe450cc9d42e9d58e606262795ecb64dd05438943c62b66f6a8673da30b16
|
|
||||||
# via -r .github/scripts/requirements_dev.in
|
|
||||||
pycparser==2.23 \
|
|
||||||
--hash=sha256:78816d4f24add8f10a06d6f05b4d424ad9e96cfebf68a4ddc99c65c0720d00c2 \
|
|
||||||
--hash=sha256:e5c6e8d3fbad53479cab09ac03729e0a9faf2bee3db8208a550daf5af81a5934
|
|
||||||
# via cffi
|
|
||||||
pydyf==0.11.0 \
|
|
||||||
--hash=sha256:0aaf9e2ebbe786ec7a78ec3fbffa4cdcecde53fd6f563221d53c6bc1328848a3 \
|
|
||||||
--hash=sha256:394dddf619cca9d0c55715e3c55ea121a9bf9cbc780cdc1201a2427917b86b64
|
|
||||||
# via weasyprint
|
|
||||||
pyphen==0.17.2 \
|
|
||||||
--hash=sha256:3a07fb017cb2341e1d9ff31b8634efb1ae4dc4b130468c7c39dd3d32e7c3affd \
|
|
||||||
--hash=sha256:f60647a9c9b30ec6c59910097af82bc5dd2d36576b918e44148d8b07ef3b4aa3
|
|
||||||
# via weasyprint
|
|
||||||
pyyaml==6.0.3 \
|
|
||||||
--hash=sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c \
|
|
||||||
--hash=sha256:0150219816b6a1fa26fb4699fb7daa9caf09eb1999f3b70fb6e786805e80375a \
|
|
||||||
--hash=sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3 \
|
|
||||||
--hash=sha256:02ea2dfa234451bbb8772601d7b8e426c2bfa197136796224e50e35a78777956 \
|
|
||||||
--hash=sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6 \
|
|
||||||
--hash=sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c \
|
|
||||||
--hash=sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65 \
|
|
||||||
--hash=sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a \
|
|
||||||
--hash=sha256:1ebe39cb5fc479422b83de611d14e2c0d3bb2a18bbcb01f229ab3cfbd8fee7a0 \
|
|
||||||
--hash=sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b \
|
|
||||||
--hash=sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1 \
|
|
||||||
--hash=sha256:22ba7cfcad58ef3ecddc7ed1db3409af68d023b7f940da23c6c2a1890976eda6 \
|
|
||||||
--hash=sha256:27c0abcb4a5dac13684a37f76e701e054692a9b2d3064b70f5e4eb54810553d7 \
|
|
||||||
--hash=sha256:28c8d926f98f432f88adc23edf2e6d4921ac26fb084b028c733d01868d19007e \
|
|
||||||
--hash=sha256:2e71d11abed7344e42a8849600193d15b6def118602c4c176f748e4583246007 \
|
|
||||||
--hash=sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310 \
|
|
||||||
--hash=sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4 \
|
|
||||||
--hash=sha256:3c5677e12444c15717b902a5798264fa7909e41153cdf9ef7ad571b704a63dd9 \
|
|
||||||
--hash=sha256:3ff07ec89bae51176c0549bc4c63aa6202991da2d9a6129d7aef7f1407d3f295 \
|
|
||||||
--hash=sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea \
|
|
||||||
--hash=sha256:418cf3f2111bc80e0933b2cd8cd04f286338bb88bdc7bc8e6dd775ebde60b5e0 \
|
|
||||||
--hash=sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e \
|
|
||||||
--hash=sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac \
|
|
||||||
--hash=sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9 \
|
|
||||||
--hash=sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7 \
|
|
||||||
--hash=sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35 \
|
|
||||||
--hash=sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb \
|
|
||||||
--hash=sha256:5cf4e27da7e3fbed4d6c3d8e797387aaad68102272f8f9752883bc32d61cb87b \
|
|
||||||
--hash=sha256:5e0b74767e5f8c593e8c9b5912019159ed0533c70051e9cce3e8b6aa699fcd69 \
|
|
||||||
--hash=sha256:5ed875a24292240029e4483f9d4a4b8a1ae08843b9c54f43fcc11e404532a8a5 \
|
|
||||||
--hash=sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b \
|
|
||||||
--hash=sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c \
|
|
||||||
--hash=sha256:6344df0d5755a2c9a276d4473ae6b90647e216ab4757f8426893b5dd2ac3f369 \
|
|
||||||
--hash=sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd \
|
|
||||||
--hash=sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824 \
|
|
||||||
--hash=sha256:66291b10affd76d76f54fad28e22e51719ef9ba22b29e1d7d03d6777a9174198 \
|
|
||||||
--hash=sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065 \
|
|
||||||
--hash=sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c \
|
|
||||||
--hash=sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c \
|
|
||||||
--hash=sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764 \
|
|
||||||
--hash=sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196 \
|
|
||||||
--hash=sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b \
|
|
||||||
--hash=sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00 \
|
|
||||||
--hash=sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac \
|
|
||||||
--hash=sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8 \
|
|
||||||
--hash=sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e \
|
|
||||||
--hash=sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28 \
|
|
||||||
--hash=sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3 \
|
|
||||||
--hash=sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5 \
|
|
||||||
--hash=sha256:9c57bb8c96f6d1808c030b1687b9b5fb476abaa47f0db9c0101f5e9f394e97f4 \
|
|
||||||
--hash=sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b \
|
|
||||||
--hash=sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf \
|
|
||||||
--hash=sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5 \
|
|
||||||
--hash=sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702 \
|
|
||||||
--hash=sha256:b30236e45cf30d2b8e7b3e85881719e98507abed1011bf463a8fa23e9c3e98a8 \
|
|
||||||
--hash=sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788 \
|
|
||||||
--hash=sha256:b865addae83924361678b652338317d1bd7e79b1f4596f96b96c77a5a34b34da \
|
|
||||||
--hash=sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d \
|
|
||||||
--hash=sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc \
|
|
||||||
--hash=sha256:bdb2c67c6c1390b63c6ff89f210c8fd09d9a1217a465701eac7316313c915e4c \
|
|
||||||
--hash=sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba \
|
|
||||||
--hash=sha256:c2514fceb77bc5e7a2f7adfaa1feb2fb311607c9cb518dbc378688ec73d8292f \
|
|
||||||
--hash=sha256:c3355370a2c156cffb25e876646f149d5d68f5e0a3ce86a5084dd0b64a994917 \
|
|
||||||
--hash=sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5 \
|
|
||||||
--hash=sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26 \
|
|
||||||
--hash=sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f \
|
|
||||||
--hash=sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b \
|
|
||||||
--hash=sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be \
|
|
||||||
--hash=sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c \
|
|
||||||
--hash=sha256:efd7b85f94a6f21e4932043973a7ba2613b059c4a000551892ac9f1d11f5baf3 \
|
|
||||||
--hash=sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6 \
|
|
||||||
--hash=sha256:fa160448684b4e94d80416c0fa4aac48967a969efe22931448d853ada8baf926 \
|
|
||||||
--hash=sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0
|
|
||||||
# via pre-commit
|
|
||||||
tinycss2==1.4.0 \
|
|
||||||
--hash=sha256:10c0972f6fc0fbee87c3edb76549357415e94548c1ae10ebccdea16fb404a9b7 \
|
|
||||||
--hash=sha256:3a49cf47b7675da0b15d0c6e1df8df4ebd96e9394bb905a5775adb0d884c5289
|
|
||||||
# via
|
|
||||||
# cssselect2
|
|
||||||
# weasyprint
|
|
||||||
tinyhtml5==2.0.0 \
|
|
||||||
--hash=sha256:086f998833da24c300c414d9fe81d9b368fd04cb9d2596a008421cbc705fcfcc \
|
|
||||||
--hash=sha256:13683277c5b176d070f82d099d977194b7a1e26815b016114f581a74bbfbf47e
|
|
||||||
# via weasyprint
|
|
||||||
unoserver==3.4 \
|
|
||||||
--hash=sha256:3dcf2204013def1d1ddd3671f38b11346bdf349fef9728277462666a8a634419 \
|
|
||||||
--hash=sha256:64c24d33d4f65d680a2d9f676518cb28e7fd6c1f9d9a745c33e4a4cb59afdfcd
|
|
||||||
# via -r .github/scripts/requirements_dev.in
|
|
||||||
virtualenv==20.35.4 \
|
|
||||||
--hash=sha256:643d3914d73d3eeb0c552cbb12d7e82adf0e504dbf86a3182f8771a153a1971c \
|
|
||||||
--hash=sha256:c21c9cede36c9753eeade68ba7d523529f228a403463376cf821eaae2b650f1b
|
|
||||||
# via pre-commit
|
|
||||||
weasyprint==66.0 \
|
|
||||||
--hash=sha256:82b0783b726fcd318e2c977dcdddca76515b30044bc7a830cc4fbe717582a6d0 \
|
|
||||||
--hash=sha256:da71dc87dc129ac9cffdc65e5477e90365ab9dbae45c744014ec1d06303dde40
|
|
||||||
# via -r .github/scripts/requirements_dev.in
|
|
||||||
webencodings==0.5.1 \
|
|
||||||
--hash=sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78 \
|
|
||||||
--hash=sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923
|
|
||||||
# via
|
|
||||||
# cssselect2
|
|
||||||
# tinycss2
|
|
||||||
# tinyhtml5
|
|
||||||
zopfli==0.2.3.post1 \
|
|
||||||
--hash=sha256:0aa5f90d6298bda02a95bc8dc8c3c19004d5a4e44bda00b67ca7431d857b4b54 \
|
|
||||||
--hash=sha256:0cc20b02a9531559945324c38302fd4ba763311632d0ec8a1a0aa9c10ea363e6 \
|
|
||||||
--hash=sha256:1d8cc06605519e82b16df090e17cb3990d1158861b2872c3117f1168777b81e4 \
|
|
||||||
--hash=sha256:1f990634fd5c5c8ced8edddd8bd45fab565123b4194d6841e01811292650acae \
|
|
||||||
--hash=sha256:2345e713260a350bea0b01a816a469ea356bc2d63d009a0d777691ecbbcf7493 \
|
|
||||||
--hash=sha256:2768c877f76c8a0e7519b1c86c93757f3c01492ddde55751e9988afb7eff64e1 \
|
|
||||||
--hash=sha256:29ea74e72ffa6e291b8c6f2504ce6c146b4fe990c724c1450eb8e4c27fd31431 \
|
|
||||||
--hash=sha256:34a99592f3d9eb6f737616b5bd74b48a589fdb3cb59a01a50d636ea81d6af272 \
|
|
||||||
--hash=sha256:3654bfc927bc478b1c3f3ff5056ed7b20a1a37fa108ca503256d0a699c03bbb1 \
|
|
||||||
--hash=sha256:3657e416ffb8f31d9d3424af12122bb251befae109f2e271d87d825c92fc5b7b \
|
|
||||||
--hash=sha256:37d011e92f7b9622742c905fdbed9920a1d0361df84142807ea2a528419dea7f \
|
|
||||||
--hash=sha256:3827170de28faf144992d3d4dcf8f3998fe3c8a6a6f4a08f1d42c2ec6119d2bb \
|
|
||||||
--hash=sha256:39e576f93576c5c223b41d9c780bbb91fd6db4babf3223d2a4fe7bf568e2b5a8 \
|
|
||||||
--hash=sha256:3a89277ed5f8c0fb2d0b46d669aa0633123aa7381f1f6118c12f15e0fb48f8ca \
|
|
||||||
--hash=sha256:3c163911f8bad94b3e1db0a572e7c28ba681a0c91d0002ea1e4fa9264c21ef17 \
|
|
||||||
--hash=sha256:3f0197b6aa6eb3086ae9e66d6dd86c4d502b6c68b0ec490496348ae8c05ecaef \
|
|
||||||
--hash=sha256:48dba9251060289101343110ab47c0756f66f809bb4d1ddbb6d5c7e7752115c5 \
|
|
||||||
--hash=sha256:4915a41375bdee4db749ecd07d985a0486eb688a6619f713b7bf6fbfd145e960 \
|
|
||||||
--hash=sha256:4c1226a7e2c7105ac31503a9bb97454743f55d88164d6d46bc138051b77f609b \
|
|
||||||
--hash=sha256:4e50ffac74842c1c1018b9b73875a0d0a877c066ab06bf7cccbaa84af97e754f \
|
|
||||||
--hash=sha256:518f1f4ed35dd69ce06b552f84e6d081f07c552b4c661c5312d950a0b764a58a \
|
|
||||||
--hash=sha256:5aad740b4d4fcbaaae4887823925166ffd062db3b248b3f432198fc287381d1a \
|
|
||||||
--hash=sha256:5f272186e03ad55e7af09ab78055535c201b1a0bcc2944edb1768298d9c483a4 \
|
|
||||||
--hash=sha256:5fcfc0dc2761e4fcc15ad5d273b4d58c2e8e059d3214a7390d4d3c8e2aee644e \
|
|
||||||
--hash=sha256:60db20f06c3d4c5934b16cfa62a2cc5c3f0686bffe0071ed7804d3c31ab1a04e \
|
|
||||||
--hash=sha256:615a8ac9dda265e9cc38b2a76c3142e4a9f30fea4a79c85f670850783bc6feb4 \
|
|
||||||
--hash=sha256:6482db9876c68faac2d20a96b566ffbf65ddaadd97b222e4e73641f4f8722fc4 \
|
|
||||||
--hash=sha256:6617fb10f9e4393b331941861d73afb119cd847e88e4974bdbe8068ceef3f73f \
|
|
||||||
--hash=sha256:676919fba7311125244eb0c4393679ac5fe856e5864a15d122bd815205369fa0 \
|
|
||||||
--hash=sha256:6c2d2bc8129707e34c51f9352c4636ca313b52350bbb7e04637c46c1818a2a70 \
|
|
||||||
--hash=sha256:71390dbd3fbf6ebea9a5d85ffed8c26ee1453ee09248e9b88486e30e0397b775 \
|
|
||||||
--hash=sha256:716cdbfc57bfd3d3e31a58e6246e8190e6849b7dbb7c4ce39ef8bbf0edb8f6d5 \
|
|
||||||
--hash=sha256:75a26a2307b10745a83b660c404416e984ee6fca515ec7f0765f69af3ce08072 \
|
|
||||||
--hash=sha256:7be5cc6732eb7b4df17305d8a7b293223f934a31783a874a01164703bc1be6cd \
|
|
||||||
--hash=sha256:7cce242b5df12b2b172489daf19c32e5577dd2fac659eb4b17f6a6efb446fd5c \
|
|
||||||
--hash=sha256:81c341d9bb87a6dbbb0d45d6e272aca80c7c97b4b210f9b6e233bf8b87242f29 \
|
|
||||||
--hash=sha256:89899641d4de97dbad8e0cde690040d078b6aea04066dacaab98e0b5a23573f2 \
|
|
||||||
--hash=sha256:8d5ab297d660b75c159190ce6d73035502310e40fd35170aed7d1a1aea7ddd65 \
|
|
||||||
--hash=sha256:8fbe5bcf10d01aab3513550f284c09fef32f342b36f56bfae2120a9c4d12c130 \
|
|
||||||
--hash=sha256:91a2327a4d7e77471fa4fbb26991c6de4a738c6fc6a33e09bb25f56a870a4b7b \
|
|
||||||
--hash=sha256:95a260cafd56b8fffa679918937401c80bb38e1681c448b988022e4c3610965d \
|
|
||||||
--hash=sha256:96484dc0f48be1c5d7ae9f38ed1ce41e3675fd506b27c11a6607f14b49101e99 \
|
|
||||||
--hash=sha256:9a6aec38a989bad7ddd1ef53f1265699e49e294d08231b5313d61293f3cd6237 \
|
|
||||||
--hash=sha256:9ba214f4f45bec195ee8559651154d3ac2932470b9d91c5715fc29c013349f8c \
|
|
||||||
--hash=sha256:9f4a7ec2770e6af05f5a02733fd3900f30a9cd58e5d6d3727e14c5bcd6e7d587 \
|
|
||||||
--hash=sha256:a1cf720896d2ce998bc8e051d4b4ce0d8bec007aab6243102e8e1d22a0b2fb3f \
|
|
||||||
--hash=sha256:a241a68581d34d67b40c425cce3d1fd211c092f99d9250947824ccba9f491949 \
|
|
||||||
--hash=sha256:a53b18797cdef27e019db595d66c4b077325afe2fd62145953275f53d84ce40c \
|
|
||||||
--hash=sha256:a82fc2dbebe6eb908b9c665e71496f8525c1bc4d2e3a7a7722ef2b128b6227c8 \
|
|
||||||
--hash=sha256:a86eb88e06bd87e1fff31dac878965c26b0c26db59ddcf78bb0379a954b120de \
|
|
||||||
--hash=sha256:aa588b21044f8a74e423d8c8a4c7fc9988501878aacced793467010039c50734 \
|
|
||||||
--hash=sha256:b05296e8bc88c92e2b21e0a9bae4740c1551ee613c1d93a51fd28a7a0b2b6fbb \
|
|
||||||
--hash=sha256:b0ec13f352ea5ae0fc91f98a48540512eed0767d0ec4f7f3cb92d92797983d18 \
|
|
||||||
--hash=sha256:b3df42f52502438ee973042cc551877d24619fa1cd38ef7b7e9ac74200daca8b \
|
|
||||||
--hash=sha256:b78008a69300d929ca2efeffec951b64a312e9a811e265ea4a907ab546d79fa6 \
|
|
||||||
--hash=sha256:b9026a21b6d41eb0e2e63f5bc1242c3fcc43ecb770963cda99a4307863dac12e \
|
|
||||||
--hash=sha256:bbe429fc50686bb2a2608a30843e36fbaa123462a5284f136c7d9e0145220bfd \
|
|
||||||
--hash=sha256:bfa1eb759e07d8b7aa7a310a2bc535e127ee70addf90dc8d4b946b593c3e51a8 \
|
|
||||||
--hash=sha256:c1e0ed5d84ffa2d677cc9582fc01e61dab2e7ef8b8996e055f0a76167b1b94df \
|
|
||||||
--hash=sha256:c4278d1873ce6e803e5d4f8d702fd3026bd67fca744aa98881324d1157ddf748 \
|
|
||||||
--hash=sha256:cac2b37ab21c2b36a10b685b1893ebd6b0f83ae26004838ac817680881576567 \
|
|
||||||
--hash=sha256:cbe6df25807227519debd1a57ab236f5f6bad441500e85b13903e51f93a43214 \
|
|
||||||
--hash=sha256:cd2c002f160502608dcc822ed2441a0f4509c52e86fcfd1a09e937278ed1ca14 \
|
|
||||||
--hash=sha256:e0137dd64a493ba6a4be37405cfd6febe650a98cc1e9dca8f6b8c63b1db11b41 \
|
|
||||||
--hash=sha256:e63d558847166543c2c9789e6f985400a520b7eacc4b99181668b2c3aeadd352 \
|
|
||||||
--hash=sha256:eb45a34f23da4f8bc712b6376ca5396914b0b7c09adbb001dad964eb7f3132f8 \
|
|
||||||
--hash=sha256:ecb7572df5372abce8073df078207d9d1749f20b8b136089916a4a0868d56051 \
|
|
||||||
--hash=sha256:f12000a6accdd4bf0a3fa6eaa1b1c7a7bc80af0a2edf3f89d770d3dcce1d0e22 \
|
|
||||||
--hash=sha256:f7d69c1a7168ad0e9cb864e8663acb232986a0c9c9cb9801f56bf6214f53a54d \
|
|
||||||
--hash=sha256:f815fcc2b2a457977724bad97fb4854022980f51ce7b136925e336b530545ae1 \
|
|
||||||
--hash=sha256:fc39f5c27f962ec8660d8d20c24762431131b5d8c672b44b0a54cf2b5bcde9b9
|
|
||||||
# via fonttools
|
|
||||||
|
|
||||||
# The following packages are considered to be unsafe in a requirements file:
|
|
||||||
pip==25.3 \
|
|
||||||
--hash=sha256:8d0538dbbd7babbd207f261ed969c65de439f6bc9e5dbd3b3b9a77f25d95f343 \
|
|
||||||
--hash=sha256:9655943313a94722b7774661c21049070f6bbb0a1516bf02f7c8d5d9201514cd
|
|
||||||
# via -r .github/scripts/requirements_dev.in
|
|
||||||
setuptools==80.9.0 \
|
|
||||||
--hash=sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922 \
|
|
||||||
--hash=sha256:f36b47402ecde768dbfafc46e8e4207b4360c654f1f3bb84475f0a28628fb19c
|
|
||||||
# via -r .github/scripts/requirements_dev.in
|
|
||||||
@@ -1,113 +1,93 @@
|
|||||||
#
|
#
|
||||||
# This file is autogenerated by pip-compile with Python 3.12
|
# This file is autogenerated by pip-compile with Python 3.10
|
||||||
# by the following command:
|
# by the following command:
|
||||||
#
|
#
|
||||||
# pip-compile --generate-hashes --output-file='.github\scripts\requirements_pre_commit.txt' --strip-extras '.github\scripts\requirements_pre_commit.in'
|
# pip-compile --generate-hashes --output-file='.github\scripts\requirements_pre_commit.txt' --strip-extras '.github\scripts\requirements_pre_commit.in'
|
||||||
#
|
#
|
||||||
cfgv==3.5.0 \
|
cfgv==3.4.0 \
|
||||||
--hash=sha256:a8dc6b26ad22ff227d2634a65cb388215ce6cc96bbcc5cfde7641ae87e8dacc0 \
|
--hash=sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9 \
|
||||||
--hash=sha256:d5b1034354820651caa73ede66a6294d6e95c1b00acc5e9b098e917404669132
|
--hash=sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560
|
||||||
# via pre-commit
|
# via pre-commit
|
||||||
distlib==0.4.0 \
|
distlib==0.3.9 \
|
||||||
--hash=sha256:9659f7d87e46584a30b5780e43ac7a2143098441670ff0a49d5f9034c54a6c16 \
|
--hash=sha256:47f8c22fd27c27e25a65601af709b38e4f0a45ea4fc2e710f65755fa8caaaf87 \
|
||||||
--hash=sha256:feec40075be03a04501a973d81f633735b4b69f98b05450592310c0f401a4e0d
|
--hash=sha256:a60f20dea646b8a33f3e7772f74dc0b2d0772d2837ee1342a00645c81edf9403
|
||||||
# via virtualenv
|
# via virtualenv
|
||||||
filelock==3.20.0 \
|
filelock==3.18.0 \
|
||||||
--hash=sha256:339b4732ffda5cd79b13f4e2711a31b0365ce445d95d243bb996273d072546a2 \
|
--hash=sha256:adbc88eabb99d2fec8c9c1b229b171f18afa655400173ddc653d5d01501fb9f2 \
|
||||||
--hash=sha256:711e943b4ec6be42e1d4e6690b48dc175c822967466bb31c0c293f34334c13f4
|
--hash=sha256:c401f4f8377c4464e6db25fff06205fd89bdd83b65eb0488ed1b160f780e21de
|
||||||
# via virtualenv
|
# via virtualenv
|
||||||
identify==2.6.15 \
|
identify==2.6.12 \
|
||||||
--hash=sha256:1181ef7608e00704db228516541eb83a88a9f94433a8c80bb9b5bd54b1d81757 \
|
--hash=sha256:ad9672d5a72e0d2ff7c5c8809b62dfa60458626352fb0eb7b55e69bdc45334a2 \
|
||||||
--hash=sha256:e4f4864b96c6557ef2a1e1c951771838f4edc9df3a72ec7118b338801b11c7bf
|
--hash=sha256:d8de45749f1efb108badef65ee8386f0f7bb19a7f26185f74de6367bffbaf0e6
|
||||||
# via pre-commit
|
# via pre-commit
|
||||||
nodeenv==1.9.1 \
|
nodeenv==1.9.1 \
|
||||||
--hash=sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f \
|
--hash=sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f \
|
||||||
--hash=sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9
|
--hash=sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9
|
||||||
# via pre-commit
|
# via pre-commit
|
||||||
platformdirs==4.5.0 \
|
platformdirs==4.3.8 \
|
||||||
--hash=sha256:70ddccdd7c99fc5942e9fc25636a8b34d04c24b335100223152c2803e4063312 \
|
--hash=sha256:3d512d96e16bcb959a814c9f348431070822a6496326a4be0911c40b5a74c2bc \
|
||||||
--hash=sha256:e578a81bb873cbb89a41fcc904c7ef523cc18284b7e3b3ccf06aca1403b7ebd3
|
--hash=sha256:ff7059bb7eb1179e2685604f4aaf157cfd9535242bd23742eadc3c13542139b4
|
||||||
# via virtualenv
|
# via virtualenv
|
||||||
pre-commit==4.5.0 \
|
pre-commit==4.2.0 \
|
||||||
--hash=sha256:25e2ce09595174d9c97860a95609f9f852c0614ba602de3561e267547f2335e1 \
|
--hash=sha256:601283b9757afd87d40c4c4a9b2b5de9637a8ea02eaff7adc2d0fb4e04841146 \
|
||||||
--hash=sha256:dc5a065e932b19fc1d4c653c6939068fe54325af8e741e74e88db4d28a4dd66b
|
--hash=sha256:a009ca7205f1eb497d10b845e52c838a98b6cdd2102a6c8e4540e94ee75c58bd
|
||||||
# via -r .github/scripts/requirements_pre_commit.in
|
# via -r .github\scripts\requirements_pre_commit.in
|
||||||
pyyaml==6.0.3 \
|
pyyaml==6.0.2 \
|
||||||
--hash=sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c \
|
--hash=sha256:01179a4a8559ab5de078078f37e5c1a30d76bb88519906844fd7bdea1b7729ff \
|
||||||
--hash=sha256:0150219816b6a1fa26fb4699fb7daa9caf09eb1999f3b70fb6e786805e80375a \
|
--hash=sha256:0833f8694549e586547b576dcfaba4a6b55b9e96098b36cdc7ebefe667dfed48 \
|
||||||
--hash=sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3 \
|
--hash=sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086 \
|
||||||
--hash=sha256:02ea2dfa234451bbb8772601d7b8e426c2bfa197136796224e50e35a78777956 \
|
--hash=sha256:0b69e4ce7a131fe56b7e4d770c67429700908fc0752af059838b1cfb41960e4e \
|
||||||
--hash=sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6 \
|
--hash=sha256:0ffe8360bab4910ef1b9e87fb812d8bc0a308b0d0eef8c8f44e0254ab3b07133 \
|
||||||
--hash=sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c \
|
--hash=sha256:11d8f3dd2b9c1207dcaf2ee0bbbfd5991f571186ec9cc78427ba5bd32afae4b5 \
|
||||||
--hash=sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65 \
|
--hash=sha256:17e311b6c678207928d649faa7cb0d7b4c26a0ba73d41e99c4fff6b6c3276484 \
|
||||||
--hash=sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a \
|
--hash=sha256:1e2120ef853f59c7419231f3bf4e7021f1b936f6ebd222406c3b60212205d2ee \
|
||||||
--hash=sha256:1ebe39cb5fc479422b83de611d14e2c0d3bb2a18bbcb01f229ab3cfbd8fee7a0 \
|
--hash=sha256:1f71ea527786de97d1a0cc0eacd1defc0985dcf6b3f17bb77dcfc8c34bec4dc5 \
|
||||||
--hash=sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b \
|
--hash=sha256:23502f431948090f597378482b4812b0caae32c22213aecf3b55325e049a6c68 \
|
||||||
--hash=sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1 \
|
--hash=sha256:24471b829b3bf607e04e88d79542a9d48bb037c2267d7927a874e6c205ca7e9a \
|
||||||
--hash=sha256:22ba7cfcad58ef3ecddc7ed1db3409af68d023b7f940da23c6c2a1890976eda6 \
|
--hash=sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf \
|
||||||
--hash=sha256:27c0abcb4a5dac13684a37f76e701e054692a9b2d3064b70f5e4eb54810553d7 \
|
--hash=sha256:2e99c6826ffa974fe6e27cdb5ed0021786b03fc98e5ee3c5bfe1fd5015f42b99 \
|
||||||
--hash=sha256:28c8d926f98f432f88adc23edf2e6d4921ac26fb084b028c733d01868d19007e \
|
--hash=sha256:39693e1f8320ae4f43943590b49779ffb98acb81f788220ea932a6b6c51004d8 \
|
||||||
--hash=sha256:2e71d11abed7344e42a8849600193d15b6def118602c4c176f748e4583246007 \
|
--hash=sha256:3ad2a3decf9aaba3d29c8f537ac4b243e36bef957511b4766cb0057d32b0be85 \
|
||||||
--hash=sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310 \
|
--hash=sha256:3b1fdb9dc17f5a7677423d508ab4f243a726dea51fa5e70992e59a7411c89d19 \
|
||||||
--hash=sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4 \
|
--hash=sha256:41e4e3953a79407c794916fa277a82531dd93aad34e29c2a514c2c0c5fe971cc \
|
||||||
--hash=sha256:3c5677e12444c15717b902a5798264fa7909e41153cdf9ef7ad571b704a63dd9 \
|
--hash=sha256:43fa96a3ca0d6b1812e01ced1044a003533c47f6ee8aca31724f78e93ccc089a \
|
||||||
--hash=sha256:3ff07ec89bae51176c0549bc4c63aa6202991da2d9a6129d7aef7f1407d3f295 \
|
--hash=sha256:50187695423ffe49e2deacb8cd10510bc361faac997de9efef88badc3bb9e2d1 \
|
||||||
--hash=sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea \
|
--hash=sha256:5ac9328ec4831237bec75defaf839f7d4564be1e6b25ac710bd1a96321cc8317 \
|
||||||
--hash=sha256:418cf3f2111bc80e0933b2cd8cd04f286338bb88bdc7bc8e6dd775ebde60b5e0 \
|
--hash=sha256:5d225db5a45f21e78dd9358e58a98702a0302f2659a3c6cd320564b75b86f47c \
|
||||||
--hash=sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e \
|
--hash=sha256:6395c297d42274772abc367baaa79683958044e5d3835486c16da75d2a694631 \
|
||||||
--hash=sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac \
|
--hash=sha256:688ba32a1cffef67fd2e9398a2efebaea461578b0923624778664cc1c914db5d \
|
||||||
--hash=sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9 \
|
--hash=sha256:68ccc6023a3400877818152ad9a1033e3db8625d899c72eacb5a668902e4d652 \
|
||||||
--hash=sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7 \
|
--hash=sha256:70b189594dbe54f75ab3a1acec5f1e3faa7e8cf2f1e08d9b561cb41b845f69d5 \
|
||||||
--hash=sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35 \
|
--hash=sha256:797b4f722ffa07cc8d62053e4cff1486fa6dc094105d13fea7b1de7d8bf71c9e \
|
||||||
--hash=sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb \
|
--hash=sha256:7c36280e6fb8385e520936c3cb3b8042851904eba0e58d277dca80a5cfed590b \
|
||||||
--hash=sha256:5cf4e27da7e3fbed4d6c3d8e797387aaad68102272f8f9752883bc32d61cb87b \
|
--hash=sha256:7e7401d0de89a9a855c839bc697c079a4af81cf878373abd7dc625847d25cbd8 \
|
||||||
--hash=sha256:5e0b74767e5f8c593e8c9b5912019159ed0533c70051e9cce3e8b6aa699fcd69 \
|
--hash=sha256:80bab7bfc629882493af4aa31a4cfa43a4c57c83813253626916b8c7ada83476 \
|
||||||
--hash=sha256:5ed875a24292240029e4483f9d4a4b8a1ae08843b9c54f43fcc11e404532a8a5 \
|
--hash=sha256:82d09873e40955485746739bcb8b4586983670466c23382c19cffecbf1fd8706 \
|
||||||
--hash=sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b \
|
--hash=sha256:8388ee1976c416731879ac16da0aff3f63b286ffdd57cdeb95f3f2e085687563 \
|
||||||
--hash=sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c \
|
--hash=sha256:8824b5a04a04a047e72eea5cec3bc266db09e35de6bdfe34c9436ac5ee27d237 \
|
||||||
--hash=sha256:6344df0d5755a2c9a276d4473ae6b90647e216ab4757f8426893b5dd2ac3f369 \
|
--hash=sha256:8b9c7197f7cb2738065c481a0461e50ad02f18c78cd75775628afb4d7137fb3b \
|
||||||
--hash=sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd \
|
--hash=sha256:9056c1ecd25795207ad294bcf39f2db3d845767be0ea6e6a34d856f006006083 \
|
||||||
--hash=sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824 \
|
--hash=sha256:936d68689298c36b53b29f23c6dbb74de12b4ac12ca6cfe0e047bedceea56180 \
|
||||||
--hash=sha256:66291b10affd76d76f54fad28e22e51719ef9ba22b29e1d7d03d6777a9174198 \
|
--hash=sha256:9b22676e8097e9e22e36d6b7bda33190d0d400f345f23d4065d48f4ca7ae0425 \
|
||||||
--hash=sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065 \
|
--hash=sha256:a4d3091415f010369ae4ed1fc6b79def9416358877534caf6a0fdd2146c87a3e \
|
||||||
--hash=sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c \
|
--hash=sha256:a8786accb172bd8afb8be14490a16625cbc387036876ab6ba70912730faf8e1f \
|
||||||
--hash=sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c \
|
--hash=sha256:a9f8c2e67970f13b16084e04f134610fd1d374bf477b17ec1599185cf611d725 \
|
||||||
--hash=sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764 \
|
--hash=sha256:bc2fa7c6b47d6bc618dd7fb02ef6fdedb1090ec036abab80d4681424b84c1183 \
|
||||||
--hash=sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196 \
|
--hash=sha256:c70c95198c015b85feafc136515252a261a84561b7b1d51e3384e0655ddf25ab \
|
||||||
--hash=sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b \
|
--hash=sha256:cc1c1159b3d456576af7a3e4d1ba7e6924cb39de8f67111c735f6fc832082774 \
|
||||||
--hash=sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00 \
|
--hash=sha256:ce826d6ef20b1bc864f0a68340c8b3287705cae2f8b4b1d932177dcc76721725 \
|
||||||
--hash=sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac \
|
--hash=sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e \
|
||||||
--hash=sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8 \
|
--hash=sha256:d7fded462629cfa4b685c5416b949ebad6cec74af5e2d42905d41e257e0869f5 \
|
||||||
--hash=sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e \
|
--hash=sha256:d84a1718ee396f54f3a086ea0a66d8e552b2ab2017ef8b420e92edbc841c352d \
|
||||||
--hash=sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28 \
|
--hash=sha256:d8e03406cac8513435335dbab54c0d385e4a49e4945d2909a581c83647ca0290 \
|
||||||
--hash=sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3 \
|
--hash=sha256:e10ce637b18caea04431ce14fabcf5c64a1c61ec9c56b071a4b7ca131ca52d44 \
|
||||||
--hash=sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5 \
|
--hash=sha256:ec031d5d2feb36d1d1a24380e4db6d43695f3748343d99434e6f5f9156aaa2ed \
|
||||||
--hash=sha256:9c57bb8c96f6d1808c030b1687b9b5fb476abaa47f0db9c0101f5e9f394e97f4 \
|
--hash=sha256:ef6107725bd54b262d6dedcc2af448a266975032bc85ef0172c5f059da6325b4 \
|
||||||
--hash=sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b \
|
--hash=sha256:efdca5630322a10774e8e98e1af481aad470dd62c3170801852d752aa7a783ba \
|
||||||
--hash=sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf \
|
--hash=sha256:f753120cb8181e736c57ef7636e83f31b9c0d1722c516f7e86cf15b7aa57ff12 \
|
||||||
--hash=sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5 \
|
--hash=sha256:ff3824dc5261f50c9b0dfb3be22b4567a6f938ccce4587b38952d85fd9e9afe4
|
||||||
--hash=sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702 \
|
|
||||||
--hash=sha256:b30236e45cf30d2b8e7b3e85881719e98507abed1011bf463a8fa23e9c3e98a8 \
|
|
||||||
--hash=sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788 \
|
|
||||||
--hash=sha256:b865addae83924361678b652338317d1bd7e79b1f4596f96b96c77a5a34b34da \
|
|
||||||
--hash=sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d \
|
|
||||||
--hash=sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc \
|
|
||||||
--hash=sha256:bdb2c67c6c1390b63c6ff89f210c8fd09d9a1217a465701eac7316313c915e4c \
|
|
||||||
--hash=sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba \
|
|
||||||
--hash=sha256:c2514fceb77bc5e7a2f7adfaa1feb2fb311607c9cb518dbc378688ec73d8292f \
|
|
||||||
--hash=sha256:c3355370a2c156cffb25e876646f149d5d68f5e0a3ce86a5084dd0b64a994917 \
|
|
||||||
--hash=sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5 \
|
|
||||||
--hash=sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26 \
|
|
||||||
--hash=sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f \
|
|
||||||
--hash=sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b \
|
|
||||||
--hash=sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be \
|
|
||||||
--hash=sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c \
|
|
||||||
--hash=sha256:efd7b85f94a6f21e4932043973a7ba2613b059c4a000551892ac9f1d11f5baf3 \
|
|
||||||
--hash=sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6 \
|
|
||||||
--hash=sha256:fa160448684b4e94d80416c0fa4aac48967a969efe22931448d853ada8baf926 \
|
|
||||||
--hash=sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0
|
|
||||||
# via pre-commit
|
# via pre-commit
|
||||||
virtualenv==20.35.4 \
|
virtualenv==20.31.2 \
|
||||||
--hash=sha256:643d3914d73d3eeb0c552cbb12d7e82adf0e504dbf86a3182f8771a153a1971c \
|
--hash=sha256:36efd0d9650ee985f0cad72065001e66d49a6f24eb44d98980f630686243cf11 \
|
||||||
--hash=sha256:c21c9cede36c9753eeade68ba7d523529f228a403463376cf821eaae2b650f1b
|
--hash=sha256:e10c0a9d02835e592521be48b332b6caee6887f332c111aa79a09b9e79efc2af
|
||||||
# via pre-commit
|
# via pre-commit
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
tomlkit
|
tomlkit
|
||||||
tomli-w
|
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
#
|
#
|
||||||
# This file is autogenerated by pip-compile with Python 3.12
|
# This file is autogenerated by pip-compile with Python 3.10
|
||||||
# by the following command:
|
# by the following command:
|
||||||
#
|
#
|
||||||
# pip-compile --generate-hashes --output-file='.github\scripts\requirements_sync_readme.txt' --strip-extras '.github\scripts\requirements_sync_readme.in'
|
# pip-compile --generate-hashes --output-file='.github\scripts\requirements_sync_readme.txt' --strip-extras '.github\scripts\requirements_sync_readme.in'
|
||||||
#
|
#
|
||||||
tomli-w==1.2.0 \
|
|
||||||
--hash=sha256:188306098d013b691fcadc011abd66727d3c414c571bb01b1a174ba8c983cf90 \
|
|
||||||
--hash=sha256:2dd14fac5a47c27be9cd4c976af5a12d87fb1f0b4512f81d69cce3b35ae25021
|
|
||||||
# via -r .github/scripts/requirements_sync_readme.in
|
|
||||||
tomlkit==0.13.3 \
|
tomlkit==0.13.3 \
|
||||||
--hash=sha256:430cf247ee57df2b94ee3fbe588e71d362a941ebb545dec29b53961d61add2a1 \
|
--hash=sha256:430cf247ee57df2b94ee3fbe588e71d362a941ebb545dec29b53961d61add2a1 \
|
||||||
--hash=sha256:c89c649d79ee40629a9fda55f8ace8c6a1b42deb912b2a8fd8d942ddadb606b0
|
--hash=sha256:c89c649d79ee40629a9fda55f8ace8c6a1b42deb912b2a8fd8d942ddadb606b0
|
||||||
# via -r .github/scripts/requirements_sync_readme.in
|
# via -r .github\scripts\requirements_sync_readme.in
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ on:
|
|||||||
allow_fork:
|
allow_fork:
|
||||||
description: "Allow deploying fork PR?"
|
description: "Allow deploying fork PR?"
|
||||||
required: false
|
required: false
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- "true"
|
|
||||||
- "false"
|
|
||||||
default: "false"
|
default: "false"
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -35,18 +31,18 @@ jobs:
|
|||||||
pr_ref: ${{ steps.resolve.outputs.ref }}
|
pr_ref: ${{ steps.resolve.outputs.ref }}
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Resolve PR info
|
- name: Resolve PR info
|
||||||
id: resolve
|
id: resolve
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const { owner, repo } = context.repo;
|
const { owner, repo } = context.repo;
|
||||||
let prNumber = context.eventName === 'workflow_dispatch'
|
let prNumber = context.eventName === 'workflow_dispatch'
|
||||||
? parseInt(context.payload.inputs.pr, 10)
|
? parseInt(process.env.INPUT_PR, 10)
|
||||||
: context.payload.number;
|
: context.payload.number;
|
||||||
|
|
||||||
if (!Number.isInteger(prNumber)) { core.setFailed('Invalid PR number'); return; }
|
if (!Number.isInteger(prNumber)) { core.setFailed('Invalid PR number'); return; }
|
||||||
@@ -56,6 +52,7 @@ jobs:
|
|||||||
core.setOutput('repository', pr.head.repo.full_name);
|
core.setOutput('repository', pr.head.repo.full_name);
|
||||||
core.setOutput('ref', pr.head.ref);
|
core.setOutput('ref', pr.head.ref);
|
||||||
core.setOutput('is_fork', String(pr.head.repo.fork));
|
core.setOutput('is_fork', String(pr.head.repo.fork));
|
||||||
|
core.setOutput('base_ref', pr.base.ref);
|
||||||
core.setOutput('author', pr.user.login);
|
core.setOutput('author', pr.user.login);
|
||||||
core.setOutput('state', pr.state);
|
core.setOutput('state', pr.state);
|
||||||
|
|
||||||
@@ -68,6 +65,10 @@ jobs:
|
|||||||
IS_FORK: ${{ steps.resolve.outputs.is_fork }}
|
IS_FORK: ${{ steps.resolve.outputs.is_fork }}
|
||||||
# nur bei workflow_dispatch gesetzt:
|
# nur bei workflow_dispatch gesetzt:
|
||||||
ALLOW_FORK_INPUT: ${{ inputs.allow_fork }}
|
ALLOW_FORK_INPUT: ${{ inputs.allow_fork }}
|
||||||
|
# für Auto-PR-Logik:
|
||||||
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
||||||
|
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
|
||||||
|
PR_BASE: ${{ steps.resolve.outputs.base_ref }}
|
||||||
PR_AUTHOR: ${{ steps.resolve.outputs.author }}
|
PR_AUTHOR: ${{ steps.resolve.outputs.author }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@@ -86,10 +87,16 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
auth_users=("Frooodle" "sf298" "Ludy87" "LaserKaspar" "sbplat" "reecebrowne" "DarioGii" "ConnorYoh" "EthanHealy01" "jbrunton96" "balazs-szucs")
|
auth_users=("Frooodle" "sf298" "Ludy87" "LaserKaspar" "sbplat" "reecebrowne" "DarioGii" "ConnorYoh" "EthanHealy01" "jbrunton96")
|
||||||
is_auth=false; for u in "${auth_users[@]}"; do [ "$u" = "$PR_AUTHOR" ] && is_auth=true && break; done
|
is_auth=false; for u in "${auth_users[@]}"; do [ "$u" = "$PR_AUTHOR" ] && is_auth=true && break; done
|
||||||
if [ "$is_auth" = true ]; then
|
if [ "$PR_BASE" = "V2" ] && [ "$is_auth" = true ]; then
|
||||||
should=true
|
should=true
|
||||||
|
else
|
||||||
|
title_has_v2=false; echo "$PR_TITLE" | grep -qiE 'v2|version.?2|version.?two' && title_has_v2=true
|
||||||
|
branch_has_kw=false; echo "$PR_BRANCH" | grep -qiE 'v2|react' && branch_has_kw=true
|
||||||
|
if [ "$is_auth" = true ] && { [ "$title_has_v2" = true ] || [ "$branch_has_kw" = true ]; }; then
|
||||||
|
should=true
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -111,12 +118,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout main repository
|
- name: Checkout main repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
with:
|
with:
|
||||||
repository: ${{ github.repository }}
|
repository: ${{ github.repository }}
|
||||||
ref: main
|
ref: main
|
||||||
@@ -132,13 +139,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Add deployment started comment
|
- name: Add deployment started comment
|
||||||
id: deployment-started
|
id: deployment-started
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
const { owner, repo } = context.repo;
|
const { owner, repo } = context.repo;
|
||||||
const prNumber = ${{ needs.check-pr.outputs.pr_number }};
|
const prNumber = ${{ needs.check-pr.outputs.pr_number }};
|
||||||
|
|
||||||
// Delete previous V2 deployment comments to avoid clutter
|
// Delete previous V2 deployment comments to avoid clutter
|
||||||
const { data: comments } = await github.rest.issues.listComments({
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
owner,
|
owner,
|
||||||
@@ -161,26 +168,26 @@ jobs:
|
|||||||
comment_id: comment.id
|
comment_id: comment.id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new deployment started comment
|
// Create new deployment started comment
|
||||||
const { data: newComment } = await github.rest.issues.createComment({
|
const { data: newComment } = await github.rest.issues.createComment({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
issue_number: prNumber,
|
issue_number: prNumber,
|
||||||
body: `🚀 **Auto-deploying V2 version** for PR #${prNumber}...\n\n_This is an automated deployment for approved V2 contributors._\n\n⚠️ **Note:** If new commits are pushed during deployment, this build will be cancelled and replaced with the latest version.`
|
body: `🚀 **Auto-deploying V2 version** for PR #${prNumber}...\n\n_This is an automated deployment triggered by V2/version2 keywords in the PR title or V2/React keywords in the branch name._\n\n⚠️ **Note:** If new commits are pushed during deployment, this build will be cancelled and replaced with the latest version.`
|
||||||
});
|
});
|
||||||
return newComment.id;
|
return newComment.id;
|
||||||
|
|
||||||
- name: Checkout PR
|
- name: Checkout PR
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
with:
|
with:
|
||||||
repository: ${{ needs.check-pr.outputs.pr_repository }}
|
repository: ${{ needs.check-pr.outputs.pr_repository }}
|
||||||
ref: ${{ needs.check-pr.outputs.pr_ref }}
|
ref: ${{ needs.check-pr.outputs.pr_ref }}
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
fetch-depth: 0 # Fetch full history for commit hash detection
|
fetch-depth: 0 # Fetch full history for commit hash detection
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
||||||
|
|
||||||
- name: Get version number
|
- name: Get version number
|
||||||
id: versionNumber
|
id: versionNumber
|
||||||
@@ -189,56 +196,93 @@ jobs:
|
|||||||
echo "versionNumber=$VERSION" >> $GITHUB_OUTPUT
|
echo "versionNumber=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_HUB_API }}
|
password: ${{ secrets.DOCKER_HUB_API }}
|
||||||
|
|
||||||
- name: Get commit hash for app
|
- name: Get commit hashes for frontend and backend
|
||||||
id: commit-hash
|
id: commit-hashes
|
||||||
run: |
|
run: |
|
||||||
# Get last commit that touched the application code
|
# Get last commit that touched the frontend folder, docker/frontend, or docker/compose
|
||||||
APP_HASH=$(git log -1 --format="%H" -- . 2>/dev/null || echo "")
|
FRONTEND_HASH=$(git log -1 --format="%H" -- frontend/ docker/frontend/ docker/compose/ 2>/dev/null || echo "")
|
||||||
if [ -z "$APP_HASH" ]; then
|
if [ -z "$FRONTEND_HASH" ]; then
|
||||||
APP_HASH="no-changes"
|
FRONTEND_HASH="no-frontend-changes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "App hash: $APP_HASH"
|
# Get last commit that touched backend code, docker/backend, or docker/compose
|
||||||
echo "app_hash=$APP_HASH" >> $GITHUB_OUTPUT
|
BACKEND_HASH=$(git log -1 --format="%H" -- app/ docker/backend/ docker/compose/ 2>/dev/null || echo "")
|
||||||
|
if [ -z "$BACKEND_HASH" ]; then
|
||||||
# Short hash for tags
|
BACKEND_HASH="no-backend-changes"
|
||||||
if [ "$APP_HASH" = "no-changes" ]; then
|
fi
|
||||||
echo "app_short=no-changes" >> $GITHUB_OUTPUT
|
|
||||||
|
echo "Frontend hash: $FRONTEND_HASH"
|
||||||
|
echo "Backend hash: $BACKEND_HASH"
|
||||||
|
|
||||||
|
echo "frontend_hash=$FRONTEND_HASH" >> $GITHUB_OUTPUT
|
||||||
|
echo "backend_hash=$BACKEND_HASH" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
# Short hashes for tags
|
||||||
|
if [ "$FRONTEND_HASH" = "no-frontend-changes" ]; then
|
||||||
|
echo "frontend_short=no-frontend" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "app_short=${APP_HASH:0:8}" >> $GITHUB_OUTPUT
|
echo "frontend_short=${FRONTEND_HASH:0:8}" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$BACKEND_HASH" = "no-backend-changes" ]; then
|
||||||
|
echo "backend_short=no-backend" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "backend_short=${BACKEND_HASH:0:8}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Check if image exists
|
- name: Check if frontend image exists
|
||||||
id: check-image
|
id: check-frontend
|
||||||
run: |
|
run: |
|
||||||
if docker manifest inspect ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-${{ steps.commit-hash.outputs.app_short }} >/dev/null 2>&1; then
|
if docker manifest inspect ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }} >/dev/null 2>&1; then
|
||||||
echo "exists=true" >> $GITHUB_OUTPUT
|
echo "exists=true" >> $GITHUB_OUTPUT
|
||||||
echo "Image already exists, skipping build"
|
echo "Frontend image already exists, skipping build"
|
||||||
else
|
else
|
||||||
echo "exists=false" >> $GITHUB_OUTPUT
|
echo "exists=false" >> $GITHUB_OUTPUT
|
||||||
echo "Image needs to be built"
|
echo "Frontend image needs to be built"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build and push V2 image
|
- name: Check if backend image exists
|
||||||
if: steps.check-image.outputs.exists == 'false'
|
id: check-backend
|
||||||
|
run: |
|
||||||
|
if docker manifest inspect ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-backend-${{ steps.commit-hashes.outputs.backend_short }} >/dev/null 2>&1; then
|
||||||
|
echo "exists=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "Backend image already exists, skipping build"
|
||||||
|
else
|
||||||
|
echo "exists=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "Backend image needs to be built"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Build and push V2 frontend image
|
||||||
|
if: steps.check-frontend.outputs.exists == 'false'
|
||||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/embedded/Dockerfile
|
file: ./docker/frontend/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-${{ steps.commit-hash.outputs.app_short }}
|
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }}
|
||||||
|
build-args: VERSION_TAG=v2-alpha
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
- name: Build and push V2 backend image
|
||||||
|
if: steps.check-backend.outputs.exists == 'false'
|
||||||
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./docker/backend/Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-backend-${{ steps.commit-hashes.outputs.backend_short }}
|
||||||
build-args: VERSION_TAG=v2-alpha
|
build-args: VERSION_TAG=v2-alpha
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
|
||||||
- name: Set up SSH
|
- name: Set up SSH
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh/
|
mkdir -p ~/.ssh/
|
||||||
echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key
|
echo "${{ secrets.VPS_SSH_KEY }}" > ../private.key
|
||||||
sudo chmod 600 ../private.key
|
sudo chmod 600 ../private.key
|
||||||
|
|
||||||
- name: Deploy V2 to VPS
|
- name: Deploy V2 to VPS
|
||||||
@@ -246,28 +290,27 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
# Use same port strategy as regular PRs - just the PR number
|
# Use same port strategy as regular PRs - just the PR number
|
||||||
V2_PORT=${{ needs.check-pr.outputs.pr_number }}
|
V2_PORT=${{ needs.check-pr.outputs.pr_number }}
|
||||||
|
BACKEND_PORT=$((V2_PORT + 10000)) # Backend on higher port to avoid conflicts
|
||||||
# Create docker-compose for V2 with unified embedded image
|
|
||||||
|
# Create docker-compose for V2 with separate frontend and backend
|
||||||
cat > docker-compose.yml << EOF
|
cat > docker-compose.yml << EOF
|
||||||
version: '3.3'
|
version: '3.3'
|
||||||
services:
|
services:
|
||||||
stirling-pdf-v2:
|
stirling-pdf-v2-backend:
|
||||||
container_name: stirling-pdf-v2-pr-${{ needs.check-pr.outputs.pr_number }}
|
container_name: stirling-pdf-v2-backend-pr-${{ needs.check-pr.outputs.pr_number }}
|
||||||
image: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-${{ steps.commit-hash.outputs.app_short }}
|
image: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-backend-${{ steps.commit-hashes.outputs.backend_short }}
|
||||||
ports:
|
ports:
|
||||||
- "${V2_PORT}:8080"
|
- "${BACKEND_PORT}:8080" # Backend API port
|
||||||
volumes:
|
volumes:
|
||||||
- /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}/data:/usr/share/tessdata:rw
|
- /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}/data:/usr/share/tessdata:rw
|
||||||
- /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}/config:/configs:rw
|
- /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}/config:/configs:rw
|
||||||
- /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}/logs:/logs:rw
|
- /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}/logs:/logs:rw
|
||||||
environment:
|
environment:
|
||||||
DISABLE_ADDITIONAL_FEATURES: "false"
|
DISABLE_ADDITIONAL_FEATURES: "true"
|
||||||
SECURITY_ENABLELOGIN: "true"
|
SECURITY_ENABLELOGIN: "false"
|
||||||
SECURITY_INITIALLOGIN_USERNAME: "${{ secrets.TEST_LOGIN_USERNAME }}"
|
|
||||||
SECURITY_INITIALLOGIN_PASSWORD: "${{ secrets.TEST_LOGIN_PASSWORD }}"
|
|
||||||
SYSTEM_DEFAULTLOCALE: en-GB
|
SYSTEM_DEFAULTLOCALE: en-GB
|
||||||
UI_APPNAME: "Stirling-PDF V2 PR#${{ needs.check-pr.outputs.pr_number }}"
|
UI_APPNAME: "Stirling-PDF V2 PR#${{ needs.check-pr.outputs.pr_number }}"
|
||||||
UI_HOMEDESCRIPTION: "V2 PR#${{ needs.check-pr.outputs.pr_number }} - Embedded Architecture"
|
UI_HOMEDESCRIPTION: "V2 PR#${{ needs.check-pr.outputs.pr_number }} - Frontend/Backend Split Architecture"
|
||||||
UI_APPNAMENAVBAR: "V2 PR#${{ needs.check-pr.outputs.pr_number }}"
|
UI_APPNAMENAVBAR: "V2 PR#${{ needs.check-pr.outputs.pr_number }}"
|
||||||
SYSTEM_MAXFILESIZE: "100"
|
SYSTEM_MAXFILESIZE: "100"
|
||||||
METRICS_ENABLED: "true"
|
METRICS_ENABLED: "true"
|
||||||
@@ -275,12 +318,23 @@ jobs:
|
|||||||
SWAGGER_SERVER_URL: "https://${V2_PORT}.ssl.stirlingpdf.cloud"
|
SWAGGER_SERVER_URL: "https://${V2_PORT}.ssl.stirlingpdf.cloud"
|
||||||
baseUrl: "https://${V2_PORT}.ssl.stirlingpdf.cloud"
|
baseUrl: "https://${V2_PORT}.ssl.stirlingpdf.cloud"
|
||||||
restart: on-failure:5
|
restart: on-failure:5
|
||||||
|
|
||||||
|
stirling-pdf-v2-frontend:
|
||||||
|
container_name: stirling-pdf-v2-frontend-pr-${{ needs.check-pr.outputs.pr_number }}
|
||||||
|
image: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }}
|
||||||
|
ports:
|
||||||
|
- "${V2_PORT}:80" # Frontend port (same as regular PRs)
|
||||||
|
environment:
|
||||||
|
VITE_API_BASE_URL: "http://${{ secrets.VPS_HOST }}:${BACKEND_PORT}"
|
||||||
|
depends_on:
|
||||||
|
- stirling-pdf-v2-backend
|
||||||
|
restart: on-failure:5
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Deploy to VPS
|
# Deploy to VPS
|
||||||
scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }}:/tmp/docker-compose-v2.yml
|
scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }}:/tmp/docker-compose-v2.yml
|
||||||
|
|
||||||
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << ENDSSH
|
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }} << ENDSSH
|
||||||
# Create V2 PR-specific directories
|
# Create V2 PR-specific directories
|
||||||
mkdir -p /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}/{data,config,logs}
|
mkdir -p /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}/{data,config,logs}
|
||||||
|
|
||||||
@@ -290,15 +344,15 @@ jobs:
|
|||||||
# Stop any existing container and clean up
|
# Stop any existing container and clean up
|
||||||
cd /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}
|
cd /stirling/V2-PR-${{ needs.check-pr.outputs.pr_number }}
|
||||||
docker-compose down --remove-orphans 2>/dev/null || true
|
docker-compose down --remove-orphans 2>/dev/null || true
|
||||||
|
|
||||||
# Start the new container
|
# Start the new container
|
||||||
docker-compose pull
|
docker-compose pull
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
|
||||||
# Clean up unused Docker resources to save space
|
# Clean up unused Docker resources to save space
|
||||||
docker system prune -af --volumes || true
|
docker system prune -af --volumes || true
|
||||||
|
|
||||||
# Clean up old images (older than 2 weeks)
|
# Clean up old backend/frontend images (older than 2 weeks)
|
||||||
docker image prune -af --filter "until=336h" --filter "label!=keep=true" || true
|
docker image prune -af --filter "until=336h" --filter "label!=keep=true" || true
|
||||||
ENDSSH
|
ENDSSH
|
||||||
|
|
||||||
@@ -307,14 +361,14 @@ jobs:
|
|||||||
|
|
||||||
- name: Post V2 deployment URL to PR
|
- name: Post V2 deployment URL to PR
|
||||||
if: success()
|
if: success()
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
const { owner, repo } = context.repo;
|
const { owner, repo } = context.repo;
|
||||||
const prNumber = ${{ needs.check-pr.outputs.pr_number }};
|
const prNumber = ${{ needs.check-pr.outputs.pr_number }};
|
||||||
const v2Port = ${{ steps.deploy.outputs.v2_port }};
|
const v2Port = ${{ steps.deploy.outputs.v2_port }};
|
||||||
|
|
||||||
// Delete the "deploying..." comment since we're posting the final result
|
// Delete the "deploying..." comment since we're posting the final result
|
||||||
const deploymentStartedId = ${{ steps.deployment-started.outputs.result }};
|
const deploymentStartedId = ${{ steps.deployment-started.outputs.result }};
|
||||||
if (deploymentStartedId) {
|
if (deploymentStartedId) {
|
||||||
@@ -329,16 +383,16 @@ jobs:
|
|||||||
console.log(`Could not delete deployment started comment: ${error.message}`);
|
console.log(`Could not delete deployment started comment: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const deploymentUrl = `http://${{ secrets.NEW_VPS_HOST }}:${v2Port}`;
|
const deploymentUrl = `http://${{ secrets.VPS_HOST }}:${v2Port}`;
|
||||||
const httpsUrl = `https://${v2Port}.ssl.stirlingpdf.cloud`;
|
const httpsUrl = `https://${v2Port}.ssl.stirlingpdf.cloud`;
|
||||||
|
|
||||||
const commentBody = `## 🚀 V2 Auto-Deployment Complete!\n\n` +
|
const commentBody = `## 🚀 V2 Auto-Deployment Complete!\n\n` +
|
||||||
`Your V2 PR with embedded architecture has been deployed!\n\n` +
|
`Your V2 PR with the new frontend/backend split architecture has been deployed!\n\n` +
|
||||||
`🔗 **Direct Test URL (non-SSL)** [${deploymentUrl}](${deploymentUrl})\n\n` +
|
`🔗 **Direct Test URL (non-SSL)** [${deploymentUrl}](${deploymentUrl})\n\n` +
|
||||||
`🔐 **Secure HTTPS URL**: [${httpsUrl}](${httpsUrl})\n\n` +
|
`🔐 **Secure HTTPS URL**: [${httpsUrl}](${httpsUrl})\n\n` +
|
||||||
`_This deployment will be automatically cleaned up when the PR is closed._\n\n` +
|
`_This deployment will be automatically cleaned up when the PR is closed._\n\n` +
|
||||||
`🔄 **Auto-deployed** for approved V2 contributors.`;
|
`🔄 **Auto-deployed** because PR title or branch name contains V2/version2/React keywords.`;
|
||||||
|
|
||||||
await github.rest.issues.createComment({
|
await github.rest.issues.createComment({
|
||||||
owner,
|
owner,
|
||||||
@@ -357,12 +411,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
- name: Setup GitHub App Bot
|
- name: Setup GitHub App Bot
|
||||||
if: github.actor != 'dependabot[bot]'
|
if: github.actor != 'dependabot[bot]'
|
||||||
@@ -374,25 +428,25 @@ jobs:
|
|||||||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Clean up V2 deployment comments
|
- name: Clean up V2 deployment comments
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
const { owner, repo } = context.repo;
|
const { owner, repo } = context.repo;
|
||||||
const prNumber = ${{ github.event.pull_request.number }};
|
const prNumber = ${{ github.event.pull_request.number }};
|
||||||
|
|
||||||
// Find and delete V2 deployment comments
|
// Find and delete V2 deployment comments
|
||||||
const { data: comments } = await github.rest.issues.listComments({
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
issue_number: prNumber
|
issue_number: prNumber
|
||||||
});
|
});
|
||||||
|
|
||||||
const v2Comments = comments.filter(c =>
|
const v2Comments = comments.filter(c =>
|
||||||
c.body?.includes("## 🚀 V2 Auto-Deployment Complete!") &&
|
c.body?.includes("## 🚀 V2 Auto-Deployment Complete!") &&
|
||||||
c.user?.type === "Bot"
|
c.user?.type === "Bot"
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const comment of v2Comments) {
|
for (const comment of v2Comments) {
|
||||||
await github.rest.issues.deleteComment({
|
await github.rest.issues.deleteComment({
|
||||||
owner,
|
owner,
|
||||||
@@ -405,12 +459,12 @@ jobs:
|
|||||||
- name: Set up SSH
|
- name: Set up SSH
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh/
|
mkdir -p ~/.ssh/
|
||||||
echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key
|
echo "${{ secrets.VPS_SSH_KEY }}" > ../private.key
|
||||||
sudo chmod 600 ../private.key
|
sudo chmod 600 ../private.key
|
||||||
|
|
||||||
- name: Cleanup V2 deployment
|
- name: Cleanup V2 deployment
|
||||||
run: |
|
run: |
|
||||||
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << 'ENDSSH'
|
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }} << 'ENDSSH'
|
||||||
if [ -d "/stirling/V2-PR-${{ github.event.pull_request.number }}" ]; then
|
if [ -d "/stirling/V2-PR-${{ github.event.pull_request.number }}" ]; then
|
||||||
echo "Found V2 PR directory, proceeding with cleanup..."
|
echo "Found V2 PR directory, proceeding with cleanup..."
|
||||||
|
|
||||||
@@ -424,8 +478,9 @@ jobs:
|
|||||||
# Remove V2 PR-specific directories
|
# Remove V2 PR-specific directories
|
||||||
rm -rf /stirling/V2-PR-${{ github.event.pull_request.number }}
|
rm -rf /stirling/V2-PR-${{ github.event.pull_request.number }}
|
||||||
|
|
||||||
# Clean up V2 container by name (in case compose cleanup missed it)
|
# Clean up V2 containers by name (in case compose cleanup missed them)
|
||||||
docker rm -f stirling-pdf-v2-pr-${{ github.event.pull_request.number }} || true
|
docker rm -f stirling-pdf-v2-frontend-pr-${{ github.event.pull_request.number }} || true
|
||||||
|
docker rm -f stirling-pdf-v2-backend-pr-${{ github.event.pull_request.number }} || true
|
||||||
|
|
||||||
echo "V2 cleanup completed"
|
echo "V2 cleanup completed"
|
||||||
else
|
else
|
||||||
@@ -443,4 +498,4 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
rm -f ../private.key
|
rm -f ../private.key
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -14,7 +14,6 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
issues: write
|
issues: write
|
||||||
if: |
|
if: |
|
||||||
vars.CI_PROFILE != 'lite' &&
|
|
||||||
github.event.issue.pull_request &&
|
github.event.issue.pull_request &&
|
||||||
(
|
(
|
||||||
contains(github.event.comment.body, 'prdeploy') ||
|
contains(github.event.comment.body, 'prdeploy') ||
|
||||||
@@ -25,7 +24,8 @@ jobs:
|
|||||||
github.event.comment.user.login == 'frooodle' ||
|
github.event.comment.user.login == 'frooodle' ||
|
||||||
github.event.comment.user.login == 'sf298' ||
|
github.event.comment.user.login == 'sf298' ||
|
||||||
github.event.comment.user.login == 'Ludy87' ||
|
github.event.comment.user.login == 'Ludy87' ||
|
||||||
github.event.comment.user.login == 'balazs-szucs' ||
|
github.event.comment.user.login == 'LaserKaspar' ||
|
||||||
|
github.event.comment.user.login == 'sbplat' ||
|
||||||
github.event.comment.user.login == 'reecebrowne' ||
|
github.event.comment.user.login == 'reecebrowne' ||
|
||||||
github.event.comment.user.login == 'DarioGii' ||
|
github.event.comment.user.login == 'DarioGii' ||
|
||||||
github.event.comment.user.login == 'EthanHealy01' ||
|
github.event.comment.user.login == 'EthanHealy01' ||
|
||||||
@@ -34,18 +34,20 @@ jobs:
|
|||||||
)
|
)
|
||||||
outputs:
|
outputs:
|
||||||
pr_number: ${{ steps.get-pr.outputs.pr_number }}
|
pr_number: ${{ steps.get-pr.outputs.pr_number }}
|
||||||
|
pr_repository: ${{ steps.get-pr-info.outputs.repository }}
|
||||||
|
pr_ref: ${{ steps.get-pr-info.outputs.ref }}
|
||||||
comment_id: ${{ github.event.comment.id }}
|
comment_id: ${{ github.event.comment.id }}
|
||||||
disable_security: ${{ steps.check-security-flag.outputs.disable_security }}
|
disable_security: ${{ steps.check-security-flag.outputs.disable_security }}
|
||||||
enable_pro: ${{ steps.check-pro-flag.outputs.enable_pro }}
|
enable_pro: ${{ steps.check-pro-flag.outputs.enable_pro }}
|
||||||
enable_enterprise: ${{ steps.check-pro-flag.outputs.enable_enterprise }}
|
enable_enterprise: ${{ steps.check-pro-flag.outputs.enable_enterprise }}
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout PR
|
- name: Checkout PR
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Setup GitHub App Bot
|
- name: Setup GitHub App Bot
|
||||||
if: github.actor != 'dependabot[bot]'
|
if: github.actor != 'dependabot[bot]'
|
||||||
@@ -58,13 +60,36 @@ jobs:
|
|||||||
|
|
||||||
- name: Get PR data
|
- name: Get PR data
|
||||||
id: get-pr
|
id: get-pr
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const prNumber = context.payload.issue.number;
|
const prNumber = context.payload.issue.number;
|
||||||
console.log(`PR Number: ${prNumber}`);
|
console.log(`PR Number: ${prNumber}`);
|
||||||
core.setOutput('pr_number', prNumber);
|
core.setOutput('pr_number', prNumber);
|
||||||
|
|
||||||
|
- name: Get PR repository and ref
|
||||||
|
id: get-pr-info
|
||||||
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { owner, repo } = context.repo;
|
||||||
|
const prNumber = context.payload.issue.number;
|
||||||
|
|
||||||
|
const { data: pr } = await github.rest.pulls.get({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
pull_number: prNumber,
|
||||||
|
});
|
||||||
|
|
||||||
|
// For forks, use the full repository name, for internal PRs use the current repo
|
||||||
|
const repository = pr.head.repo.fork ? pr.head.repo.full_name : `${owner}/${repo}`;
|
||||||
|
|
||||||
|
console.log(`PR Repository: ${repository}`);
|
||||||
|
console.log(`PR Branch: ${pr.head.ref}`);
|
||||||
|
|
||||||
|
core.setOutput('repository', repository);
|
||||||
|
core.setOutput('ref', pr.head.ref);
|
||||||
|
|
||||||
- name: Check for security/login flag
|
- name: Check for security/login flag
|
||||||
id: check-security-flag
|
id: check-security-flag
|
||||||
env:
|
env:
|
||||||
@@ -99,7 +124,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Add 'in_progress' reaction to comment
|
- name: Add 'in_progress' reaction to comment
|
||||||
id: add-eyes-reaction
|
id: add-eyes-reaction
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
@@ -128,12 +153,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout PR
|
- name: Checkout PR
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Setup GitHub App Bot
|
- name: Setup GitHub App Bot
|
||||||
if: github.actor != 'dependabot[bot]'
|
if: github.actor != 'dependabot[bot]'
|
||||||
@@ -145,22 +170,18 @@ jobs:
|
|||||||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Checkout PR
|
- name: Checkout PR
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
with:
|
with:
|
||||||
ref: refs/pull/${{ needs.check-comment.outputs.pr_number }}/merge
|
repository: ${{ needs.check-comment.outputs.pr_repository }}
|
||||||
|
ref: ${{ needs.check-comment.outputs.pr_ref }}
|
||||||
token: ${{ steps.setup-bot.outputs.token }}
|
token: ${{ steps.setup-bot.outputs.token }}
|
||||||
|
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
java-version: "17"
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
|
||||||
gradle-version: 8.14
|
|
||||||
|
|
||||||
- name: Run Gradle Command
|
- name: Run Gradle Command
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ needs.check-comment.outputs.disable_security }}" == "true" ]; then
|
if [ "${{ needs.check-comment.outputs.disable_security }}" == "true" ]; then
|
||||||
@@ -168,18 +189,15 @@ jobs:
|
|||||||
else
|
else
|
||||||
export DISABLE_ADDITIONAL_FEATURES=false
|
export DISABLE_ADDITIONAL_FEATURES=false
|
||||||
fi
|
fi
|
||||||
./gradlew build
|
./gradlew clean build
|
||||||
env:
|
env:
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
STIRLING_PDF_DESKTOP_UI: false
|
STIRLING_PDF_DESKTOP_UI: false
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_HUB_API }}
|
password: ${{ secrets.DOCKER_HUB_API }}
|
||||||
@@ -188,7 +206,7 @@ jobs:
|
|||||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/embedded/Dockerfile
|
file: ./Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:pr-${{ needs.check-comment.outputs.pr_number }}
|
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:pr-${{ needs.check-comment.outputs.pr_number }}
|
||||||
build-args: VERSION_TAG=alpha
|
build-args: VERSION_TAG=alpha
|
||||||
@@ -197,7 +215,7 @@ jobs:
|
|||||||
- name: Set up SSH
|
- name: Set up SSH
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh/
|
mkdir -p ~/.ssh/
|
||||||
echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key
|
echo "${{ secrets.VPS_SSH_KEY }}" > ../private.key
|
||||||
sudo chmod 600 ../private.key
|
sudo chmod 600 ../private.key
|
||||||
|
|
||||||
- name: Deploy to VPS
|
- name: Deploy to VPS
|
||||||
@@ -259,9 +277,9 @@ jobs:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Then copy the file and execute commands
|
# Then copy the file and execute commands
|
||||||
scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }}:/tmp/docker-compose.yml
|
scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }}:/tmp/docker-compose.yml
|
||||||
|
|
||||||
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << ENDSSH
|
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }} << ENDSSH
|
||||||
# Create PR-specific directories
|
# Create PR-specific directories
|
||||||
mkdir -p /stirling/PR-${{ needs.check-comment.outputs.pr_number }}/{data,config,logs}
|
mkdir -p /stirling/PR-${{ needs.check-comment.outputs.pr_number }}/{data,config,logs}
|
||||||
|
|
||||||
@@ -279,7 +297,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Add success reaction to comment
|
- name: Add success reaction to comment
|
||||||
if: success()
|
if: success()
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
@@ -314,7 +332,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Add failure reaction to comment
|
- name: Add failure reaction to comment
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
@@ -334,7 +352,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Post deployment URL to PR
|
- name: Post deployment URL to PR
|
||||||
if: success()
|
if: success()
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
@@ -343,7 +361,7 @@ jobs:
|
|||||||
const prNumber = ${{ needs.check-comment.outputs.pr_number }};
|
const prNumber = ${{ needs.check-comment.outputs.pr_number }};
|
||||||
const securityStatus = process.env.security_status || "Security Disabled";
|
const securityStatus = process.env.security_status || "Security Disabled";
|
||||||
|
|
||||||
const deploymentUrl = `http://${{ secrets.NEW_VPS_HOST }}:${prNumber}`;
|
const deploymentUrl = `http://${{ secrets.VPS_HOST }}:${prNumber}`;
|
||||||
const commentBody = `## 🚀 PR Test Deployment\n\n` +
|
const commentBody = `## 🚀 PR Test Deployment\n\n` +
|
||||||
`Your PR has been deployed for testing!\n\n` +
|
`Your PR has been deployed for testing!\n\n` +
|
||||||
`🔗 **Test URL:** [${deploymentUrl}](${deploymentUrl})\n` +
|
`🔗 **Test URL:** [${deploymentUrl}](${deploymentUrl})\n` +
|
||||||
@@ -364,149 +382,3 @@ jobs:
|
|||||||
rm -f ../private.key docker-compose.yml
|
rm -f ../private.key docker-compose.yml
|
||||||
echo "Cleanup complete."
|
echo "Cleanup complete."
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
handle-label-commands:
|
|
||||||
if: ${{ github.event.issue.pull_request != null }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Harden Runner
|
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
|
|
||||||
- name: Check out the repository
|
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
||||||
|
|
||||||
- name: Setup GitHub App Bot
|
|
||||||
id: setup-bot
|
|
||||||
uses: ./.github/actions/setup-bot
|
|
||||||
with:
|
|
||||||
app-id: ${{ secrets.GH_APP_ID }}
|
|
||||||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
|
||||||
|
|
||||||
- name: Apply label commands
|
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
||||||
with:
|
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
script: |
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const { comment, issue } = context.payload;
|
|
||||||
const commentBody = comment?.body ?? '';
|
|
||||||
if (!commentBody.includes('::label::')) {
|
|
||||||
core.info('No label commands detected in comment.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const configPath = path.join(process.env.GITHUB_WORKSPACE, '.github', 'config', 'repo_devs.json');
|
|
||||||
const repoDevsConfig = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
||||||
const label_changer = (repoDevsConfig.label_changer || []).map((login) => login.toLowerCase());
|
|
||||||
|
|
||||||
const commenter = (comment?.user?.login || '').toLowerCase();
|
|
||||||
if (!label_changer.includes(commenter)) {
|
|
||||||
core.info(`User ${commenter} is not authorized to manage labels.`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const labelsConfigPath = path.join(process.env.GITHUB_WORKSPACE, '.github', 'labels.yml');
|
|
||||||
const labelsFile = fs.readFileSync(labelsConfigPath, 'utf8');
|
|
||||||
|
|
||||||
const labelNameMap = new Map();
|
|
||||||
for (const match of labelsFile.matchAll(/-\s+name:\s*(?:"([^"]+)"|'([^']+)'|([^\n]+))/g)) {
|
|
||||||
const labelName = (match[1] ?? match[2] ?? match[3] ?? '').trim();
|
|
||||||
|
|
||||||
if (!labelName) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const normalized = labelName.toLowerCase();
|
|
||||||
if (!labelNameMap.has(normalized)) {
|
|
||||||
labelNameMap.set(normalized, labelName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!labelNameMap.size) {
|
|
||||||
core.warning('No labels could be read from .github/labels.yml; aborting label commands.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let allowedLabelNames = new Set(labelNameMap.values());
|
|
||||||
|
|
||||||
const labelsToAdd = new Set();
|
|
||||||
const labelsToRemove = new Set();
|
|
||||||
const commandRegex = /^(\w+)::(label)::"([^"]+)"/gim;
|
|
||||||
let match;
|
|
||||||
while ((match = commandRegex.exec(commentBody)) !== null) {
|
|
||||||
core.info(`Found label command: ${match[0]} (action: ${match[1]}, label: ${match[2]}, labelName: ${match[3]})`);
|
|
||||||
const action = match[1].toLowerCase();
|
|
||||||
const labelName = match[3].trim();
|
|
||||||
|
|
||||||
if (!labelName) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized = labelName.toLowerCase();
|
|
||||||
const resolvedLabelName = labelNameMap.get(normalized);
|
|
||||||
if (action === 'add') {
|
|
||||||
if (!resolvedLabelName) {
|
|
||||||
core.warning(`Label "${labelName}" is not defined in .github/labels.yml and cannot be added.`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!allowedLabelNames.has(resolvedLabelName)) {
|
|
||||||
core.warning(`Label "${resolvedLabelName}" is not allowed for add commands and will be skipped.`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
labelsToAdd.add(resolvedLabelName);
|
|
||||||
} else if (action === 'rm') {
|
|
||||||
const labelToRemove = resolvedLabelName ?? labelName;
|
|
||||||
if (!resolvedLabelName) {
|
|
||||||
core.warning(`Label "${labelName}" is not defined in .github/labels.yml; attempting to remove as provided.`);
|
|
||||||
}
|
|
||||||
labelsToRemove.add(labelToRemove);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const addLabels = Array.from(labelsToAdd);
|
|
||||||
const removeLabels = Array.from(labelsToRemove);
|
|
||||||
|
|
||||||
if (!addLabels.length && !removeLabels.length) {
|
|
||||||
core.info('No valid label commands found after parsing.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const issueParams = {
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
issue_number: issue.number,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (addLabels.length) {
|
|
||||||
core.info(`Adding labels: ${addLabels.join(', ')}`);
|
|
||||||
await github.rest.issues.addLabels({
|
|
||||||
...issueParams,
|
|
||||||
labels: addLabels,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const labelName of removeLabels) {
|
|
||||||
core.info(`Removing label: ${labelName}`);
|
|
||||||
try {
|
|
||||||
await github.rest.issues.removeLabel({
|
|
||||||
...issueParams,
|
|
||||||
name: labelName,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
if (error.status === 404) {
|
|
||||||
core.warning(`Label "${labelName}" was not present on the pull request.`);
|
|
||||||
} else {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await github.rest.issues.deleteComment({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
comment_id: comment.id,
|
|
||||||
});
|
|
||||||
core.info('Processed label commands and deleted the comment.');
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ permissions:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
env:
|
env:
|
||||||
SERVER_IP: ${{ secrets.NEW_VPS_IP }} # Add this to your GitHub secrets
|
SERVER_IP: ${{ secrets.VPS_IP }} # Add this to your GitHub secrets
|
||||||
CLEANUP_PERFORMED: "false" # Add flag to track if cleanup occurred
|
CLEANUP_PERFORMED: "false" # Add flag to track if cleanup occurred
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -21,12 +21,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout PR
|
- name: Checkout PR
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Setup GitHub App Bot
|
- name: Setup GitHub App Bot
|
||||||
if: github.actor != 'dependabot[bot]'
|
if: github.actor != 'dependabot[bot]'
|
||||||
@@ -39,7 +39,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Remove 'pr-deployed' label if present
|
- name: Remove 'pr-deployed' label if present
|
||||||
id: remove-label-comment
|
id: remove-label-comment
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
@@ -96,18 +96,19 @@ jobs:
|
|||||||
const hasDeploymentComment = deploymentComments.length > 0;
|
const hasDeploymentComment = deploymentComments.length > 0;
|
||||||
core.setOutput('present', (hasLabel || hasDeploymentComment) ? 'true' : 'false');
|
core.setOutput('present', (hasLabel || hasDeploymentComment) ? 'true' : 'false');
|
||||||
|
|
||||||
|
|
||||||
- name: Set up SSH
|
- name: Set up SSH
|
||||||
if: steps.remove-label-comment.outputs.present == 'true'
|
if: steps.remove-label-comment.outputs.present == 'true'
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh/
|
mkdir -p ~/.ssh/
|
||||||
echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key
|
echo "${{ secrets.VPS_SSH_KEY }}" > ../private.key
|
||||||
sudo chmod 600 ../private.key
|
sudo chmod 600 ../private.key
|
||||||
|
|
||||||
- name: Cleanup PR deployment
|
- name: Cleanup PR deployment
|
||||||
if: steps.remove-label-comment.outputs.present == 'true'
|
if: steps.remove-label-comment.outputs.present == 'true'
|
||||||
id: cleanup
|
id: cleanup
|
||||||
run: |
|
run: |
|
||||||
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << 'ENDSSH'
|
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }} << 'ENDSSH'
|
||||||
if [ -d "/stirling/PR-${{ github.event.pull_request.number }}" ]; then
|
if [ -d "/stirling/PR-${{ github.event.pull_request.number }}" ]; then
|
||||||
echo "Found PR directory, proceeding with cleanup..."
|
echo "Found PR directory, proceeding with cleanup..."
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ on:
|
|||||||
types: [opened, edited]
|
types: [opened, edited]
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
permissions: # required for secure-repo hardening
|
permissions: # required for secure-repo hardening
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -19,11 +19,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ jobs:
|
|||||||
- name: AI PR Title Analysis
|
- name: AI PR Title Analysis
|
||||||
if: steps.actor.outputs.is_repo_dev == 'true'
|
if: steps.actor.outputs.is_repo_dev == 'true'
|
||||||
id: ai-title-analysis
|
id: ai-title-analysis
|
||||||
uses: actions/ai-inference@334892bb203895caaed82ec52d23c1ed9385151e # v2.0.4
|
uses: actions/ai-inference@b81b2afb8390ee6839b494a404766bef6493c7d9 # v1.2.8
|
||||||
with:
|
with:
|
||||||
model: openai/gpt-4o
|
model: openai/gpt-4o
|
||||||
system-prompt-file: ".github/config/system-prompt.txt"
|
system-prompt-file: ".github/config/system-prompt.txt"
|
||||||
@@ -158,7 +158,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Post comment on PR if needed
|
- name: Post comment on PR if needed
|
||||||
if: steps.actor.outputs.is_repo_dev == 'true'
|
if: steps.actor.outputs.is_repo_dev == 'true'
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ name: "Auto Pull Request Labeler V2"
|
|||||||
on:
|
on:
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
types: [opened, synchronize]
|
types: [opened, synchronize]
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- V3
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -16,11 +13,11 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Setup GitHub App Bot
|
- name: Setup GitHub App Bot
|
||||||
id: setup-bot
|
id: setup-bot
|
||||||
|
|||||||
+55
-129
@@ -2,7 +2,7 @@ name: Build and Test Workflow
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ["main"]
|
branches: ["main", "V2", "V2-gha"]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
# cancel in-progress jobs if a new job is triggered
|
# cancel in-progress jobs if a new job is triggered
|
||||||
@@ -27,19 +27,14 @@ jobs:
|
|||||||
timeout-minutes: 3
|
timeout-minutes: 3
|
||||||
outputs:
|
outputs:
|
||||||
build: ${{ steps.changes.outputs.build }}
|
build: ${{ steps.changes.outputs.build }}
|
||||||
|
app: ${{ steps.changes.outputs.app }}
|
||||||
project: ${{ steps.changes.outputs.project }}
|
project: ${{ steps.changes.outputs.project }}
|
||||||
openapi: ${{ steps.changes.outputs.openapi }}
|
openapi: ${{ steps.changes.outputs.openapi }}
|
||||||
frontend: ${{ steps.changes.outputs.frontend }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- uses: actions/checkout@v4.3.0
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
||||||
|
|
||||||
- name: Check for file changes
|
- name: Check for file changes
|
||||||
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
|
uses: dorny/paths-filter@v3.0.2
|
||||||
id: changes
|
id: changes
|
||||||
with:
|
with:
|
||||||
filters: .github/config/.files.yaml
|
filters: .github/config/.files.yaml
|
||||||
@@ -56,31 +51,25 @@ jobs:
|
|||||||
spring-security: [true, false]
|
spring-security: [true, false]
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@v4.3.0
|
||||||
|
|
||||||
- name: Set up JDK ${{ matrix.jdk-version }}
|
- name: Set up JDK ${{ matrix.jdk-version }}
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.jdk-version }}
|
java-version: ${{ matrix.jdk-version }}
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
uses: gradle/actions/setup-gradle@v4.4.2
|
||||||
with:
|
with:
|
||||||
gradle-version: 8.14
|
gradle-version: 8.14
|
||||||
|
|
||||||
- name: Build with Gradle and spring security ${{ matrix.spring-security }}
|
- name: Build with Gradle and spring security ${{ matrix.spring-security }}
|
||||||
run: ./gradlew build -PnoSpotless
|
run: ./gradlew clean build -PnoSpotless
|
||||||
env:
|
env:
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
DISABLE_ADDITIONAL_FEATURES: ${{ matrix.spring-security }}
|
DISABLE_ADDITIONAL_FEATURES: ${{ matrix.spring-security }}
|
||||||
|
|
||||||
- name: Check Test Reports Exist
|
- name: Check Test Reports Exist
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
@@ -98,14 +87,12 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Upload Test Reports
|
- name: Upload Test Reports
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
uses: actions/upload-artifact@v4.6.2
|
||||||
with:
|
with:
|
||||||
name: test-reports-jdk-${{ matrix.jdk-version }}-spring-security-${{ matrix.spring-security }}
|
name: test-reports-jdk-${{ matrix.jdk-version }}-spring-security-${{ matrix.spring-security }}
|
||||||
path: |
|
path: |
|
||||||
app/**/build/reports/jacoco/test
|
|
||||||
app/**/build/reports/tests/
|
app/**/build/reports/tests/
|
||||||
app/**/build/test-results/
|
app/**/build/test-results/
|
||||||
app/**/build/reports/problems/
|
app/**/build/reports/problems/
|
||||||
@@ -113,76 +100,53 @@ jobs:
|
|||||||
retention-days: 3
|
retention-days: 3
|
||||||
if-no-files-found: warn
|
if-no-files-found: warn
|
||||||
|
|
||||||
- name: Add coverage to PR with spring security ${{ matrix.spring-security }} and JDK ${{ matrix.jdk-version }}
|
|
||||||
id: jacoco
|
|
||||||
uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 # v1.7.2
|
|
||||||
with:
|
|
||||||
paths: |
|
|
||||||
${{ github.workspace }}/**/build/reports/jacoco/test/jacocoTestReport.xml
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
min-coverage-overall: 10
|
|
||||||
min-coverage-changed-files: 0
|
|
||||||
comment-type: summary
|
|
||||||
|
|
||||||
check-generateOpenApiDocs:
|
check-generateOpenApiDocs:
|
||||||
if: needs.files-changed.outputs.openapi == 'true'
|
if: needs.files-changed.outputs.openapi == 'true'
|
||||||
needs: [files-changed]
|
needs: [files-changed]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@v4.3.0
|
||||||
|
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
java-version: "17"
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
- uses: gradle/actions/setup-gradle@v4.4.2
|
||||||
- name: Setup Gradle
|
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
|
||||||
gradle-version: 8.14
|
|
||||||
|
|
||||||
- name: Generate OpenAPI documentation
|
- name: Generate OpenAPI documentation
|
||||||
run: ./gradlew :stirling-pdf:generateOpenApiDocs
|
run: ./gradlew :stirling-pdf:generateOpenApiDocs
|
||||||
env:
|
env:
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
DISABLE_ADDITIONAL_FEATURES: true
|
DISABLE_ADDITIONAL_FEATURES: true
|
||||||
|
|
||||||
- name: Upload OpenAPI Documentation
|
- name: Upload OpenAPI Documentation
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
uses: actions/upload-artifact@v4.6.2
|
||||||
with:
|
with:
|
||||||
name: openapi-docs
|
name: openapi-docs
|
||||||
path: ./SwaggerDoc.json
|
path: ./SwaggerDoc.json
|
||||||
|
|
||||||
frontend-validation:
|
frontend-validation:
|
||||||
if: needs.files-changed.outputs.frontend == 'true'
|
|
||||||
needs: files-changed
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@v2.12.2
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@v4.2.2
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
uses: actions/setup-node@v4.1.0
|
||||||
with:
|
with:
|
||||||
node-version: "22"
|
node-version: '20'
|
||||||
cache: "npm"
|
cache: 'npm'
|
||||||
cache-dependency-path: frontend/package-lock.json
|
cache-dependency-path: frontend/package-lock.json
|
||||||
- name: Install frontend dependencies
|
- name: Install frontend dependencies
|
||||||
run: cd frontend && npm ci
|
run: cd frontend && npm ci
|
||||||
- name: Type-check frontend
|
|
||||||
run: cd frontend && npm run prebuild && npm run typecheck:all
|
|
||||||
- name: Lint frontend
|
- name: Lint frontend
|
||||||
run: cd frontend && npm run lint
|
run: cd frontend && npm run lint
|
||||||
- name: Build frontend
|
- name: Build frontend
|
||||||
@@ -190,7 +154,7 @@ jobs:
|
|||||||
- name: Run frontend tests
|
- name: Run frontend tests
|
||||||
run: cd frontend && npm run test -- --run
|
run: cd frontend && npm run test -- --run
|
||||||
- name: Upload frontend build artifacts
|
- name: Upload frontend build artifacts
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
uses: actions/upload-artifact@v4.6.2
|
||||||
with:
|
with:
|
||||||
name: frontend-build
|
name: frontend-build
|
||||||
path: frontend/dist/
|
path: frontend/dist/
|
||||||
@@ -202,34 +166,21 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@v4.3.0
|
||||||
|
- name: Set up JDK 17
|
||||||
- name: Set up JDK 21
|
uses: actions/setup-java@v4.7.1
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
java-version: "17"
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
|
||||||
gradle-version: 8.14
|
|
||||||
|
|
||||||
- name: check the licenses for compatibility
|
- name: check the licenses for compatibility
|
||||||
run: ./gradlew checkLicense
|
run: ./gradlew clean checkLicense
|
||||||
env:
|
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
|
|
||||||
- name: FAILED - check the licenses for compatibility
|
- name: FAILED - check the licenses for compatibility
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
uses: actions/upload-artifact@v4.6.2
|
||||||
with:
|
with:
|
||||||
name: dependencies-without-allowed-license.json
|
name: dependencies-without-allowed-license.json
|
||||||
path: build/reports/dependency-license/dependencies-without-allowed-license.json
|
path: build/reports/dependency-license/dependencies-without-allowed-license.json
|
||||||
@@ -256,37 +207,32 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Set up JDK 21
|
- name: Set up Java 17
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
java-version: "17"
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
|
||||||
gradle-version: 8.14
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
||||||
|
|
||||||
- name: Install Docker Compose
|
- name: Install Docker Compose
|
||||||
run: |
|
run: |
|
||||||
sudo curl -SL "https://github.com/docker/compose/releases/download/v2.39.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
sudo curl -SL "https://github.com/docker/compose/releases/download/v2.37.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||||
sudo chmod +x /usr/local/bin/docker-compose
|
sudo chmod +x /usr/local/bin/docker-compose
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
|
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
||||||
with:
|
with:
|
||||||
python-version: "3.12"
|
python-version: "3.12"
|
||||||
cache: "pip" # caching pip dependencies
|
cache: 'pip' # caching pip dependencies
|
||||||
cache-dependency-path: ./testing/cucumber/requirements.txt
|
cache-dependency-path: ./testing/cucumber/requirements.txt
|
||||||
|
|
||||||
- name: Pip requirements
|
- name: Pip requirements
|
||||||
@@ -299,10 +245,6 @@ jobs:
|
|||||||
chmod +x ./testing/test.sh
|
chmod +x ./testing/test.sh
|
||||||
chmod +x ./testing/test_disabledEndpoints.sh
|
chmod +x ./testing/test_disabledEndpoints.sh
|
||||||
./testing/test.sh
|
./testing/test.sh
|
||||||
env:
|
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
|
|
||||||
test-build-docker-images:
|
test-build-docker-images:
|
||||||
if: github.event_name == 'pull_request' && needs.files-changed.outputs.project == 'true'
|
if: github.event_name == 'pull_request' && needs.files-changed.outputs.project == 'true'
|
||||||
@@ -311,65 +253,49 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
docker-rev: ["Dockerfile", "Dockerfile.ultra-lite", "Dockerfile.fat"]
|
||||||
- docker-rev: docker/embedded/Dockerfile
|
|
||||||
artifact-suffix: Dockerfile
|
|
||||||
- docker-rev: docker/embedded/Dockerfile.ultra-lite
|
|
||||||
artifact-suffix: Dockerfile.ultra-lite
|
|
||||||
- docker-rev: docker/embedded/Dockerfile.fat
|
|
||||||
artifact-suffix: Dockerfile.fat
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Free disk space on runner
|
- name: Set up JDK 17
|
||||||
run: |
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
echo "Disk space before cleanup:" && df -h
|
|
||||||
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android /usr/local/share/boost
|
|
||||||
docker system prune -af || true
|
|
||||||
echo "Disk space after cleanup:" && df -h
|
|
||||||
|
|
||||||
- name: Set up JDK 21
|
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
java-version: "17"
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Set up Gradle
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
|
||||||
with:
|
with:
|
||||||
gradle-version: 8.14
|
gradle-version: 8.14
|
||||||
|
|
||||||
- name: Build application
|
- name: Build application
|
||||||
run: ./gradlew build
|
run: ./gradlew clean build
|
||||||
env:
|
env:
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
DISABLE_ADDITIONAL_FEATURES: true
|
DISABLE_ADDITIONAL_FEATURES: true
|
||||||
STIRLING_PDF_DESKTOP_UI: false
|
STIRLING_PDF_DESKTOP_UI: false
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
||||||
|
|
||||||
- name: Build ${{ matrix.docker-rev }}
|
- name: Build ${{ matrix.docker-rev }}
|
||||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
context: .
|
context: .
|
||||||
file: ./${{ matrix.docker-rev }}
|
file: ./docker/backend/${{ matrix.docker-rev }}
|
||||||
push: false
|
push: false
|
||||||
cache-from: type=gha,scope=${{ matrix.artifact-suffix }}
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max,scope=${{ matrix.artifact-suffix }}
|
cache-to: type=gha,mode=max
|
||||||
platforms: linux/amd64,linux/arm64/v8
|
platforms: linux/amd64,linux/arm64/v8
|
||||||
provenance: true
|
provenance: true
|
||||||
sbom: true
|
sbom: true
|
||||||
@@ -378,7 +304,7 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: reports-docker-${{ matrix.artifact-suffix }}
|
name: reports-docker-${{ matrix.docker-rev }}
|
||||||
path: |
|
path: |
|
||||||
build/reports/tests/
|
build/reports/tests/
|
||||||
build/test-results/
|
build/test-results/
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
name: Check TOML Translation Files on PR
|
name: Check Properties Files on PR
|
||||||
|
|
||||||
# This workflow validates TOML translation files
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
paths:
|
paths:
|
||||||
- "frontend/public/locales/*/translation.toml"
|
- "app/core/src/main/resources/messages_*.properties"
|
||||||
- ".github/scripts/check_language_toml.py"
|
|
||||||
- ".github/workflows/check_toml.yml"
|
|
||||||
|
|
||||||
# cancel in-progress jobs if a new job is triggered
|
# cancel in-progress jobs if a new job is triggered
|
||||||
|
# This is useful to avoid running multiple builds for the same branch if a new commit is pushed
|
||||||
|
# or a pull request is updated.
|
||||||
|
# It helps to save resources and time by ensuring that only the latest commit is built and tested
|
||||||
|
# This is particularly useful for long-running jobs that may take a while to complete.
|
||||||
|
# The `group` is set to a combination of the workflow name, event name, and branch name.
|
||||||
|
# This ensures that jobs are grouped by the workflow and branch, allowing for cancellation of
|
||||||
|
# in-progress jobs when a new commit is pushed to the same branch or a new pull request is opened.
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref_name || github.ref }}
|
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref_name || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -27,12 +30,12 @@ jobs:
|
|||||||
pull-requests: write # Allow writing to pull requests
|
pull-requests: write # Allow writing to pull requests
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout main branch first
|
- name: Checkout main branch first
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Setup GitHub App Bot
|
- name: Setup GitHub App Bot
|
||||||
id: setup-bot
|
id: setup-bot
|
||||||
@@ -43,7 +46,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Get PR data
|
- name: Get PR data
|
||||||
id: get-pr-data
|
id: get-pr-data
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
@@ -70,24 +73,24 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "Fetching PR changed files..."
|
echo "Fetching PR changed files..."
|
||||||
echo "Getting list of changed files from PR..."
|
echo "Getting list of changed files from PR..."
|
||||||
# Check if PR number exists
|
# Check if PR number exists
|
||||||
if [ -z "${{ steps.get-pr-data.outputs.pr_number }}" ]; then
|
if [ -z "${{ steps.get-pr-data.outputs.pr_number }}" ]; then
|
||||||
echo "Error: PR number is empty"
|
echo "Error: PR number is empty"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Get changed files and filter for TOML translation files
|
# Get changed files and filter for properties files, handle case where no matches are found
|
||||||
gh pr view ${{ steps.get-pr-data.outputs.pr_number }} --json files -q ".files[].path" | grep -E '^frontend/public/locales/[a-zA-Z-]+/translation\.toml$' > changed_files.txt || echo "No matching TOML files found in PR"
|
gh pr view ${{ steps.get-pr-data.outputs.pr_number }} --json files -q ".files[].path" | grep -E '^app/core/src/main/resources/messages_[a-zA-Z_]{2}_[a-zA-Z_]{2,7}\.properties$' > changed_files.txt || echo "No matching properties files found in PR"
|
||||||
# Check if any files were found
|
# Check if any files were found
|
||||||
if [ ! -s changed_files.txt ]; then
|
if [ ! -s changed_files.txt ]; then
|
||||||
echo "No TOML translation files changed in this PR"
|
echo "No properties files changed in this PR"
|
||||||
echo "Workflow will exit early as no relevant files to check"
|
echo "Workflow will exit early as no relevant files to check"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "Found $(wc -l < changed_files.txt) matching TOML files"
|
echo "Found $(wc -l < changed_files.txt) matching properties files"
|
||||||
|
|
||||||
- name: Determine reference file
|
- name: Determine reference file test
|
||||||
id: determine-file
|
id: determine-file
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
@@ -122,11 +125,11 @@ jobs:
|
|||||||
pull_number: prNumber,
|
pull_number: prNumber,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Filter for relevant TOML files based on the PR changes
|
// Filter for relevant files based on the PR changes
|
||||||
const changedFiles = files
|
const changedFiles = files
|
||||||
.filter(file =>
|
.filter(file =>
|
||||||
file.status !== "removed" &&
|
file.status !== "removed" &&
|
||||||
/^frontend\/public\/locales\/[a-zA-Z-]+\/translation\.toml$/.test(file.filename)
|
/^app\/core\/src\/main\/resources\/messages_[a-zA-Z_]{2}_[a-zA-Z_]{2,7}\.properties$/.test(file.filename)
|
||||||
)
|
)
|
||||||
.map(file => file.filename);
|
.map(file => file.filename);
|
||||||
|
|
||||||
@@ -166,16 +169,16 @@ jobs:
|
|||||||
|
|
||||||
// Determine reference file
|
// Determine reference file
|
||||||
let referenceFilePath;
|
let referenceFilePath;
|
||||||
if (changedFiles.includes("frontend/public/locales/en-GB/translation.toml")) {
|
if (changedFiles.includes("app/core/src/main/resources/messages_en_GB.properties")) {
|
||||||
console.log("Using PR branch reference file.");
|
console.log("Using PR branch reference file.");
|
||||||
const { data: fileContent } = await github.rest.repos.getContent({
|
const { data: fileContent } = await github.rest.repos.getContent({
|
||||||
owner: prRepoOwner,
|
owner: prRepoOwner,
|
||||||
repo: prRepoName,
|
repo: prRepoName,
|
||||||
path: "frontend/public/locales/en-GB/translation.toml",
|
path: "app/core/src/main/resources/messages_en_GB.properties",
|
||||||
ref: branch,
|
ref: branch,
|
||||||
});
|
});
|
||||||
|
|
||||||
referenceFilePath = "pr-branch-translation-en-GB.toml";
|
referenceFilePath = "pr-branch-messages_en_GB.properties";
|
||||||
const content = Buffer.from(fileContent.content, "base64").toString("utf-8");
|
const content = Buffer.from(fileContent.content, "base64").toString("utf-8");
|
||||||
fs.writeFileSync(referenceFilePath, content);
|
fs.writeFileSync(referenceFilePath, content);
|
||||||
} else {
|
} else {
|
||||||
@@ -183,11 +186,11 @@ jobs:
|
|||||||
const { data: fileContent } = await github.rest.repos.getContent({
|
const { data: fileContent } = await github.rest.repos.getContent({
|
||||||
owner: repoOwner,
|
owner: repoOwner,
|
||||||
repo: repoName,
|
repo: repoName,
|
||||||
path: "frontend/public/locales/en-GB/translation.toml",
|
path: "app/core/src/main/resources/messages_en_GB.properties",
|
||||||
ref: "main",
|
ref: "main",
|
||||||
});
|
});
|
||||||
|
|
||||||
referenceFilePath = "main-branch-translation-en-GB.toml";
|
referenceFilePath = "main-branch-messages_en_GB.properties";
|
||||||
const content = Buffer.from(fileContent.content, "base64").toString("utf-8");
|
const content = Buffer.from(fileContent.content, "base64").toString("utf-8");
|
||||||
fs.writeFileSync(referenceFilePath, content);
|
fs.writeFileSync(referenceFilePath, content);
|
||||||
}
|
}
|
||||||
@@ -195,19 +198,11 @@ jobs:
|
|||||||
console.log(`Reference file path: ${referenceFilePath}`);
|
console.log(`Reference file path: ${referenceFilePath}`);
|
||||||
core.exportVariable("REFERENCE_FILE", referenceFilePath);
|
core.exportVariable("REFERENCE_FILE", referenceFilePath);
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
|
|
||||||
with:
|
|
||||||
python-version: "3.12"
|
|
||||||
|
|
||||||
- name: Install Python dependencies
|
|
||||||
run: pip install --require-hashes -r ./.github/scripts/requirements_sync_readme.txt
|
|
||||||
|
|
||||||
- name: Run Python script to check files
|
- name: Run Python script to check files
|
||||||
id: run-check
|
id: run-check
|
||||||
run: |
|
run: |
|
||||||
echo "Running Python script to check TOML files..."
|
echo "Running Python script to check files..."
|
||||||
python .github/scripts/check_language_toml.py \
|
python .github/scripts/check_language_properties.py \
|
||||||
--actor ${{ github.event.pull_request.user.login }} \
|
--actor ${{ github.event.pull_request.user.login }} \
|
||||||
--reference-file "${REFERENCE_FILE}" \
|
--reference-file "${REFERENCE_FILE}" \
|
||||||
--branch "pr-branch" \
|
--branch "pr-branch" \
|
||||||
@@ -218,7 +213,7 @@ jobs:
|
|||||||
id: capture-output
|
id: capture-output
|
||||||
run: |
|
run: |
|
||||||
if [ -f result.txt ] && [ -s result.txt ]; then
|
if [ -f result.txt ] && [ -s result.txt ]; then
|
||||||
echo "Capturing output..."
|
echo "Test, capturing output..."
|
||||||
SCRIPT_OUTPUT=$(cat result.txt)
|
SCRIPT_OUTPUT=$(cat result.txt)
|
||||||
echo "SCRIPT_OUTPUT<<EOF" >> $GITHUB_ENV
|
echo "SCRIPT_OUTPUT<<EOF" >> $GITHUB_ENV
|
||||||
echo "$SCRIPT_OUTPUT" >> $GITHUB_ENV
|
echo "$SCRIPT_OUTPUT" >> $GITHUB_ENV
|
||||||
@@ -232,14 +227,14 @@ jobs:
|
|||||||
echo "FAIL_JOB=false" >> $GITHUB_ENV
|
echo "FAIL_JOB=false" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "No output found."
|
echo "No update found."
|
||||||
echo "SCRIPT_OUTPUT=" >> $GITHUB_ENV
|
echo "SCRIPT_OUTPUT=" >> $GITHUB_ENV
|
||||||
echo "FAIL_JOB=false" >> $GITHUB_ENV
|
echo "FAIL_JOB=false" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Post comment on PR
|
- name: Post comment on PR
|
||||||
if: env.SCRIPT_OUTPUT != ''
|
if: env.SCRIPT_OUTPUT != ''
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
with:
|
with:
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
script: |
|
script: |
|
||||||
@@ -254,7 +249,7 @@ jobs:
|
|||||||
issue_number: issueNumber
|
issue_number: issueNumber
|
||||||
});
|
});
|
||||||
|
|
||||||
const comment = comments.data.find(c => c.body.includes("## 🌐 TOML Translation Verification Summary"));
|
const comment = comments.data.find(c => c.body.includes("## 🚀 Translation Verification Summary"));
|
||||||
|
|
||||||
// Only update or create comments by the action user
|
// Only update or create comments by the action user
|
||||||
const expectedActor = "${{ steps.setup-bot.outputs.app-slug }}[bot]";
|
const expectedActor = "${{ steps.setup-bot.outputs.app-slug }}[bot]";
|
||||||
@@ -265,7 +260,7 @@ jobs:
|
|||||||
owner: repoOwner,
|
owner: repoOwner,
|
||||||
repo: repoName,
|
repo: repoName,
|
||||||
comment_id: comment.id,
|
comment_id: comment.id,
|
||||||
body: `## 🌐 TOML Translation Verification Summary\n\n\n${SCRIPT_OUTPUT}\n`
|
body: `## 🚀 Translation Verification Summary\n\n\n${SCRIPT_OUTPUT}\n`
|
||||||
});
|
});
|
||||||
console.log("Updated existing comment.");
|
console.log("Updated existing comment.");
|
||||||
} else if (!comment) {
|
} else if (!comment) {
|
||||||
@@ -274,7 +269,7 @@ jobs:
|
|||||||
owner: repoOwner,
|
owner: repoOwner,
|
||||||
repo: repoName,
|
repo: repoName,
|
||||||
issue_number: issueNumber,
|
issue_number: issueNumber,
|
||||||
body: `## 🌐 TOML Translation Verification Summary\n\n\n${SCRIPT_OUTPUT}\n`
|
body: `## 🚀 Translation Verification Summary\n\n\n${SCRIPT_OUTPUT}\n`
|
||||||
});
|
});
|
||||||
console.log("Created new comment.");
|
console.log("Created new comment.");
|
||||||
} else {
|
} else {
|
||||||
@@ -292,6 +287,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "Cleaning up temporary files..."
|
echo "Cleaning up temporary files..."
|
||||||
rm -rf pr-branch
|
rm -rf pr-branch
|
||||||
rm -f pr-branch-translation-en-GB.toml main-branch-translation-en-GB.toml changed_files.txt result.txt
|
rm -f pr-branch-messages_en_GB.properties main-branch-messages_en_GB.properties changed_files.txt result.txt
|
||||||
echo "Cleanup complete."
|
echo "Cleanup complete."
|
||||||
continue-on-error: true # Ensure cleanup runs even if previous steps fail
|
continue-on-error: true # Ensure cleanup runs even if previous steps fail
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
#disable for now
|
||||||
|
#on:
|
||||||
|
# push:
|
||||||
|
# branches: ["main"]
|
||||||
|
# pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
# branches: ["main"]
|
||||||
|
# schedule:
|
||||||
|
# - cron: "0 0 * * 1"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: ["java"]
|
||||||
|
# CodeQL supports [ $supported-codeql-languages ]
|
||||||
|
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@c95a14d0e5bab51a9f56296a4eb0e416910cd350 # v2.10.3
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||||
|
|
||||||
|
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
||||||
|
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
||||||
|
|
||||||
|
# - run: |
|
||||||
|
# echo "Run, Build Application using script"
|
||||||
|
# ./location_of_script_within_repo/buildscript.sh
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
|
||||||
|
with:
|
||||||
|
category: "/language:${{matrix.language}}"
|
||||||
@@ -17,13 +17,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: "Checkout Repository"
|
- name: "Checkout Repository"
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
- name: "Dependency Review"
|
- name: "Dependency Review"
|
||||||
uses: actions/dependency-review-action@3c4e3dcb1aa7874d2c16be7d79418e9b7efd6261 # v4.8.2
|
uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1
|
||||||
with:
|
|
||||||
config-file: "./.github/config/dependency-review-config.yml"
|
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Get commit hashes for frontend and backend
|
- name: Get commit hashes for frontend and backend
|
||||||
id: commit-hashes
|
id: commit-hashes
|
||||||
@@ -36,26 +36,26 @@ jobs:
|
|||||||
if [ -z "$FRONTEND_HASH" ]; then
|
if [ -z "$FRONTEND_HASH" ]; then
|
||||||
FRONTEND_HASH="no-frontend-changes"
|
FRONTEND_HASH="no-frontend-changes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get last commit that touched backend code, docker/backend, or docker/compose
|
# Get last commit that touched backend code, docker/backend, or docker/compose
|
||||||
BACKEND_HASH=$(git log -1 --format="%H" -- app/ docker/backend/ docker/compose/ 2>/dev/null || echo "")
|
BACKEND_HASH=$(git log -1 --format="%H" -- app/ docker/backend/ docker/compose/ 2>/dev/null || echo "")
|
||||||
if [ -z "$BACKEND_HASH" ]; then
|
if [ -z "$BACKEND_HASH" ]; then
|
||||||
BACKEND_HASH="no-backend-changes"
|
BACKEND_HASH="no-backend-changes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Frontend hash: $FRONTEND_HASH"
|
echo "Frontend hash: $FRONTEND_HASH"
|
||||||
echo "Backend hash: $BACKEND_HASH"
|
echo "Backend hash: $BACKEND_HASH"
|
||||||
|
|
||||||
echo "frontend_hash=$FRONTEND_HASH" >> $GITHUB_OUTPUT
|
echo "frontend_hash=$FRONTEND_HASH" >> $GITHUB_OUTPUT
|
||||||
echo "backend_hash=$BACKEND_HASH" >> $GITHUB_OUTPUT
|
echo "backend_hash=$BACKEND_HASH" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
# Short hashes for tags
|
# Short hashes for tags
|
||||||
if [ "$FRONTEND_HASH" = "no-frontend-changes" ]; then
|
if [ "$FRONTEND_HASH" = "no-frontend-changes" ]; then
|
||||||
echo "frontend_short=no-frontend" >> $GITHUB_OUTPUT
|
echo "frontend_short=no-frontend" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "frontend_short=${FRONTEND_HASH:0:8}" >> $GITHUB_OUTPUT
|
echo "frontend_short=${FRONTEND_HASH:0:8}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$BACKEND_HASH" = "no-backend-changes" ]; then
|
if [ "$BACKEND_HASH" = "no-backend-changes" ]; then
|
||||||
echo "backend_short=no-backend" >> $GITHUB_OUTPUT
|
echo "backend_short=no-backend" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
@@ -84,15 +84,16 @@ jobs:
|
|||||||
echo "Backend image needs to be built"
|
echo "Backend image needs to be built"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_HUB_API }}
|
password: ${{ secrets.DOCKER_HUB_API }}
|
||||||
|
|
||||||
- name: Build and push frontend image
|
- name: Build and push frontend image
|
||||||
if: steps.check-frontend.outputs.exists == 'false'
|
if: steps.check-frontend.outputs.exists == 'false'
|
||||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/frontend/Dockerfile
|
file: ./docker/frontend/Dockerfile
|
||||||
@@ -102,10 +103,10 @@ jobs:
|
|||||||
${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-latest
|
${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-latest
|
||||||
build-args: VERSION_TAG=v2-alpha
|
build-args: VERSION_TAG=v2-alpha
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
|
||||||
- name: Build and push backend image
|
- name: Build and push backend image
|
||||||
if: steps.check-backend.outputs.exists == 'false'
|
if: steps.check-backend.outputs.exists == 'false'
|
||||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/backend/Dockerfile
|
file: ./docker/backend/Dockerfile
|
||||||
@@ -116,16 +117,18 @@ jobs:
|
|||||||
build-args: VERSION_TAG=v2-alpha
|
build-args: VERSION_TAG=v2-alpha
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
|
||||||
- name: Set up SSH
|
- name: Set up SSH
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh/
|
mkdir -p ~/.ssh/
|
||||||
echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key
|
echo "${{ secrets.VPS_SSH_KEY }}" > ../private.key
|
||||||
chmod 600 ../private.key
|
chmod 600 ../private.key
|
||||||
|
|
||||||
|
|
||||||
- name: Deploy to VPS on port 3000
|
- name: Deploy to VPS on port 3000
|
||||||
run: |
|
run: |
|
||||||
export UNIQUE_NAME=docker-compose-v2-$GITHUB_RUN_ID.yml
|
export UNIQUE_NAME=docker-compose-v2-$GITHUB_RUN_ID.yml
|
||||||
|
|
||||||
cat > $UNIQUE_NAME << EOF
|
cat > $UNIQUE_NAME << EOF
|
||||||
version: '3.3'
|
version: '3.3'
|
||||||
services:
|
services:
|
||||||
@@ -151,24 +154,24 @@ jobs:
|
|||||||
SWAGGER_SERVER_URL: "https://demo.stirlingpdf.cloud"
|
SWAGGER_SERVER_URL: "https://demo.stirlingpdf.cloud"
|
||||||
baseUrl: "https://demo.stirlingpdf.cloud"
|
baseUrl: "https://demo.stirlingpdf.cloud"
|
||||||
restart: on-failure:5
|
restart: on-failure:5
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
container_name: stirling-v2-frontend
|
container_name: stirling-v2-frontend
|
||||||
image: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }}
|
image: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }}
|
||||||
ports:
|
ports:
|
||||||
- "3000:80"
|
- "3000:80"
|
||||||
environment:
|
environment:
|
||||||
VITE_API_BASE_URL: "http://${{ secrets.NEW_VPS_HOST }}:13000"
|
VITE_API_BASE_URL: "http://${{ secrets.VPS_HOST }}:13000"
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
restart: on-failure:5
|
restart: on-failure:5
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Copy to remote with unique name
|
# Copy to remote with unique name
|
||||||
scp -i ../private.key -o StrictHostKeyChecking=no $UNIQUE_NAME ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }}:/tmp/$UNIQUE_NAME
|
scp -i ../private.key -o StrictHostKeyChecking=no $UNIQUE_NAME ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }}:/tmp/$UNIQUE_NAME
|
||||||
|
|
||||||
# SSH and rename/move atomically to avoid interference
|
# SSH and rename/move atomically to avoid interference
|
||||||
ssh -i ../private.key -o StrictHostKeyChecking=no ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << ENDSSH
|
ssh -i ../private.key -o StrictHostKeyChecking=no ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }} << ENDSSH
|
||||||
mkdir -p /stirling/V2/{data,config,logs}
|
mkdir -p /stirling/V2/{data,config,logs}
|
||||||
mv /tmp/$UNIQUE_NAME /stirling/V2/docker-compose.yml
|
mv /tmp/$UNIQUE_NAME /stirling/V2/docker-compose.yml
|
||||||
cd /stirling/V2
|
cd /stirling/V2
|
||||||
@@ -183,3 +186,4 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
rm -f ../private.key
|
rm -f ../private.key
|
||||||
|
|
||||||
|
|||||||
@@ -1,518 +0,0 @@
|
|||||||
name: License Report Workflow
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name || github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
files-changed:
|
|
||||||
name: detect what files changed
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 3
|
|
||||||
outputs:
|
|
||||||
licenses-frontend: ${{ steps.changes.outputs.licenses-frontend }}
|
|
||||||
licenses-backend: ${{ steps.changes.outputs.licenses-backend }}
|
|
||||||
steps:
|
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
||||||
|
|
||||||
- name: Check for file changes
|
|
||||||
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
|
|
||||||
id: changes
|
|
||||||
with:
|
|
||||||
filters: .github/config/.files.yaml
|
|
||||||
|
|
||||||
generate-frontend-license-report:
|
|
||||||
if: needs.files-changed.outputs.licenses-frontend == 'true'
|
|
||||||
name: Generate Frontend License Report
|
|
||||||
needs: files-changed
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
repository-projects: write # Required for enabling automerge
|
|
||||||
steps:
|
|
||||||
- name: Harden Runner
|
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
|
|
||||||
- name: Checkout PR head (default)
|
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: Setup GitHub App Bot
|
|
||||||
if: (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false)) && github.actor != 'dependabot[bot]'
|
|
||||||
id: setup-bot
|
|
||||||
uses: ./.github/actions/setup-bot
|
|
||||||
with:
|
|
||||||
app-id: ${{ secrets.GH_APP_ID }}
|
|
||||||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
|
||||||
|
|
||||||
- name: Checkout BASE branch (safe script)
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
||||||
with:
|
|
||||||
ref: ${{ github.event.pull_request.base.sha }}
|
|
||||||
path: base
|
|
||||||
fetch-depth: 1
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
|
||||||
with:
|
|
||||||
node-version: "22"
|
|
||||||
cache: "npm"
|
|
||||||
cache-dependency-path: frontend/package-lock.json
|
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
|
||||||
working-directory: frontend
|
|
||||||
env:
|
|
||||||
NPM_CONFIG_IGNORE_SCRIPTS: "true"
|
|
||||||
run: npm ci --ignore-scripts --audit=false --fund=false
|
|
||||||
|
|
||||||
- name: Generate frontend license report (internal PR)
|
|
||||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
|
|
||||||
working-directory: frontend
|
|
||||||
env:
|
|
||||||
PR_IS_FORK: "false"
|
|
||||||
run: npm run generate-licenses
|
|
||||||
|
|
||||||
- name: Generate frontend license report (fork PRs, pinned)
|
|
||||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
|
|
||||||
env:
|
|
||||||
NPM_CONFIG_IGNORE_SCRIPTS: "true"
|
|
||||||
working-directory: frontend
|
|
||||||
run: |
|
|
||||||
mkdir -p src/assets
|
|
||||||
npx --yes license-report --only=prod --output=json > src/assets/3rdPartyLicenses.json
|
|
||||||
|
|
||||||
- name: Postprocess with project script (BASE version)
|
|
||||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
|
|
||||||
env:
|
|
||||||
PR_IS_FORK: "true"
|
|
||||||
run: |
|
|
||||||
node base/frontend/scripts/generate-licenses.js \
|
|
||||||
--input frontend/src/assets/3rdPartyLicenses.json
|
|
||||||
|
|
||||||
- name: Copy postprocessed artifacts back (fork PRs)
|
|
||||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
|
|
||||||
run: |
|
|
||||||
mkdir -p frontend/src/assets
|
|
||||||
if [ -f "base/frontend/src/assets/3rdPartyLicenses.json" ]; then
|
|
||||||
cp base/frontend/src/assets/3rdPartyLicenses.json frontend/src/assets/3rdPartyLicenses.json
|
|
||||||
fi
|
|
||||||
if [ -f "base/frontend/src/assets/license-warnings.json" ]; then
|
|
||||||
cp base/frontend/src/assets/license-warnings.json frontend/src/assets/license-warnings.json
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Check for license warnings
|
|
||||||
run: |
|
|
||||||
if [ -f "frontend/src/assets/license-warnings.json" ]; then
|
|
||||||
echo "LICENSE_WARNINGS_EXIST=true" >> $GITHUB_ENV
|
|
||||||
else
|
|
||||||
echo "LICENSE_WARNINGS_EXIST=false" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
|
|
||||||
# PR Event: Check licenses and comment on PR
|
|
||||||
- name: Delete previous license check comments
|
|
||||||
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) && github.actor != 'dependabot[bot]'
|
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
||||||
with:
|
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
script: |
|
|
||||||
const { owner, repo } = context.repo;
|
|
||||||
const prNumber = context.issue.number;
|
|
||||||
|
|
||||||
// Get all comments on the PR
|
|
||||||
const { data: comments } = await github.rest.issues.listComments({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issue_number: prNumber,
|
|
||||||
per_page: 100
|
|
||||||
});
|
|
||||||
|
|
||||||
// Filter for license check comments
|
|
||||||
const licenseComments = comments.filter(comment =>
|
|
||||||
comment.body.includes('## ✅ Frontend License Check Passed') ||
|
|
||||||
comment.body.includes('## ❌ Frontend License Check Failed')
|
|
||||||
);
|
|
||||||
|
|
||||||
// Delete old license check comments
|
|
||||||
for (const comment of licenseComments) {
|
|
||||||
console.log(`Deleting old license check comment: ${comment.id}`);
|
|
||||||
await github.rest.issues.deleteComment({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
comment_id: comment.id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Summarize results (fork PRs)
|
|
||||||
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true) || github.actor == 'dependabot[bot]'
|
|
||||||
run: |
|
|
||||||
{
|
|
||||||
echo "## Frontend License Check"
|
|
||||||
echo ""
|
|
||||||
if [ "${LICENSE_WARNINGS_EXIST}" = "true" ]; then
|
|
||||||
echo "❌ **Failed** – incompatible or unknown licenses found."
|
|
||||||
if [ -f "frontend/src/assets/license-warnings.json" ]; then
|
|
||||||
echo ""
|
|
||||||
echo "### Warnings"
|
|
||||||
jq -r '.warnings[] | "- \(.message)"' frontend/src/assets/license-warnings.json || true
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "✅ **Passed** – no license warnings detected."
|
|
||||||
fi
|
|
||||||
echo ""
|
|
||||||
echo "_Note: This is a fork PR. PR comments are disabled; use this summary._"
|
|
||||||
} >> "$GITHUB_STEP_SUMMARY"
|
|
||||||
|
|
||||||
- name: Comment on PR - License Check Results
|
|
||||||
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) && github.actor != 'dependabot[bot]'
|
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
||||||
with:
|
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
script: |
|
|
||||||
const { owner, repo } = context.repo;
|
|
||||||
const prNumber = context.issue.number;
|
|
||||||
const hasWarnings = process.env.LICENSE_WARNINGS_EXIST === 'true';
|
|
||||||
|
|
||||||
let commentBody;
|
|
||||||
|
|
||||||
if (hasWarnings) {
|
|
||||||
// Read warnings file to get specific issues
|
|
||||||
const fs = require('fs');
|
|
||||||
let warningDetails = '';
|
|
||||||
try {
|
|
||||||
const warnings = JSON.parse(fs.readFileSync('frontend/src/assets/license-warnings.json', 'utf8'));
|
|
||||||
warningDetails = warnings.warnings.map(w => `- ${w.message}`).join('\n');
|
|
||||||
} catch (e) {
|
|
||||||
warningDetails = 'Unable to read warning details';
|
|
||||||
}
|
|
||||||
|
|
||||||
commentBody = `## ❌ Frontend License Check Failed
|
|
||||||
|
|
||||||
The frontend license check has detected compatibility warnings that require review:
|
|
||||||
|
|
||||||
${warningDetails}
|
|
||||||
|
|
||||||
**Action Required:** Please review these licenses to ensure they are acceptable for your use case before merging.
|
|
||||||
|
|
||||||
_This check will fail the PR until license issues are resolved._`;
|
|
||||||
} else {
|
|
||||||
commentBody = `## ✅ Frontend License Check Passed
|
|
||||||
|
|
||||||
All frontend licenses have been validated and no compatibility warnings were detected.
|
|
||||||
|
|
||||||
The frontend license report has been updated successfully.`;
|
|
||||||
}
|
|
||||||
|
|
||||||
await github.rest.issues.createComment({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issue_number: prNumber,
|
|
||||||
body: commentBody
|
|
||||||
});
|
|
||||||
|
|
||||||
- name: Fail workflow if license warnings exist (PR only)
|
|
||||||
if: github.event_name == 'pull_request' && env.LICENSE_WARNINGS_EXIST == 'true'
|
|
||||||
run: |
|
|
||||||
echo "❌ License warnings detected. Failing the workflow."
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
# Push Event: Commit license files and create PR
|
|
||||||
- name: Commit changes (Push only)
|
|
||||||
if: github.event_name == 'push'
|
|
||||||
run: |
|
|
||||||
git add frontend/src/assets/3rdPartyLicenses.json
|
|
||||||
# Note: Do NOT commit license-warnings.json - it's only for PR review
|
|
||||||
git diff --staged --quiet || echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Prepare PR body (Push only)
|
|
||||||
if: github.event_name == 'push'
|
|
||||||
run: |
|
|
||||||
PR_BODY="Auto-generated by ${{ steps.setup-bot.outputs.app-slug }}[bot]
|
|
||||||
|
|
||||||
This PR updates the frontend license report based on changes to package.json dependencies."
|
|
||||||
|
|
||||||
if [ "${{ env.LICENSE_WARNINGS_EXIST }}" = "true" ]; then
|
|
||||||
PR_BODY="$PR_BODY
|
|
||||||
|
|
||||||
## ⚠️ License Compatibility Warnings
|
|
||||||
|
|
||||||
The following licenses may require review for corporate compatibility:
|
|
||||||
|
|
||||||
$(cat frontend/src/assets/license-warnings.json | jq -r '.warnings[].message')
|
|
||||||
|
|
||||||
Please review these licenses to ensure they are acceptable for your use case."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "PR_BODY<<EOF" >> $GITHUB_ENV
|
|
||||||
echo "$PR_BODY" >> $GITHUB_ENV
|
|
||||||
echo "EOF" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Create Pull Request (Push only)
|
|
||||||
id: cpr
|
|
||||||
if: github.event_name == 'push' && env.CHANGES_DETECTED == 'true'
|
|
||||||
uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v8.0.0
|
|
||||||
with:
|
|
||||||
token: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
commit-message: "Update Frontend 3rd Party Licenses"
|
|
||||||
committer: ${{ steps.setup-bot.outputs.committer }}
|
|
||||||
author: ${{ steps.setup-bot.outputs.committer }}
|
|
||||||
signoff: true
|
|
||||||
branch: update-frontend-3rd-party-licenses
|
|
||||||
base: main
|
|
||||||
title: "Update Frontend 3rd Party Licenses"
|
|
||||||
body: ${{ env.PR_BODY }}
|
|
||||||
labels: Licenses,github-actions,frontend
|
|
||||||
draft: false
|
|
||||||
delete-branch: true
|
|
||||||
sign-commits: true
|
|
||||||
|
|
||||||
- name: Enable Pull Request Automerge (Push only)
|
|
||||||
if: github.event_name == 'push' && steps.cpr.outputs.pull-request-operation == 'created' && env.LICENSE_WARNINGS_EXIST == 'false'
|
|
||||||
run: gh pr merge --squash --auto "${{ steps.cpr.outputs.pull-request-number }}"
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
|
|
||||||
- name: Add review required label (Push only)
|
|
||||||
if: github.event_name == 'push' && steps.cpr.outputs.pull-request-operation == 'created' && env.LICENSE_WARNINGS_EXIST == 'true'
|
|
||||||
run: gh pr edit "${{ steps.cpr.outputs.pull-request-number }}" --add-label "license-review-required"
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
|
|
||||||
generate-backend-license-report:
|
|
||||||
if: needs.files-changed.outputs.licenses-backend == 'true'
|
|
||||||
needs: files-changed
|
|
||||||
name: Generate Backend License Report
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
repository-projects: write # Required for enabling automerge
|
|
||||||
steps:
|
|
||||||
- name: Harden Runner
|
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: Setup GitHub App Bot
|
|
||||||
if: (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false)) && github.actor != 'dependabot[bot]'
|
|
||||||
id: setup-bot
|
|
||||||
uses: ./.github/actions/setup-bot
|
|
||||||
with:
|
|
||||||
app-id: ${{ secrets.GH_APP_ID }}
|
|
||||||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
|
||||||
|
|
||||||
- name: Set up JDK 21
|
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
|
||||||
with:
|
|
||||||
java-version: "21"
|
|
||||||
distribution: "temurin"
|
|
||||||
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
|
||||||
gradle-version: 8.14
|
|
||||||
|
|
||||||
- name: Check licenses and generate report
|
|
||||||
id: license-check
|
|
||||||
run: |
|
|
||||||
./gradlew checkLicense generateLicenseReport || echo "LICENSE_CHECK_FAILED=true" >> $GITHUB_ENV
|
|
||||||
env:
|
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
DISABLE_ADDITIONAL_FEATURES: false
|
|
||||||
STIRLING_PDF_DESKTOP_UI: true
|
|
||||||
|
|
||||||
- name: Check for license compatibility issues
|
|
||||||
run: |
|
|
||||||
if [ -f build/reports/dependency-license/dependencies-without-allowed-license.json ] && \
|
|
||||||
jq '.dependenciesWithoutAllowedLicenses | length > 0' build/reports/dependency-license/dependencies-without-allowed-license.json | grep -q true; then
|
|
||||||
echo "LICENSE_WARNINGS_EXIST=true" >> $GITHUB_ENV
|
|
||||||
else
|
|
||||||
echo "LICENSE_WARNINGS_EXIST=false" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
if: always()
|
|
||||||
|
|
||||||
- name: Upload artifact on license issues
|
|
||||||
if: env.LICENSE_WARNINGS_EXIST == 'true'
|
|
||||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
|
||||||
with:
|
|
||||||
name: backend-dependencies-without-allowed-license.json
|
|
||||||
path: build/reports/dependency-license/dependencies-without-allowed-license.json
|
|
||||||
|
|
||||||
- name: Move license file
|
|
||||||
if: env.LICENSE_CHECK_FAILED != 'true' && env.LICENSE_WARNINGS_EXIST == 'false'
|
|
||||||
run: |
|
|
||||||
mkdir -p app/core/src/main/resources/static
|
|
||||||
cp build/reports/dependency-license/index.json app/core/src/main/resources/static/3rdPartyLicenses.json
|
|
||||||
|
|
||||||
- name: Delete previous backend license check comments
|
|
||||||
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) && github.actor != 'dependabot[bot]'
|
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
||||||
with:
|
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
script: |
|
|
||||||
const { owner, repo } = context.repo;
|
|
||||||
const prNumber = context.issue.number;
|
|
||||||
|
|
||||||
const { data: comments } = await github.rest.issues.listComments({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issue_number: prNumber,
|
|
||||||
per_page: 100
|
|
||||||
});
|
|
||||||
|
|
||||||
const backendLicenseComments = comments.filter(comment =>
|
|
||||||
comment.body.includes('## ✅ Backend License Check Passed') ||
|
|
||||||
comment.body.includes('## ❌ Backend License Check Failed')
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const comment of backendLicenseComments) {
|
|
||||||
console.log(`Deleting old backend license comment: ${comment.id}`);
|
|
||||||
await github.rest.issues.deleteComment({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
comment_id: comment.id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Comment on PR - Backend License Check Results
|
|
||||||
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) && github.actor != 'dependabot[bot]'
|
|
||||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
||||||
with:
|
|
||||||
github-token: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
script: |
|
|
||||||
const hasWarnings = process.env.LICENSE_WARNINGS_EXIST === 'true';
|
|
||||||
const fs = require('fs');
|
|
||||||
let warningDetails = '';
|
|
||||||
|
|
||||||
if (hasWarnings) {
|
|
||||||
try {
|
|
||||||
const warningsFile = 'build/reports/dependency-license/dependencies-without-allowed-license.json';
|
|
||||||
if (fs.existsSync(warningsFile)) {
|
|
||||||
const data = JSON.parse(fs.readFileSync(warningsFile, 'utf8'));
|
|
||||||
if (data.length > 0) {
|
|
||||||
warningDetails = data.map(dep => `- **${dep.moduleName}@${dep.moduleVersion}** – ${dep.moduleLicenses.map(l => l.licenseName).join(', ')}`).join('\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
warningDetails = 'Unable to parse warning details.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let commentBody;
|
|
||||||
if (hasWarnings) {
|
|
||||||
commentBody = `## ❌ Backend License Check Failed
|
|
||||||
|
|
||||||
The backend license check has detected dependencies with incompatible or unallowed licenses:
|
|
||||||
|
|
||||||
${warningDetails || 'See uploaded artifact for details.'}
|
|
||||||
|
|
||||||
**Action Required:** Please review these licenses and resolve before merging.
|
|
||||||
|
|
||||||
_This check will fail the PR until license issues are resolved._`;
|
|
||||||
} else {
|
|
||||||
commentBody = `## ✅ Backend License Check Passed
|
|
||||||
|
|
||||||
All backend dependencies have valid and allowed licenses.
|
|
||||||
|
|
||||||
The backend license report has been updated successfully.`;
|
|
||||||
}
|
|
||||||
|
|
||||||
await github.rest.issues.createComment({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
issue_number: context.issue.number,
|
|
||||||
body: commentBody
|
|
||||||
});
|
|
||||||
|
|
||||||
- name: Fail workflow if license warnings exist (PR only)
|
|
||||||
if: github.event_name == 'pull_request' && env.LICENSE_WARNINGS_EXIST == 'true'
|
|
||||||
run: |
|
|
||||||
echo "❌ Backend license warnings detected. Failing the workflow."
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
- name: Commit changes (push only)
|
|
||||||
if: github.event_name == 'push' && env.LICENSE_WARNINGS_EXIST == 'false'
|
|
||||||
run: |
|
|
||||||
git config user.name "${{ steps.setup-bot.outputs.committer }}"
|
|
||||||
git config user.email "${{ steps.setup-bot.outputs.committer-email || 'bot@github.com' }}"
|
|
||||||
git add app/core/src/main/resources/static/3rdPartyLicenses.json
|
|
||||||
git diff --staged --quiet || echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Prepare PR body (push only)
|
|
||||||
if: github.event_name == 'push' && env.CHANGES_DETECTED == 'true'
|
|
||||||
run: |
|
|
||||||
PR_BODY="Auto-generated by ${{ steps.setup-bot.outputs.app-slug }}[bot]
|
|
||||||
|
|
||||||
This PR updates the backend license report based on dependency changes."
|
|
||||||
|
|
||||||
if [ "${{ env.LICENSE_WARNINGS_EXIST }}" = "true" ]; then
|
|
||||||
PR_BODY="$PR_BODY
|
|
||||||
|
|
||||||
## ⚠️ License Compatibility Warnings
|
|
||||||
|
|
||||||
Incompatible licenses detected – manual review required before merge."
|
|
||||||
fi
|
|
||||||
echo "PR_BODY<<EOF" >> $GITHUB_ENV
|
|
||||||
echo "$PR_BODY" >> $GITHUB_ENV
|
|
||||||
echo "EOF" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Create Pull Request (push only)
|
|
||||||
if: github.event_name == 'push' && env.CHANGES_DETECTED == 'true'
|
|
||||||
id: cpr
|
|
||||||
uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v8.0.0
|
|
||||||
with:
|
|
||||||
token: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
commit-message: "Update Backend 3rd Party Licenses"
|
|
||||||
committer: ${{ steps.setup-bot.outputs.committer }}
|
|
||||||
author: ${{ steps.setup-bot.outputs.committer }}
|
|
||||||
signoff: true
|
|
||||||
branch: update-backend-3rd-party-licenses
|
|
||||||
base: main
|
|
||||||
title: "Update Backend 3rd Party Licenses"
|
|
||||||
body: ${{ env.PR_BODY }}
|
|
||||||
labels: Licenses,github-actions,backend
|
|
||||||
delete-branch: true
|
|
||||||
sign-commits: true
|
|
||||||
|
|
||||||
- name: Enable Pull Request Automerge (push only, no warnings)
|
|
||||||
if: github.event_name == 'push' && steps.cpr.outputs.pull-request-operation == 'created' && env.LICENSE_WARNINGS_EXIST == 'false'
|
|
||||||
run: gh pr merge --squash --auto "${{ steps.cpr.outputs.pull-request-number }}"
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
|
|
||||||
- name: Add review required label (push only, with warnings)
|
|
||||||
if: github.event_name == 'push' && steps.cpr.outputs.pull-request-operation == 'created' && env.LICENSE_WARNINGS_EXIST == 'true'
|
|
||||||
run: gh pr edit "${{ steps.cpr.outputs.pull-request-number }}" --add-label "license-review-required"
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ steps.setup-bot.outputs.token }}
|
|
||||||
@@ -0,0 +1,282 @@
|
|||||||
|
name: Frontend License Report Workflow
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- V2
|
||||||
|
paths:
|
||||||
|
- "frontend/package.json"
|
||||||
|
- "frontend/package-lock.json"
|
||||||
|
- "frontend/scripts/generate-licenses.js"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- V2
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/frontend-licenses-update.yml"
|
||||||
|
- "frontend/package.json"
|
||||||
|
- "frontend/package-lock.json"
|
||||||
|
- "frontend/scripts/generate-licenses.js"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate-frontend-license-report:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
repository-projects: write # Required for enabling automerge
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- name: Checkout PR head (default)
|
||||||
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Setup GitHub App Bot
|
||||||
|
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false)
|
||||||
|
id: setup-bot
|
||||||
|
uses: ./.github/actions/setup-bot
|
||||||
|
with:
|
||||||
|
app-id: ${{ secrets.GH_APP_ID }}
|
||||||
|
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Checkout BASE branch (safe script)
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.base.sha }}
|
||||||
|
path: base
|
||||||
|
fetch-depth: 1
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: frontend/package-lock.json
|
||||||
|
|
||||||
|
- name: Install frontend dependencies
|
||||||
|
working-directory: frontend
|
||||||
|
env:
|
||||||
|
NPM_CONFIG_IGNORE_SCRIPTS: "true"
|
||||||
|
run: npm ci --ignore-scripts --audit=false --fund=false
|
||||||
|
|
||||||
|
- name: Generate frontend license report (internal PR)
|
||||||
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
|
||||||
|
working-directory: frontend
|
||||||
|
env:
|
||||||
|
PR_IS_FORK: "false"
|
||||||
|
run: npm run generate-licenses
|
||||||
|
|
||||||
|
- name: Generate frontend license report (fork PRs, pinned)
|
||||||
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
|
||||||
|
env:
|
||||||
|
NPM_CONFIG_IGNORE_SCRIPTS: "true"
|
||||||
|
working-directory: frontend
|
||||||
|
run: |
|
||||||
|
mkdir -p src/assets
|
||||||
|
npx --yes license-report --only=prod --output=json > src/assets/3rdPartyLicenses.json
|
||||||
|
|
||||||
|
- name: Postprocess with project script (BASE version)
|
||||||
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
|
||||||
|
env:
|
||||||
|
PR_IS_FORK: "true"
|
||||||
|
run: |
|
||||||
|
node base/frontend/scripts/generate-licenses.js \
|
||||||
|
--input frontend/src/assets/3rdPartyLicenses.json
|
||||||
|
|
||||||
|
- name: Copy postprocessed artifacts back (fork PRs)
|
||||||
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
|
||||||
|
run: |
|
||||||
|
mkdir -p frontend/src/assets
|
||||||
|
if [ -f "base/frontend/src/assets/3rdPartyLicenses.json" ]; then
|
||||||
|
cp base/frontend/src/assets/3rdPartyLicenses.json frontend/src/assets/3rdPartyLicenses.json
|
||||||
|
fi
|
||||||
|
if [ -f "base/frontend/src/assets/license-warnings.json" ]; then
|
||||||
|
cp base/frontend/src/assets/license-warnings.json frontend/src/assets/license-warnings.json
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check for license warnings
|
||||||
|
run: |
|
||||||
|
if [ -f "frontend/src/assets/license-warnings.json" ]; then
|
||||||
|
echo "LICENSE_WARNINGS_EXIST=true" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "LICENSE_WARNINGS_EXIST=false" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
# PR Event: Check licenses and comment on PR
|
||||||
|
- name: Delete previous license check comments
|
||||||
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
|
||||||
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||||
|
with:
|
||||||
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
|
script: |
|
||||||
|
const { owner, repo } = context.repo;
|
||||||
|
const prNumber = context.issue.number;
|
||||||
|
|
||||||
|
// Get all comments on the PR
|
||||||
|
const { data: comments } = await github.rest.issues.listComments({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: prNumber,
|
||||||
|
per_page: 100
|
||||||
|
});
|
||||||
|
|
||||||
|
// Filter for license check comments
|
||||||
|
const licenseComments = comments.filter(comment =>
|
||||||
|
comment.body.includes('## ✅ Frontend License Check Passed') ||
|
||||||
|
comment.body.includes('## ❌ Frontend License Check Failed')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Delete old license check comments
|
||||||
|
for (const comment of licenseComments) {
|
||||||
|
console.log(`Deleting old license check comment: ${comment.id}`);
|
||||||
|
await github.rest.issues.deleteComment({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
comment_id: comment.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Summarize results (fork PRs)
|
||||||
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
|
||||||
|
run: |
|
||||||
|
{
|
||||||
|
echo "## Frontend License Check"
|
||||||
|
echo ""
|
||||||
|
if [ "${LICENSE_WARNINGS_EXIST}" = "true" ]; then
|
||||||
|
echo "❌ **Failed** – incompatible or unknown licenses found."
|
||||||
|
if [ -f "frontend/src/assets/license-warnings.json" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "### Warnings"
|
||||||
|
jq -r '.warnings[] | "- \(.message)"' frontend/src/assets/license-warnings.json || true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "✅ **Passed** – no license warnings detected."
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
echo "_Note: This is a fork PR. PR comments are disabled; use this summary._"
|
||||||
|
} >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
|
||||||
|
- name: Comment on PR - License Check Results
|
||||||
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
|
||||||
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||||
|
with:
|
||||||
|
github-token: ${{ steps.setup-bot.outputs.token }}
|
||||||
|
script: |
|
||||||
|
const { owner, repo } = context.repo;
|
||||||
|
const prNumber = context.issue.number;
|
||||||
|
const hasWarnings = process.env.LICENSE_WARNINGS_EXIST === 'true';
|
||||||
|
|
||||||
|
let commentBody;
|
||||||
|
|
||||||
|
if (hasWarnings) {
|
||||||
|
// Read warnings file to get specific issues
|
||||||
|
const fs = require('fs');
|
||||||
|
let warningDetails = '';
|
||||||
|
try {
|
||||||
|
const warnings = JSON.parse(fs.readFileSync('frontend/src/assets/license-warnings.json', 'utf8'));
|
||||||
|
warningDetails = warnings.warnings.map(w => `- ${w.message}`).join('\n');
|
||||||
|
} catch (e) {
|
||||||
|
warningDetails = 'Unable to read warning details';
|
||||||
|
}
|
||||||
|
|
||||||
|
commentBody = `## ❌ Frontend License Check Failed
|
||||||
|
|
||||||
|
The frontend license check has detected compatibility warnings that require review:
|
||||||
|
|
||||||
|
${warningDetails}
|
||||||
|
|
||||||
|
**Action Required:** Please review these licenses to ensure they are acceptable for your use case before merging.
|
||||||
|
|
||||||
|
_This check will fail the PR until license issues are resolved._`;
|
||||||
|
} else {
|
||||||
|
commentBody = `## ✅ Frontend License Check Passed
|
||||||
|
|
||||||
|
All frontend licenses have been validated and no compatibility warnings were detected.
|
||||||
|
|
||||||
|
The frontend license report has been updated successfully.`;
|
||||||
|
}
|
||||||
|
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: prNumber,
|
||||||
|
body: commentBody
|
||||||
|
});
|
||||||
|
|
||||||
|
- name: Fail workflow if license warnings exist (PR only)
|
||||||
|
if: github.event_name == 'pull_request' && env.LICENSE_WARNINGS_EXIST == 'true'
|
||||||
|
run: |
|
||||||
|
echo "❌ License warnings detected. Failing the workflow."
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
# Push Event: Commit license files and create PR
|
||||||
|
- name: Commit changes (Push only)
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
run: |
|
||||||
|
git add frontend/src/assets/3rdPartyLicenses.json
|
||||||
|
# Note: Do NOT commit license-warnings.json - it's only for PR review
|
||||||
|
git diff --staged --quiet || echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Prepare PR body (Push only)
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
run: |
|
||||||
|
PR_BODY="Auto-generated by ${{ steps.setup-bot.outputs.app-slug }}[bot]
|
||||||
|
|
||||||
|
This PR updates the frontend license report based on changes to package.json dependencies."
|
||||||
|
|
||||||
|
if [ "${{ env.LICENSE_WARNINGS_EXIST }}" = "true" ]; then
|
||||||
|
PR_BODY="$PR_BODY
|
||||||
|
|
||||||
|
## ⚠️ License Compatibility Warnings
|
||||||
|
|
||||||
|
The following licenses may require review for corporate compatibility:
|
||||||
|
|
||||||
|
$(cat frontend/src/assets/license-warnings.json | jq -r '.warnings[].message')
|
||||||
|
|
||||||
|
Please review these licenses to ensure they are acceptable for your use case."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "PR_BODY<<EOF" >> $GITHUB_ENV
|
||||||
|
echo "$PR_BODY" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Create Pull Request (Push only)
|
||||||
|
id: cpr
|
||||||
|
if: github.event_name == 'push' && env.CHANGES_DETECTED == 'true'
|
||||||
|
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
|
||||||
|
with:
|
||||||
|
token: ${{ steps.setup-bot.outputs.token }}
|
||||||
|
commit-message: "Update Frontend 3rd Party Licenses"
|
||||||
|
committer: ${{ steps.setup-bot.outputs.committer }}
|
||||||
|
author: ${{ steps.setup-bot.outputs.committer }}
|
||||||
|
signoff: true
|
||||||
|
branch: update-frontend-3rd-party-licenses
|
||||||
|
base: V2
|
||||||
|
title: "Update Frontend 3rd Party Licenses"
|
||||||
|
body: ${{ env.PR_BODY }}
|
||||||
|
labels: Licenses,github-actions,frontend
|
||||||
|
draft: false
|
||||||
|
delete-branch: true
|
||||||
|
sign-commits: true
|
||||||
|
|
||||||
|
- name: Enable Pull Request Automerge (Push only)
|
||||||
|
if: github.event_name == 'push' && steps.cpr.outputs.pull-request-operation == 'created' && env.LICENSE_WARNINGS_EXIST == 'false'
|
||||||
|
run: gh pr merge --squash --auto "${{ steps.cpr.outputs.pull-request-number }}"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ steps.setup-bot.outputs.token }}
|
||||||
|
|
||||||
|
- name: Add review required label (Push only)
|
||||||
|
if: github.event_name == 'push' && steps.cpr.outputs.pull-request-operation == 'created' && env.LICENSE_WARNINGS_EXIST == 'true'
|
||||||
|
run: gh pr edit "${{ steps.cpr.outputs.pull-request-number }}" --add-label "license-review-required"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ steps.setup-bot.outputs.token }}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
name: License Report Workflow
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- "build.gradle"
|
||||||
|
|
||||||
|
# cancel in-progress jobs if a new job is triggered
|
||||||
|
# This is useful to avoid running multiple builds for the same branch if a new commit is pushed
|
||||||
|
# or a pull request is updated.
|
||||||
|
# It helps to save resources and time by ensuring that only the latest commit is built and tested
|
||||||
|
# This is particularly useful for long-running jobs that may take a while to complete.
|
||||||
|
# The `group` is set to a combination of the workflow name, event name, and branch name.
|
||||||
|
# This ensures that jobs are grouped by the workflow and branch, allowing for cancellation of
|
||||||
|
# in-progress jobs when a new commit is pushed to the same branch or a new pull request is opened.
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name || github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate-license-report:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
repository-projects: write # Required for enabling automerge
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup GitHub App Bot
|
||||||
|
id: setup-bot
|
||||||
|
uses: ./.github/actions/setup-bot
|
||||||
|
with:
|
||||||
|
app-id: ${{ secrets.GH_APP_ID }}
|
||||||
|
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
|
with:
|
||||||
|
java-version: "17"
|
||||||
|
distribution: "temurin"
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
|
||||||
|
|
||||||
|
- name: Check licenses for compatibility
|
||||||
|
run: ./gradlew clean checkLicense
|
||||||
|
|
||||||
|
- name: Upload artifact on failure
|
||||||
|
if: failure()
|
||||||
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
|
with:
|
||||||
|
name: dependencies-without-allowed-license.json
|
||||||
|
path: build/reports/dependency-license/dependencies-without-allowed-license.json
|
||||||
|
retention-days: 3
|
||||||
|
|
||||||
|
- name: Move and rename license file
|
||||||
|
run: |
|
||||||
|
mv build/reports/dependency-license/index.json app/core/src/main/resources/static/3rdPartyLicenses.json
|
||||||
|
|
||||||
|
- name: Commit changes
|
||||||
|
run: |
|
||||||
|
git add app/core/src/main/resources/static/3rdPartyLicenses.json
|
||||||
|
git diff --staged --quiet || echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
id: cpr
|
||||||
|
if: env.CHANGES_DETECTED == 'true'
|
||||||
|
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
|
||||||
|
with:
|
||||||
|
token: ${{ steps.setup-bot.outputs.token }}
|
||||||
|
commit-message: "Update 3rd Party Licenses"
|
||||||
|
committer: ${{ steps.setup-bot.outputs.committer }}
|
||||||
|
author: ${{ steps.setup-bot.outputs.committer }}
|
||||||
|
signoff: true
|
||||||
|
branch: update-3rd-party-licenses
|
||||||
|
title: "Update 3rd Party Licenses"
|
||||||
|
body: |
|
||||||
|
Auto-generated by ${{ steps.setup-bot.outputs.app-slug }}[bot]
|
||||||
|
labels: Licenses,github-actions
|
||||||
|
draft: false
|
||||||
|
delete-branch: true
|
||||||
|
sign-commits: true
|
||||||
|
|
||||||
|
- name: Enable Pull Request Automerge
|
||||||
|
if: steps.cpr.outputs.pull-request-operation == 'created'
|
||||||
|
run: gh pr merge --squash --auto "${{ steps.cpr.outputs.pull-request-number }}"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ steps.setup-bot.outputs.token }}
|
||||||
@@ -15,12 +15,12 @@ jobs:
|
|||||||
issues: write
|
issues: write
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Check out the repository
|
- name: Check out the repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Run Labeler
|
- name: Run Labeler
|
||||||
uses: crazy-max/ghaction-github-labeler@24d110aa46a59976b8a7f35518cb7f14f434c916 # v5.3.0
|
uses: crazy-max/ghaction-github-labeler@24d110aa46a59976b8a7f35518cb7f14f434c916 # v5.3.0
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: Multi-OS Tauri Releases
|
name: Test Installers Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -6,23 +6,7 @@ on:
|
|||||||
test_mode:
|
test_mode:
|
||||||
description: "Run in test mode (skip release step)"
|
description: "Run in test mode (skip release step)"
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "false"
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- "true"
|
|
||||||
- "false"
|
|
||||||
platform:
|
|
||||||
description: "Platform to build (windows, macos, linux, or all)"
|
|
||||||
required: true
|
|
||||||
default: "all"
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- all
|
|
||||||
- windows
|
|
||||||
- macos
|
|
||||||
- linux
|
|
||||||
push:
|
|
||||||
branches: [main, V2-master]
|
|
||||||
release:
|
release:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
@@ -30,564 +14,305 @@ permissions:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
determine-matrix:
|
read_versions:
|
||||||
if: ${{ vars.CI_PROFILE != 'lite' }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
||||||
version: ${{ steps.versionNumber.outputs.versionNumber }}
|
version: ${{ steps.versionNumber.outputs.versionNumber }}
|
||||||
|
versionMac: ${{ steps.versionNumberMac.outputs.versionNumberMac }}
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
distribution: 'temurin'
|
||||||
distribution: "temurin"
|
java-version: '21'
|
||||||
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
|
||||||
gradle-version: 8.14
|
|
||||||
|
|
||||||
|
# ✅ Get version from Gradle
|
||||||
- name: Get version number
|
- name: Get version number
|
||||||
id: versionNumber
|
id: versionNumber
|
||||||
run: |
|
run: |
|
||||||
echo "Running gradlew printVersion..."
|
|
||||||
./gradlew printVersion --quiet
|
|
||||||
VERSION=$(./gradlew printVersion --quiet | tail -1)
|
VERSION=$(./gradlew printVersion --quiet | tail -1)
|
||||||
echo "Extracted version: $VERSION"
|
|
||||||
echo "versionNumber=$VERSION" >> $GITHUB_OUTPUT
|
echo "versionNumber=$VERSION" >> $GITHUB_OUTPUT
|
||||||
env:
|
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
|
|
||||||
- name: Determine build matrix
|
# ✅ Get Mac-specific version from Gradle
|
||||||
id: set-matrix
|
- name: Get version number mac
|
||||||
|
id: versionNumberMac
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
VERSION_MAC=$(./gradlew printMacVersion --quiet | tail -1)
|
||||||
case "${{ github.event.inputs.platform }}" in
|
echo "versionNumberMac=$VERSION_MAC" >> $GITHUB_OUTPUT
|
||||||
"windows")
|
|
||||||
echo 'matrix={"include":[{"platform":"windows-latest","args":"--target x86_64-pc-windows-msvc","name":"windows-x86_64"}]}' >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
"macos")
|
|
||||||
echo 'matrix={"include":[{"platform":"macos-15","args":"--target aarch64-apple-darwin","name":"macos-aarch64"},{"platform":"macos-15-intel","args":"--target x86_64-apple-darwin","name":"macos-x86_64"}]}' >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
"linux")
|
|
||||||
echo 'matrix={"include":[{"platform":"ubuntu-22.04","args":"","name":"linux-x86_64"}]}' >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo 'matrix={"include":[{"platform":"windows-latest","args":"--target x86_64-pc-windows-msvc","name":"windows-x86_64"},{"platform":"macos-15","args":"--target aarch64-apple-darwin","name":"macos-aarch64"},{"platform":"macos-15-intel","args":"--target x86_64-apple-darwin","name":"macos-x86_64"},{"platform":"ubuntu-22.04","args":"","name":"linux-x86_64"}]}' >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
# For push/release events, build all platforms
|
|
||||||
echo 'matrix={"include":[{"platform":"windows-latest","args":"--target x86_64-pc-windows-msvc","name":"windows-x86_64"},{"platform":"macos-15","args":"--target aarch64-apple-darwin","name":"macos-aarch64"},{"platform":"macos-15-intel","args":"--target x86_64-apple-darwin","name":"macos-x86_64"},{"platform":"ubuntu-22.04","args":"","name":"linux-x86_64"}]}' >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
build-jars:
|
build-portable:
|
||||||
needs: determine-matrix
|
needs: read_versions
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
variant:
|
disable_security: [true, false]
|
||||||
- name: "default"
|
include:
|
||||||
disable_security: true
|
- disable_security: false
|
||||||
build_frontend: true
|
|
||||||
file_suffix: ""
|
|
||||||
- name: "with-login"
|
|
||||||
disable_security: false
|
|
||||||
build_frontend: true
|
|
||||||
file_suffix: "-with-login"
|
file_suffix: "-with-login"
|
||||||
- name: "server-only"
|
- disable_security: true
|
||||||
disable_security: true
|
file_suffix: ""
|
||||||
build_frontend: false
|
|
||||||
file_suffix: "-server"
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
java-version: "21"
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
|
||||||
- name: Setup Gradle
|
- uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
with:
|
||||||
gradle-version: 8.14
|
gradle-version: 8.14
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Generate jar (Disable Security=${{ matrix.disable_security }})
|
||||||
if: matrix.variant.build_frontend == true
|
run: ./gradlew clean createExe
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
cache: "npm"
|
|
||||||
cache-dependency-path: frontend/package-lock.json
|
|
||||||
|
|
||||||
- name: Build JAR
|
|
||||||
run: ./gradlew build ${{ matrix.variant.build_frontend && '-PbuildWithFrontend=true' || '' }} -x spotlessApply -x spotlessCheck -x test -x sonarqube
|
|
||||||
env:
|
env:
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
DISABLE_ADDITIONAL_FEATURES: ${{ matrix.disable_security }}
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
DISABLE_ADDITIONAL_FEATURES: ${{ matrix.variant.disable_security }}
|
|
||||||
STIRLING_PDF_DESKTOP_UI: false
|
STIRLING_PDF_DESKTOP_UI: false
|
||||||
|
|
||||||
- name: Rename JAR
|
- name: Rename binaries
|
||||||
run: |
|
run: |
|
||||||
echo "Version from determine-matrix: ${{ needs.determine-matrix.outputs.version }}"
|
mkdir ./binaries
|
||||||
echo "Looking for: app/core/build/libs/stirling-pdf-${{ needs.determine-matrix.outputs.version }}.jar"
|
mv ./build/launch4j/Stirling-PDF.exe ./binaries/win-Stirling-PDF-portable-Server${{ matrix.file_suffix }}.exe
|
||||||
ls -la app/core/build/libs/
|
mv ./app/core/build/libs/stirling-pdf-${{ needs.read_versions.outputs.version }}.jar ./binaries/Stirling-PDF${{ matrix.file_suffix }}.jar
|
||||||
mkdir -p ./jar-dist
|
|
||||||
cp app/core/build/libs/stirling-pdf-${{ needs.determine-matrix.outputs.version }}.jar ./jar-dist/Stirling-PDF${{ matrix.variant.file_suffix }}.jar
|
|
||||||
|
|
||||||
- name: Upload JAR artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: jar${{ matrix.variant.file_suffix }}
|
|
||||||
path: ./jar-dist/*.jar
|
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
if-no-files-found: error
|
||||||
|
name: stirling${{ matrix.file_suffix }}-binaries
|
||||||
|
path: |
|
||||||
|
./binaries/*
|
||||||
|
|
||||||
build:
|
sign_verify-portable:
|
||||||
needs: determine-matrix
|
needs: [build-portable, read_versions]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
matrix:
|
||||||
matrix: ${{ fromJson(needs.determine-matrix.outputs.matrix) }}
|
disable_security: [true, false]
|
||||||
runs-on: ${{ matrix.platform }}
|
include:
|
||||||
env:
|
- disable_security: false
|
||||||
SM_API_KEY: ${{ secrets.SM_API_KEY }}
|
file_suffix: "with-login-"
|
||||||
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
- disable_security: true
|
||||||
|
file_suffix: ""
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Download build artifacts
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
|
||||||
|
|
||||||
- name: Install dependencies (ubuntu only)
|
|
||||||
if: matrix.platform == 'ubuntu-22.04'
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libjavascriptcoregtk-4.0-dev libsoup2.4-dev libjavascriptcoregtk-4.1-dev libsoup-3.0-dev
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
name: stirling-${{ matrix.file_suffix }}binaries
|
||||||
cache: "npm"
|
|
||||||
cache-dependency-path: frontend/package-lock.json
|
|
||||||
|
|
||||||
- name: Setup Rust
|
- name: Display structure of downloaded files
|
||||||
uses: dtolnay/rust-toolchain@stable
|
run: ls -R
|
||||||
|
|
||||||
|
- name: Upload signed artifacts
|
||||||
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
retention-days: 1
|
||||||
targets: ${{ (matrix.platform == 'macos-15' || matrix.platform == 'macos-15-intel') && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
|
if-no-files-found: error
|
||||||
|
name: stirling-${{ matrix.file_suffix }}signed
|
||||||
|
path: |
|
||||||
|
./*
|
||||||
|
!cosign.*
|
||||||
|
|
||||||
|
build-installers:
|
||||||
|
needs: read_versions
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: windows-latest
|
||||||
|
platform: win-
|
||||||
|
- os: macos-latest
|
||||||
|
platform: mac-
|
||||||
|
# - os: ubuntu-latest
|
||||||
|
# platform: linux-
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
java-version: "21"
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
|
||||||
- name: Setup Gradle
|
- uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
with:
|
||||||
gradle-version: 8.14
|
gradle-version: 8.14
|
||||||
|
|
||||||
- name: Build Java backend with JLink
|
# Install Windows dependencies
|
||||||
working-directory: ./
|
- name: Install WiX Toolset
|
||||||
shell: bash
|
if: matrix.os == 'windows-latest'
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./gradlew
|
curl -L -o wix.exe https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314.exe
|
||||||
echo "🔧 Building Stirling-PDF JAR..."
|
.\wix.exe /install /quiet
|
||||||
./gradlew build -x spotlessApply -x spotlessCheck -x test -x sonarqube
|
|
||||||
|
|
||||||
# Find the built JAR
|
# Build installer
|
||||||
STIRLING_JAR=$(ls app/core/build/libs/stirling-pdf-*.jar | head -n 1)
|
- name: Build Installer
|
||||||
echo "✅ Built JAR: $STIRLING_JAR"
|
run: ./gradlew build jpackage -x test --info
|
||||||
|
|
||||||
# Create Tauri directories
|
|
||||||
mkdir -p ./frontend/src-tauri/libs
|
|
||||||
mkdir -p ./frontend/src-tauri/runtime
|
|
||||||
|
|
||||||
# Copy JAR to Tauri libs
|
|
||||||
cp "$STIRLING_JAR" ./frontend/src-tauri/libs/
|
|
||||||
echo "✅ JAR copied to Tauri libs"
|
|
||||||
|
|
||||||
# Analyze JAR dependencies for jlink modules
|
|
||||||
echo "🔍 Analyzing JAR dependencies..."
|
|
||||||
if command -v jdeps &> /dev/null; then
|
|
||||||
DETECTED_MODULES=$(jdeps --print-module-deps --ignore-missing-deps "$STIRLING_JAR" 2>/dev/null || echo "")
|
|
||||||
if [ -n "$DETECTED_MODULES" ]; then
|
|
||||||
echo "📋 jdeps detected modules: $DETECTED_MODULES"
|
|
||||||
MODULES="$DETECTED_MODULES,java.compiler,java.instrument,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.security.jgss,java.security.sasl,java.sql,java.transaction.xa,java.xml.crypto,jdk.crypto.ec,jdk.crypto.cryptoki,jdk.unsupported"
|
|
||||||
else
|
|
||||||
echo "⚠️ jdeps analysis failed, using predefined modules"
|
|
||||||
MODULES="java.base,java.compiler,java.desktop,java.instrument,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.security.jgss,java.security.sasl,java.sql,java.transaction.xa,java.xml,java.xml.crypto,jdk.crypto.ec,jdk.crypto.cryptoki,jdk.unsupported"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "⚠️ jdeps not available, using predefined modules"
|
|
||||||
MODULES="java.base,java.compiler,java.desktop,java.instrument,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.security.jgss,java.security.sasl,java.sql,java.transaction.xa,java.xml,java.xml.crypto,jdk.crypto.ec,jdk.crypto.cryptoki,jdk.unsupported"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create custom JRE with jlink
|
|
||||||
echo "🔧 Creating custom JRE with jlink..."
|
|
||||||
echo "📋 Using modules: $MODULES"
|
|
||||||
|
|
||||||
# Remove any existing JRE
|
|
||||||
rm -rf ./frontend/src-tauri/runtime/jre
|
|
||||||
|
|
||||||
# Create the custom JRE
|
|
||||||
jlink \
|
|
||||||
--add-modules "$MODULES" \
|
|
||||||
--strip-debug \
|
|
||||||
--compress=2 \
|
|
||||||
--no-header-files \
|
|
||||||
--no-man-pages \
|
|
||||||
--output ./frontend/src-tauri/runtime/jre
|
|
||||||
|
|
||||||
if [ ! -d "./frontend/src-tauri/runtime/jre" ]; then
|
|
||||||
echo "❌ Failed to create JLink runtime"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Test the bundled runtime
|
|
||||||
if [ -f "./frontend/src-tauri/runtime/jre/bin/java" ]; then
|
|
||||||
RUNTIME_VERSION=$(./frontend/src-tauri/runtime/jre/bin/java --version 2>&1 | head -n 1)
|
|
||||||
echo "✅ Custom JRE created successfully: $RUNTIME_VERSION"
|
|
||||||
else
|
|
||||||
echo "❌ Custom JRE executable not found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Calculate runtime size
|
|
||||||
RUNTIME_SIZE=$(du -sh ./frontend/src-tauri/runtime/jre | cut -f1)
|
|
||||||
echo "📊 Custom JRE size: $RUNTIME_SIZE"
|
|
||||||
env:
|
env:
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
DISABLE_ADDITIONAL_FEATURES: true
|
DISABLE_ADDITIONAL_FEATURES: true
|
||||||
|
STIRLING_PDF_DESKTOP_UI: true
|
||||||
|
BROWSER_OPEN: true
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
- name: Set up JDK (x86_64)
|
||||||
working-directory: ./frontend
|
if: matrix.os == 'macos-latest'
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
# DigiCert KeyLocker Setup (Cloud HSM)
|
|
||||||
- name: Setup DigiCert KeyLocker
|
|
||||||
id: digicert-setup
|
|
||||||
if: ${{ matrix.platform == 'windows-latest' && env.SM_API_KEY != '' && (github.event_name == 'release' || github.ref == 'refs/heads/V2-master') }}
|
|
||||||
uses: digicert/ssm-code-signing@v1.1.0
|
|
||||||
env:
|
|
||||||
SM_API_KEY: ${{ secrets.SM_API_KEY }}
|
|
||||||
SM_CLIENT_CERT_FILE_B64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}
|
|
||||||
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
|
|
||||||
SM_KEYPAIR_ALIAS: ${{ secrets.SM_KEYPAIR_ALIAS }}
|
|
||||||
SM_HOST: ${{ secrets.SM_HOST }}
|
|
||||||
|
|
||||||
- name: Setup DigiCert KeyLocker Certificate
|
|
||||||
if: ${{ matrix.platform == 'windows-latest' && env.SM_API_KEY != '' && (github.event_name == 'release' || github.ref == 'refs/heads/V2-master') }}
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
run: |
|
||||||
Write-Host "Setting up DigiCert KeyLocker environment..."
|
curl -L -o jdk.tar.gz https://cdn.azul.com/zulu/bin/zulu17.56.15-ca-jdk17.0.14-macosx_x64.tar.gz
|
||||||
|
mkdir -p zulu17
|
||||||
|
tar -xzf jdk.tar.gz -C zulu17 --strip-components=1
|
||||||
|
echo "JAVA_HOME=$PWD/zulu17" >> $GITHUB_ENV
|
||||||
|
echo "$PWD/zulu17/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
# Decode client certificate
|
- name: Verify JDK architecture
|
||||||
$certBytes = [Convert]::FromBase64String("${{ secrets.SM_CLIENT_CERT_FILE_B64 }}")
|
if: matrix.os == 'macos-latest'
|
||||||
$certPath = "D:\Certificate_pkcs12.p12"
|
run: file $JAVA_HOME/bin/java
|
||||||
[IO.File]::WriteAllBytes($certPath, $certBytes)
|
|
||||||
|
|
||||||
# Set environment variables
|
- name: Build project and run jpackage (x86_64)
|
||||||
echo "SM_CLIENT_CERT_FILE=D:\Certificate_pkcs12.p12" >> $env:GITHUB_ENV
|
if: matrix.os == 'macos-latest'
|
||||||
echo "SM_HOST=${{ secrets.SM_HOST }}" >> $env:GITHUB_ENV
|
run: arch -x86_64 ./gradlew jpackageMacX64
|
||||||
echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> $env:GITHUB_ENV
|
|
||||||
echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> $env:GITHUB_ENV
|
|
||||||
echo "SM_KEYPAIR_ALIAS=${{ secrets.SM_KEYPAIR_ALIAS }}" >> $env:GITHUB_ENV
|
|
||||||
|
|
||||||
# Get PKCS11 config path from DigiCert action
|
# Rename and collect artifacts based on OS
|
||||||
$pkcs11Config = $env:PKCS11_CONFIG
|
- name: Prepare artifacts
|
||||||
if ($pkcs11Config) {
|
id: prepare
|
||||||
Write-Host "Found PKCS11_CONFIG: $pkcs11Config"
|
|
||||||
echo "PKCS11_CONFIG=$pkcs11Config" >> $env:GITHUB_ENV
|
|
||||||
} else {
|
|
||||||
Write-Host "PKCS11_CONFIG not set by DigiCert action, using default path"
|
|
||||||
$defaultPath = "C:\Users\RUNNER~1\AppData\Local\Temp\smtools-windows-x64\pkcs11properties.cfg"
|
|
||||||
if (Test-Path $defaultPath) {
|
|
||||||
Write-Host "Found config at default path: $defaultPath"
|
|
||||||
echo "PKCS11_CONFIG=$defaultPath" >> $env:GITHUB_ENV
|
|
||||||
} else {
|
|
||||||
Write-Host "Warning: Could not find PKCS11 config file"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Traditional PFX Certificate Import (fallback if KeyLocker not configured)
|
|
||||||
- name: Import Windows Code Signing Certificate
|
|
||||||
if: ${{ matrix.platform == 'windows-latest' && env.SM_API_KEY == '' && (github.event_name == 'release' || github.ref == 'refs/heads/V2-master') }}
|
|
||||||
env:
|
|
||||||
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
|
||||||
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
if ($env:WINDOWS_CERTIFICATE) {
|
|
||||||
Write-Host "Importing Windows Code Signing Certificate..."
|
|
||||||
|
|
||||||
# Decode base64 certificate and save to file
|
|
||||||
$certBytes = [Convert]::FromBase64String($env:WINDOWS_CERTIFICATE)
|
|
||||||
$certPath = Join-Path $env:RUNNER_TEMP "certificate.pfx"
|
|
||||||
[IO.File]::WriteAllBytes($certPath, $certBytes)
|
|
||||||
|
|
||||||
# Import certificate to CurrentUser\My store
|
|
||||||
$cert = Import-PfxCertificate -FilePath $certPath -CertStoreLocation Cert:\CurrentUser\My -Password (ConvertTo-SecureString -String $env:WINDOWS_CERTIFICATE_PASSWORD -AsPlainText -Force)
|
|
||||||
|
|
||||||
# Extract and set thumbprint as environment variable
|
|
||||||
$thumbprint = $cert.Thumbprint
|
|
||||||
Write-Host "Certificate imported with thumbprint: $thumbprint"
|
|
||||||
echo "WINDOWS_CERTIFICATE_THUMBPRINT=$thumbprint" >> $env:GITHUB_ENV
|
|
||||||
|
|
||||||
# Clean up certificate file
|
|
||||||
Remove-Item $certPath
|
|
||||||
|
|
||||||
Write-Host "Windows certificate import completed."
|
|
||||||
} else {
|
|
||||||
Write-Host "⚠️ WINDOWS_CERTIFICATE secret not set - building unsigned binary"
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Import Apple Developer Certificate
|
|
||||||
if: (matrix.platform == 'macos-15' || matrix.platform == 'macos-15-intel') && (github.event_name == 'release' || github.ref == 'refs/heads/V2-master')
|
|
||||||
env:
|
|
||||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
|
||||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
|
||||||
run: |
|
|
||||||
echo "Importing Apple Developer Certificate..."
|
|
||||||
echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
|
|
||||||
# Create temporary keychain
|
|
||||||
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
|
|
||||||
KEYCHAIN_PASSWORD=$(openssl rand -base64 32)
|
|
||||||
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
|
||||||
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
|
|
||||||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
|
||||||
# Import certificate
|
|
||||||
security import certificate.p12 -P "$APPLE_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
|
|
||||||
security list-keychain -d user -s $KEYCHAIN_PATH
|
|
||||||
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
|
||||||
# Clean up
|
|
||||||
rm certificate.p12
|
|
||||||
|
|
||||||
- name: Verify Certificate
|
|
||||||
if: (matrix.platform == 'macos-15' || matrix.platform == 'macos-15-intel') && (github.event_name == 'release' || github.ref == 'refs/heads/V2-master')
|
|
||||||
run: |
|
|
||||||
echo "Verifying Apple Developer Certificate..."
|
|
||||||
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
|
|
||||||
CERT_INFO=$(security find-identity -v -p codesigning $KEYCHAIN_PATH | grep "Developer ID Application")
|
|
||||||
echo "Certificate Info: $CERT_INFO"
|
|
||||||
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
|
|
||||||
echo "Certificate ID: $CERT_ID"
|
|
||||||
echo "APPLE_SIGNING_IDENTITY=$CERT_ID" >> $GITHUB_ENV
|
|
||||||
echo "Certificate imported successfully."
|
|
||||||
|
|
||||||
- name: Build Tauri app
|
|
||||||
uses: tauri-apps/tauri-action@v0
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
|
||||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
|
||||||
APPLE_SIGNING_IDENTITY: ${{ env.APPLE_SIGNING_IDENTITY }}
|
|
||||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
|
||||||
APPLE_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
|
|
||||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
|
||||||
APPIMAGETOOL_SIGN_PASSPHRASE: ${{ secrets.APPIMAGETOOL_SIGN_PASSPHRASE }}
|
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
||||||
VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY: ${{ secrets.VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY }}
|
|
||||||
VITE_SAAS_SERVER_URL: ${{ secrets.VITE_SAAS_SERVER_URL }}
|
|
||||||
# Only enable Windows signing in Tauri when on release or V2-master
|
|
||||||
SIGN: ${{ (github.event_name == 'release' || github.ref == 'refs/heads/V2-master') && (env.SM_API_KEY == '' && env.WINDOWS_CERTIFICATE != '') && '1' || '0' }}
|
|
||||||
CI: true
|
|
||||||
with:
|
|
||||||
projectPath: ./frontend
|
|
||||||
tauriScript: npx tauri
|
|
||||||
args: ${{ matrix.args }}
|
|
||||||
|
|
||||||
# Sign with DigiCert KeyLocker (post-build)
|
|
||||||
- name: Sign Windows binaries with DigiCert KeyLocker
|
|
||||||
if: ${{ matrix.platform == 'windows-latest' && env.SM_API_KEY != '' && (github.event_name == 'release' || github.ref == 'refs/heads/V2-master') }}
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
Write-Host "=== DigiCert KeyLocker Signing ==="
|
|
||||||
|
|
||||||
# Test smctl connectivity first
|
|
||||||
Write-Host "Testing smctl connection..."
|
|
||||||
$healthCheck = & smctl healthcheck 2>&1
|
|
||||||
if ($LASTEXITCODE -eq 0) {
|
|
||||||
Write-Host "[SUCCESS] Connected to DigiCert KeyLocker"
|
|
||||||
} else {
|
|
||||||
Write-Host "[ERROR] Failed to connect to DigiCert KeyLocker"
|
|
||||||
Write-Host $healthCheck
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
# Sync certificates to Windows certificate store
|
|
||||||
Write-Host "Syncing certificates to Windows certificate store..."
|
|
||||||
$syncOutput = & smctl windows certsync 2>&1
|
|
||||||
Write-Host "Cert sync result: $syncOutput"
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
# Find only the files we need to sign
|
|
||||||
$filesToSign = @()
|
|
||||||
|
|
||||||
# Main application executable
|
|
||||||
$mainExe = Get-ChildItem -Path "./frontend/src-tauri/target/x86_64-pc-windows-msvc/release" -Filter "stirling-pdf.exe" -File -ErrorAction SilentlyContinue
|
|
||||||
if ($mainExe) { $filesToSign += $mainExe }
|
|
||||||
|
|
||||||
# MSI installer
|
|
||||||
$msiFiles = Get-ChildItem -Path "./frontend/src-tauri/target" -Filter "*.msi" -Recurse -File
|
|
||||||
$filesToSign += $msiFiles
|
|
||||||
|
|
||||||
if ($filesToSign.Count -eq 0) {
|
|
||||||
Write-Host "[ERROR] No files found to sign"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Found $($filesToSign.Count) files to sign:"
|
|
||||||
foreach ($f in $filesToSign) { Write-Host " - $($f.Name)" }
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
$signedCount = 0
|
|
||||||
foreach ($file in $filesToSign) {
|
|
||||||
Write-Host "Signing: $($file.Name)"
|
|
||||||
|
|
||||||
# Get PKCS11 config file path
|
|
||||||
$pkcs11Config = $env:PKCS11_CONFIG
|
|
||||||
if (-not $pkcs11Config) {
|
|
||||||
Write-Host "[ERROR] PKCS11_CONFIG environment variable not set"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Using PKCS11 config: $pkcs11Config"
|
|
||||||
|
|
||||||
# Try signing with certificate fingerprint first (if available)
|
|
||||||
$fingerprint = "${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}"
|
|
||||||
if ($fingerprint -and $fingerprint -ne "") {
|
|
||||||
Write-Host "Attempting to sign with certificate fingerprint..."
|
|
||||||
$output = & smctl sign --fingerprint "$fingerprint" --input "$($file.FullName)" --config-file "$pkcs11Config" --verbose 2>&1
|
|
||||||
$exitCode = $LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
Write-Host "No fingerprint provided, using keypair alias..."
|
|
||||||
$output = & smctl sign --keypair-alias "${{ secrets.SM_KEYPAIR_ALIAS }}" --input "$($file.FullName)" --config-file "$pkcs11Config" --verbose 2>&1
|
|
||||||
$exitCode = $LASTEXITCODE
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Exit code: $exitCode"
|
|
||||||
Write-Host "Output: $output"
|
|
||||||
|
|
||||||
if ($output -match "FAILED" -or $output -match "error" -or $output -match "Error") {
|
|
||||||
Write-Host "[ERROR] Signing failed for $($file.Name)"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($exitCode -ne 0) {
|
|
||||||
Write-Host "[ERROR] Failed to sign $($file.Name)"
|
|
||||||
Write-Host "Full error output:"
|
|
||||||
Write-Host $output
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
$signedCount++
|
|
||||||
Write-Host "[SUCCESS] Signed: $($file.Name)"
|
|
||||||
Write-Host ""
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "=== Summary ==="
|
|
||||||
Write-Host "[SUCCESS] Signed $signedCount/$($filesToSign.Count) files successfully"
|
|
||||||
|
|
||||||
- name: Rename artifacts
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./dist
|
ls -lah ./build/jpackage/
|
||||||
cd ./frontend/src-tauri/target
|
mkdir ./binaries
|
||||||
|
if [ "${{ matrix.os }}" = "windows-latest" ]; then
|
||||||
# Find and rename artifacts based on platform
|
mv "./build/jpackage/Stirling PDF-${{ needs.read_versions.outputs.version }}.exe" "./binaries/Stirling-PDF-win-installer.exe"
|
||||||
if [ "${{ matrix.platform }}" = "windows-latest" ]; then
|
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
|
||||||
find . -name "*.exe" -exec cp {} "../../../dist/Stirling-PDF-${{ matrix.name }}.exe" \;
|
mv "./build/jpackage/Stirling PDF-${{ needs.read_versions.outputs.versionMac }}.dmg" "./binaries/Stirling-PDF-mac-installer.dmg"
|
||||||
find . -name "*.msi" -exec cp {} "../../../dist/Stirling-PDF-${{ matrix.name }}.msi" \;
|
mv "./build/jpackage/x86_64/Stirling PDF (x86_64)-${{ needs.read_versions.outputs.versionMac }}.dmg" "./binaries/Stirling-PDF-mac-x86_64-installer.dmg"
|
||||||
elif [ "${{ matrix.platform }}" = "macos-15" ] || [ "${{ matrix.platform }}" = "macos-15-intel" ]; then
|
|
||||||
find . -name "*.dmg" -exec cp {} "../../../dist/Stirling-PDF-${{ matrix.name }}.dmg" \;
|
|
||||||
find . -name "*.app" -exec cp -r {} "../../../dist/Stirling-PDF-${{ matrix.name }}.app" \;
|
|
||||||
else
|
else
|
||||||
find . -name "*.deb" -exec cp {} "../../../dist/Stirling-PDF-${{ matrix.name }}.deb" \;
|
mv "./build/jpackage/stirling-pdf_${{ needs.read_versions.outputs.version }}-1_amd64.deb" "./binaries/Stirling-PDF-linux-installer.deb"
|
||||||
find . -name "*.AppImage" -exec cp {} "../../../dist/Stirling-PDF-${{ matrix.name }}.AppImage" \;
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Display structure of downloaded files
|
||||||
|
run: ls -R ./binaries
|
||||||
|
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: Stirling-PDF-${{ matrix.name }}
|
|
||||||
path: ./dist/*
|
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
if-no-files-found: error
|
||||||
|
name: ${{ matrix.platform }}binaries
|
||||||
|
path: |
|
||||||
|
./binaries/*
|
||||||
|
|
||||||
|
sign_verify:
|
||||||
|
needs: [read_versions, build-installers]
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: windows-latest
|
||||||
|
platform: win-
|
||||||
|
- os: macos-latest
|
||||||
|
platform: mac-
|
||||||
|
# - os: ubuntu-latest
|
||||||
|
# platform: linux-
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- name: Download build artifacts
|
||||||
|
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.platform }}binaries
|
||||||
|
|
||||||
|
- name: Display structure of downloaded files
|
||||||
|
run: ls -R
|
||||||
|
|
||||||
|
- name: Install Cosign
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
|
||||||
|
|
||||||
|
- name: Generate key pair
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: cosign generate-key-pair
|
||||||
|
|
||||||
|
- name: Sign and generate attestations
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
run: |
|
||||||
|
cosign sign-blob \
|
||||||
|
--key ./cosign.key \
|
||||||
|
--yes \
|
||||||
|
--output-signature ./Stirling-PDF-win-installer.exe.sig \
|
||||||
|
./Stirling-PDF-win-installer.exe
|
||||||
|
|
||||||
|
cosign attest-blob \
|
||||||
|
--predicate - \
|
||||||
|
--key ./cosign.key \
|
||||||
|
--yes \
|
||||||
|
--output-attestation ./Stirling-PDF-win-installer.exe.intoto.jsonl \
|
||||||
|
./Stirling-PDF-win-installer.exe
|
||||||
|
|
||||||
|
cosign verify-blob \
|
||||||
|
--key ./cosign.pub \
|
||||||
|
--signature ./Stirling-PDF-win-installer.exe.sig \
|
||||||
|
./Stirling-PDF-win-installer.exe
|
||||||
|
|
||||||
|
- name: Display structure of downloaded files
|
||||||
|
run: ls -R
|
||||||
|
|
||||||
|
- name: Upload signed artifacts
|
||||||
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
|
with:
|
||||||
|
retention-days: 1
|
||||||
|
if-no-files-found: error
|
||||||
|
name: ${{ matrix.platform }}signed
|
||||||
|
path: |
|
||||||
|
./Stirling-PDF-${{ matrix.platform }}installer.*
|
||||||
|
./Stirling-PDF-${{ matrix.platform }}x86_64-installer.*
|
||||||
|
!cosign.*
|
||||||
|
|
||||||
create-release:
|
create-release:
|
||||||
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.test_mode != 'true') || github.event_name == 'release' || github.ref == 'refs/heads/V2-master'
|
if: github.event_name != 'workflow_dispatch' || github.event.inputs.test_mode != 'true'
|
||||||
needs: [determine-matrix, build, build-jars]
|
needs: [read_versions, sign_verify, sign_verify-portable]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Download all Tauri artifacts
|
- name: Download signed artifacts
|
||||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
|
||||||
with:
|
|
||||||
pattern: Stirling-PDF-*
|
|
||||||
path: ./artifacts/tauri
|
|
||||||
|
|
||||||
- name: Download JAR artifact (default)
|
|
||||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
|
||||||
with:
|
|
||||||
name: jar
|
|
||||||
path: ./artifacts/jars
|
|
||||||
|
|
||||||
- name: Download JAR artifact (with login)
|
|
||||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
|
||||||
with:
|
|
||||||
name: jar-with-login
|
|
||||||
path: ./artifacts/jars
|
|
||||||
|
|
||||||
- name: Download JAR artifact (server only)
|
|
||||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
|
||||||
with:
|
|
||||||
name: jar-server
|
|
||||||
path: ./artifacts/jars
|
|
||||||
|
|
||||||
- name: Display structure of downloaded files
|
- name: Display structure of downloaded files
|
||||||
run: ls -R ./artifacts
|
run: ls -R
|
||||||
|
- name: Upload binaries, attestations and signatures to Release and create GitHub Release
|
||||||
- name: Upload binaries to Release
|
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
|
||||||
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
|
|
||||||
with:
|
with:
|
||||||
tag_name: v${{ needs.determine-matrix.outputs.version }}
|
tag_name: v${{ needs.read_versions.outputs.version }}
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
files: |
|
files: |
|
||||||
./artifacts/**/*.jar
|
./*signed/*
|
||||||
./artifacts/**/*.msi
|
|
||||||
./artifacts/**/*.dmg
|
|
||||||
./artifacts/**/*.deb
|
|
||||||
./artifacts/**/*.AppImage
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
|
|||||||
@@ -12,21 +12,17 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
pre-commit:
|
pre-commit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
# Prevents sdist builds → no tar extraction
|
|
||||||
PIP_ONLY_BINARY: ":all:"
|
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@@ -38,36 +34,27 @@ jobs:
|
|||||||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
|
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
||||||
with:
|
with:
|
||||||
python-version: 3.12
|
python-version: 3.12
|
||||||
cache: "pip" # caching pip dependencies
|
cache: 'pip' # caching pip dependencies
|
||||||
cache-dependency-path: ./.github/scripts/requirements_pre_commit.txt
|
cache-dependency-path: ./.github/scripts/requirements_pre_commit.txt
|
||||||
|
|
||||||
- name: Run Pre-Commit Hooks
|
- name: Run Pre-Commit Hooks
|
||||||
run: |
|
run: |
|
||||||
pip install --require-hashes --only-binary=:all: -r ./.github/scripts/requirements_pre_commit.txt
|
pip install --require-hashes -r ./.github/scripts/requirements_pre_commit.txt
|
||||||
|
|
||||||
- run: pre-commit run --all-files -c .pre-commit-config.yaml
|
- run: pre-commit run --all-files -c .pre-commit-config.yaml
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: 21
|
java-version: 17
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
|
||||||
gradle-version: 8.14
|
|
||||||
|
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build
|
run: ./gradlew clean build
|
||||||
env:
|
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
|
|
||||||
- name: git add
|
- name: git add
|
||||||
run: |
|
run: |
|
||||||
@@ -76,7 +63,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
if: env.CHANGES_DETECTED == 'true'
|
if: env.CHANGES_DETECTED == 'true'
|
||||||
uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v8.0.0
|
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.setup-bot.outputs.token }}
|
token: ${{ steps.setup-bot.outputs.token }}
|
||||||
commit-message: ":file_folder: pre-commit"
|
commit-message: ":file_folder: pre-commit"
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- main
|
- main
|
||||||
- V2-master
|
|
||||||
- testMain
|
|
||||||
|
|
||||||
# cancel in-progress jobs if a new job is triggered
|
# cancel in-progress jobs if a new job is triggered
|
||||||
# This is useful to avoid running multiple builds for the same branch if a new commit is pushed
|
# This is useful to avoid running multiple builds for the same branch if a new commit is pushed
|
||||||
@@ -26,77 +24,72 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
push:
|
push:
|
||||||
if: ${{ vars.CI_PROFILE != 'lite' }}
|
runs-on: ubuntu-latest
|
||||||
runs-on: ubuntu-24.04-8core
|
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
packages: write
|
||||||
id-token: write
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
java-version: "17"
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
|
||||||
- name: Setup Gradle
|
- uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
with:
|
||||||
gradle-version: 8.14
|
gradle-version: 8.14
|
||||||
|
|
||||||
|
- name: Run Gradle Command
|
||||||
|
run: ./gradlew clean build
|
||||||
|
env:
|
||||||
|
DISABLE_ADDITIONAL_FEATURES: true
|
||||||
|
STIRLING_PDF_DESKTOP_UI: false
|
||||||
|
|
||||||
|
- name: Install cosign
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
|
||||||
|
with:
|
||||||
|
cosign-release: "v2.4.1"
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
||||||
|
|
||||||
- name: Get version number
|
- name: Get version number
|
||||||
id: versionNumber
|
id: versionNumber
|
||||||
run: echo "versionNumber=$(./gradlew printVersion --quiet | tail -1)" >> $GITHUB_OUTPUT
|
run: echo "versionNumber=$(./gradlew printVersion --quiet | tail -1)" >> $GITHUB_OUTPUT
|
||||||
env:
|
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
|
|
||||||
- name: Install cosign
|
|
||||||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master'
|
|
||||||
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
|
|
||||||
with:
|
|
||||||
cosign-release: "v2.4.1"
|
|
||||||
|
|
||||||
- name: Install cosign
|
|
||||||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master'
|
|
||||||
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
|
|
||||||
with:
|
|
||||||
cosign-release: "v2.4.1"
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_HUB_API }}
|
password: ${{ secrets.DOCKER_HUB_API }}
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ github.token }}
|
password: ${{ github.token }}
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
|
||||||
|
|
||||||
- name: Convert repository owner to lowercase
|
- name: Convert repository owner to lowercase
|
||||||
id: repoowner
|
id: repoowner
|
||||||
run: echo "lowercase=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" >> $GITHUB_OUTPUT
|
run: echo "lowercase=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Generate tags for latest
|
- name: Generate tags
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
|
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
||||||
|
if: github.ref != 'refs/heads/main'
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ secrets.DOCKER_HUB_USERNAME }}/s-pdf
|
${{ secrets.DOCKER_HUB_USERNAME }}/s-pdf
|
||||||
@@ -104,17 +97,17 @@ jobs:
|
|||||||
ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf
|
ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf
|
||||||
${{ secrets.DOCKER_HUB_ORG_USERNAME }}/stirling-pdf
|
${{ secrets.DOCKER_HUB_ORG_USERNAME }}/stirling-pdf
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=${{ steps.versionNumber.outputs.versionNumber }},enable=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master' }}
|
type=raw,value=${{ steps.versionNumber.outputs.versionNumber }},enable=${{ github.ref == 'refs/heads/master' }}
|
||||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master' }}
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
|
||||||
type=raw,value=alpha,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/testMain' }}
|
|
||||||
|
|
||||||
- name: Build and push Unified Dockerfile (latest variant)
|
- name: Build and push main Dockerfile
|
||||||
id: build-push-latest
|
id: build-push-regular
|
||||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||||
|
if: github.ref != 'refs/heads/main'
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/embedded/Dockerfile
|
file: ./Dockerfile
|
||||||
push: true
|
push: true
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
@@ -126,9 +119,9 @@ jobs:
|
|||||||
sbom: true
|
sbom: true
|
||||||
|
|
||||||
- name: Sign regular images
|
- name: Sign regular images
|
||||||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master'
|
if: github.ref == 'refs/heads/master'
|
||||||
env:
|
env:
|
||||||
DIGEST: ${{ steps.build-push-latest.outputs.digest }}
|
DIGEST: ${{ steps.build-push-regular.outputs.digest }}
|
||||||
TAGS: ${{ steps.meta.outputs.tags }}
|
TAGS: ${{ steps.meta.outputs.tags }}
|
||||||
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
|
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
|
||||||
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
|
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
|
||||||
@@ -139,10 +132,10 @@ jobs:
|
|||||||
"${tag}@${DIGEST}"
|
"${tag}@${DIGEST}"
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Generate tags for latest-fat
|
- name: Generate tags ultra-lite
|
||||||
id: meta-fat
|
id: meta2
|
||||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
|
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
||||||
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/testMain'
|
if: github.ref != 'refs/heads/main'
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ secrets.DOCKER_HUB_USERNAME }}/s-pdf
|
${{ secrets.DOCKER_HUB_USERNAME }}/s-pdf
|
||||||
@@ -150,76 +143,62 @@ jobs:
|
|||||||
ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf
|
ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf
|
||||||
${{ secrets.DOCKER_HUB_ORG_USERNAME }}/stirling-pdf
|
${{ secrets.DOCKER_HUB_ORG_USERNAME }}/stirling-pdf
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=${{ steps.versionNumber.outputs.versionNumber }}-fat,enable=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master' }}
|
type=raw,value=${{ steps.versionNumber.outputs.versionNumber }}-ultra-lite,enable=${{ github.ref == 'refs/heads/master' }}
|
||||||
type=raw,value=latest-fat,enable=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master' }}
|
type=raw,value=latest-ultra-lite,enable=${{ github.ref == 'refs/heads/master' }}
|
||||||
|
|
||||||
- name: Build and push Unified Dockerfile (fat variant)
|
- name: Build and push Dockerfile-ultra-lite
|
||||||
id: build-push-fat
|
id: build-push-lite
|
||||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||||
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/testMain'
|
if: github.ref != 'refs/heads/main'
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/embedded/Dockerfile.fat
|
file: ./Dockerfile.ultra-lite
|
||||||
push: true
|
push: true
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
tags: ${{ steps.meta-fat.outputs.tags }}
|
tags: ${{ steps.meta2.outputs.tags }}
|
||||||
labels: ${{ steps.meta-fat.outputs.labels }}
|
labels: ${{ steps.meta2.outputs.labels }}
|
||||||
|
build-args: VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
|
||||||
|
platforms: linux/amd64,linux/arm64/v8
|
||||||
|
provenance: true
|
||||||
|
sbom: true
|
||||||
|
|
||||||
|
- name: Generate tags fat
|
||||||
|
id: meta3
|
||||||
|
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ secrets.DOCKER_HUB_USERNAME }}/s-pdf
|
||||||
|
ghcr.io/${{ steps.repoowner.outputs.lowercase }}/s-pdf
|
||||||
|
ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf
|
||||||
|
${{ secrets.DOCKER_HUB_ORG_USERNAME }}/stirling-pdf
|
||||||
|
tags: |
|
||||||
|
type=raw,value=${{ steps.versionNumber.outputs.versionNumber }}-fat,enable=${{ github.ref == 'refs/heads/master' }}
|
||||||
|
type=raw,value=latest-fat,enable=${{ github.ref == 'refs/heads/master' }}
|
||||||
|
type=raw,value=alpha,enable=${{ github.ref == 'refs/heads/main' }}
|
||||||
|
|
||||||
|
- name: Build and push main Dockerfile fat
|
||||||
|
id: build-push-fat
|
||||||
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||||
|
with:
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile.fat
|
||||||
|
push: true
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
tags: ${{ steps.meta3.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta3.outputs.labels }}
|
||||||
build-args: VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
|
build-args: VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
|
||||||
platforms: linux/amd64,linux/arm64/v8
|
platforms: linux/amd64,linux/arm64/v8
|
||||||
provenance: true
|
provenance: true
|
||||||
sbom: true
|
sbom: true
|
||||||
|
|
||||||
- name: Sign fat images
|
- name: Sign fat images
|
||||||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master'
|
if: github.ref == 'refs/heads/master'
|
||||||
env:
|
env:
|
||||||
DIGEST: ${{ steps.build-push-fat.outputs.digest }}
|
DIGEST: ${{ steps.build-push-fat.outputs.digest }}
|
||||||
TAGS: ${{ steps.meta-fat.outputs.tags }}
|
TAGS: ${{ steps.meta3.outputs.tags }}
|
||||||
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
|
|
||||||
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
|
|
||||||
run: |
|
|
||||||
echo "$TAGS" | tr ',' '\n' | while read -r tag; do
|
|
||||||
cosign sign --key env://COSIGN_PRIVATE_KEY --yes "${tag}@${DIGEST}"
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Generate tags for ultra-lite
|
|
||||||
id: meta-lite
|
|
||||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
|
|
||||||
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/testMain'
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ secrets.DOCKER_HUB_USERNAME }}/s-pdf
|
|
||||||
ghcr.io/${{ steps.repoowner.outputs.lowercase }}/s-pdf
|
|
||||||
ghcr.io/${{ steps.repoowner.outputs.lowercase }}/stirling-pdf
|
|
||||||
${{ secrets.DOCKER_HUB_ORG_USERNAME }}/stirling-pdf
|
|
||||||
tags: |
|
|
||||||
type=raw,value=${{ steps.versionNumber.outputs.versionNumber }}-ultra-lite,enable=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master' }}
|
|
||||||
type=raw,value=latest-ultra-lite,enable=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master' }}
|
|
||||||
|
|
||||||
- name: Build and push Unified Dockerfile (ultra-lite variant)
|
|
||||||
id: build-push-lite
|
|
||||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
|
||||||
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/testMain'
|
|
||||||
with:
|
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
context: .
|
|
||||||
file: ./docker/embedded/Dockerfile.ultra-lite
|
|
||||||
push: true
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
tags: ${{ steps.meta-lite.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta-lite.outputs.labels }}
|
|
||||||
build-args: VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
|
|
||||||
platforms: linux/amd64,linux/arm64/v8
|
|
||||||
provenance: true
|
|
||||||
sbom: true
|
|
||||||
|
|
||||||
- name: Sign ultra-lite images
|
|
||||||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/V2-master'
|
|
||||||
env:
|
|
||||||
DIGEST: ${{ steps.build-push-lite.outputs.digest }}
|
|
||||||
TAGS: ${{ steps.meta-lite.outputs.tags }}
|
|
||||||
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
|
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
|
||||||
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
|
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
name: Release Artifacts
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
disable_security: [true, false]
|
||||||
|
include:
|
||||||
|
- disable_security: false
|
||||||
|
file_suffix: "-with-login"
|
||||||
|
- disable_security: true
|
||||||
|
file_suffix: ""
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.versionNumber.outputs.versionNumber }}
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
|
with:
|
||||||
|
java-version: "17"
|
||||||
|
distribution: "temurin"
|
||||||
|
|
||||||
|
- uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
|
||||||
|
with:
|
||||||
|
gradle-version: 8.14
|
||||||
|
|
||||||
|
- name: Generate jar (Disable Security=${{ matrix.disable_security }})
|
||||||
|
run: ./gradlew clean createExe
|
||||||
|
env:
|
||||||
|
DISABLE_ADDITIONAL_FEATURES: ${{ matrix.disable_security }}
|
||||||
|
STIRLING_PDF_DESKTOP_UI: false
|
||||||
|
|
||||||
|
- name: Get version number
|
||||||
|
id: versionNumber
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep "^version =" build.gradle | awk -F'"' '{print $2}')
|
||||||
|
echo "versionNumber=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Rename binaries
|
||||||
|
run: |
|
||||||
|
mv ./build/launch4j/Stirling-PDF.exe ./build/launch4j/Stirling-PDF-Server${{ matrix.file_suffix }}.exe
|
||||||
|
mv ./build/libs/Stirling-PDF-${{ steps.versionNumber.outputs.versionNumber }}.jar ./build/libs/Stirling-PDF${{ matrix.file_suffix }}.jar
|
||||||
|
|
||||||
|
- name: Debug build artifacts
|
||||||
|
run: |
|
||||||
|
echo "Current Directory: $(pwd)"
|
||||||
|
ls -R ./build/libs
|
||||||
|
ls -R ./build/launch4j
|
||||||
|
|
||||||
|
- name: Upload build artifacts
|
||||||
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
|
with:
|
||||||
|
name: binaries${{ matrix.file_suffix }}
|
||||||
|
path: |
|
||||||
|
./build/launch4j/Stirling-PDF-Server${{ matrix.file_suffix }}.*
|
||||||
|
./build/libs/Stirling-PDF${{ matrix.file_suffix }}.*
|
||||||
|
|
||||||
|
sign_verify:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
disable_security: [true, false]
|
||||||
|
include:
|
||||||
|
- disable_security: false
|
||||||
|
file_suffix: "-with-login"
|
||||||
|
- disable_security: true
|
||||||
|
file_suffix: ""
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- name: Download build artifacts
|
||||||
|
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
|
||||||
|
with:
|
||||||
|
name: binaries${{ matrix.file_suffix }}
|
||||||
|
- name: Display structure of downloaded files
|
||||||
|
run: ls -R
|
||||||
|
|
||||||
|
- name: Install Cosign
|
||||||
|
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
|
||||||
|
|
||||||
|
- name: Generate key pair
|
||||||
|
run: cosign generate-key-pair
|
||||||
|
|
||||||
|
- name: Sign and generate attestations
|
||||||
|
run: |
|
||||||
|
cosign sign-blob \
|
||||||
|
--key ./cosign.key \
|
||||||
|
--yes \
|
||||||
|
--output-signature ./libs/Stirling-PDF${{ matrix.file_suffix }}.jar.sig \
|
||||||
|
./libs/Stirling-PDF${{ matrix.file_suffix }}.jar
|
||||||
|
|
||||||
|
cosign attest-blob \
|
||||||
|
--predicate - \
|
||||||
|
--key ./cosign.key \
|
||||||
|
--yes \
|
||||||
|
--output-attestation ./libs/Stirling-PDF${{ matrix.file_suffix }}.jar.intoto.jsonl \
|
||||||
|
./libs/Stirling-PDF${{ matrix.file_suffix }}.jar
|
||||||
|
|
||||||
|
cosign verify-blob \
|
||||||
|
--key ./cosign.pub \
|
||||||
|
--signature ./libs/Stirling-PDF${{ matrix.file_suffix }}.jar.sig \
|
||||||
|
./libs/Stirling-PDF${{ matrix.file_suffix }}.jar
|
||||||
|
|
||||||
|
cosign sign-blob \
|
||||||
|
--key ./cosign.key \
|
||||||
|
--yes \
|
||||||
|
--output-signature ./launch4j/Stirling-PDF-Server${{ matrix.file_suffix }}.exe.sig \
|
||||||
|
./launch4j/Stirling-PDF-Server${{ matrix.file_suffix }}.exe
|
||||||
|
|
||||||
|
cosign attest-blob \
|
||||||
|
--predicate - \
|
||||||
|
--key ./cosign.key \
|
||||||
|
--yes \
|
||||||
|
--output-attestation ./launch4j/Stirling-PDF-Server${{ matrix.file_suffix }}.exe.intoto.jsonl \
|
||||||
|
./launch4j/Stirling-PDF-Server${{ matrix.file_suffix }}.exe
|
||||||
|
|
||||||
|
cosign verify-blob \
|
||||||
|
--key ./cosign.pub \
|
||||||
|
--signature ./launch4j/Stirling-PDF-Server${{ matrix.file_suffix }}.exe.sig \
|
||||||
|
./launch4j/Stirling-PDF-Server${{ matrix.file_suffix }}.exe
|
||||||
|
|
||||||
|
- name: Upload signed artifacts
|
||||||
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
|
with:
|
||||||
|
name: signed${{ matrix.file_suffix }}
|
||||||
|
path: |
|
||||||
|
./libs/Stirling-PDF${{ matrix.file_suffix }}.*
|
||||||
|
./launch4j/Stirling-PDF-Server${{ matrix.file_suffix }}.*
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: [build, sign_verify]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
disable_security: [true, false]
|
||||||
|
include:
|
||||||
|
- disable_security: false
|
||||||
|
file_suffix: "-with-login"
|
||||||
|
- disable_security: true
|
||||||
|
file_suffix: ""
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- name: Download signed artifacts
|
||||||
|
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
|
||||||
|
with:
|
||||||
|
name: signed${{ matrix.file_suffix }}
|
||||||
|
|
||||||
|
- name: Upload binaries, attestations and signatures to Release and create GitHub Release
|
||||||
|
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
|
||||||
|
with:
|
||||||
|
tag_name: v${{ needs.build.outputs.version }}
|
||||||
|
generate_release_notes: true
|
||||||
|
files: |
|
||||||
|
./libs/Stirling-PDF*
|
||||||
|
./launch4j/Stirling-PDF-Server*
|
||||||
@@ -17,7 +17,6 @@ permissions: read-all
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
analysis:
|
analysis:
|
||||||
if: ${{ vars.CI_PROFILE != 'lite' }}
|
|
||||||
name: Scorecard analysis
|
name: Scorecard analysis
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
@@ -35,17 +34,17 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: "Run analysis"
|
- name: "Run analysis"
|
||||||
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
|
||||||
with:
|
with:
|
||||||
results_file: results.sarif
|
results_file: results.sarif
|
||||||
results_format: sarif
|
results_format: sarif
|
||||||
@@ -67,7 +66,7 @@ jobs:
|
|||||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||||
# format to the repository Actions tab.
|
# format to the repository Actions tab.
|
||||||
- name: "Upload artifact"
|
- name: "Upload artifact"
|
||||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: SARIF file
|
name: SARIF file
|
||||||
path: results.sarif
|
path: results.sarif
|
||||||
@@ -75,6 +74,6 @@ jobs:
|
|||||||
|
|
||||||
# Upload the results to GitHub's code scanning dashboard.
|
# Upload the results to GitHub's code scanning dashboard.
|
||||||
- name: "Upload to code-scanning"
|
- name: "Upload to code-scanning"
|
||||||
uses: github/codeql-action/upload-sarif@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v3.29.5
|
uses: github/codeql-action/upload-sarif@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.5
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
name: Run Sonarqube
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request_target:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# cancel in-progress jobs if a new job is triggered
|
||||||
|
# This is useful to avoid running multiple builds for the same branch if a new commit is pushed
|
||||||
|
# or a pull request is updated.
|
||||||
|
# It helps to save resources and time by ensuring that only the latest commit is built and tested
|
||||||
|
# This is particularly useful for long-running jobs that may take a while to complete.
|
||||||
|
# The `group` is set to a combination of the workflow name, event name, and branch name.
|
||||||
|
# This ensures that jobs are grouped by the workflow and branch, allowing for cancellation of
|
||||||
|
# in-progress jobs when a new commit is pushed to the same branch or a new pull request is opened.
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref_name || github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: read
|
||||||
|
actions: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sonarqube:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
|
||||||
|
|
||||||
|
- name: Build and analyze with Gradle
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
DISABLE_ADDITIONAL_FEATURES: false
|
||||||
|
STIRLING_PDF_DESKTOP_UI: true
|
||||||
|
run: |
|
||||||
|
./gradlew clean build sonar \
|
||||||
|
-Dsonar.projectKey=Stirling-Tools_Stirling-PDF \
|
||||||
|
-Dsonar.organization=stirling-tools \
|
||||||
|
-Dsonar.host.url=https://sonarcloud.io \
|
||||||
|
-Dsonar.login=${SONAR_TOKEN} \
|
||||||
|
-Dsonar.log.level=DEBUG \
|
||||||
|
--info
|
||||||
|
|
||||||
|
- name: Upload Problems Report on Failure
|
||||||
|
if: failure()
|
||||||
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
|
with:
|
||||||
|
name: gradle-problems-report
|
||||||
|
path: build/reports/problems/problems-report.html
|
||||||
|
retention-days: 7
|
||||||
|
|
||||||
|
- name: Upload Sonar Logs on Failure
|
||||||
|
if: failure()
|
||||||
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
|
with:
|
||||||
|
name: sonar-logs
|
||||||
|
path: |
|
||||||
|
.scannerwork/report-task.txt
|
||||||
|
build/sonar/
|
||||||
|
retention-days: 7
|
||||||
@@ -10,19 +10,18 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stale:
|
stale:
|
||||||
if: ${{ vars.CI_PROFILE != 'lite' }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
issues: write
|
issues: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: 30 days stale issues
|
- name: 30 days stale issues
|
||||||
uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
|
uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
days-before-stale: 30
|
days-before-stale: 30
|
||||||
|
|||||||
@@ -23,26 +23,22 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
push:
|
push:
|
||||||
if: ${{ vars.CI_PROFILE != 'lite' }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
java-version: "17"
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
|
|
||||||
- name: Setup Gradle
|
- uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
|
||||||
gradle-version: 8.14
|
|
||||||
|
|
||||||
- name: Generate Swagger documentation
|
- name: Generate Swagger documentation
|
||||||
run: ./gradlew :stirling-pdf:generateOpenApiDocs
|
run: ./gradlew :stirling-pdf:generateOpenApiDocs
|
||||||
@@ -50,19 +46,12 @@ jobs:
|
|||||||
- name: Upload Swagger Documentation to SwaggerHub
|
- name: Upload Swagger Documentation to SwaggerHub
|
||||||
run: ./gradlew swaggerhubUpload
|
run: ./gradlew swaggerhubUpload
|
||||||
env:
|
env:
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_API_KEY }}
|
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_API_KEY }}
|
||||||
SWAGGERHUB_USER: "Frooodle"
|
SWAGGERHUB_USER: "Frooodle"
|
||||||
|
|
||||||
- name: Get version number
|
- name: Get version number
|
||||||
id: versionNumber
|
id: versionNumber
|
||||||
run: echo "versionNumber=$(./gradlew printVersion --quiet | tail -1)" >> $GITHUB_OUTPUT
|
run: echo "versionNumber=$(./gradlew printVersion --quiet | tail -1)" >> $GITHUB_OUTPUT
|
||||||
env:
|
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
|
|
||||||
- name: Set API version as published and default on SwaggerHub
|
- name: Set API version as published and default on SwaggerHub
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
name: Sync Files
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- "build.gradle"
|
||||||
|
- "README.md"
|
||||||
|
- "app/core/src/main/resources/messages_*.properties"
|
||||||
|
- "app/core/src/main/resources/static/3rdPartyLicenses.json"
|
||||||
|
- "scripts/ignore_translation.toml"
|
||||||
|
|
||||||
|
# cancel in-progress jobs if a new job is triggered
|
||||||
|
# This is useful to avoid running multiple builds for the same branch if a new commit is pushed
|
||||||
|
# or a pull request is updated.
|
||||||
|
# It helps to save resources and time by ensuring that only the latest commit is built and tested
|
||||||
|
# This is particularly useful for long-running jobs that may take a while to complete.
|
||||||
|
# The `group` is set to a combination of the workflow name, event name, and branch name.
|
||||||
|
# This ensures that jobs are grouped by the workflow and branch, allowing for cancellation of
|
||||||
|
# in-progress jobs when a new commit is pushed to the same branch or a new pull request is opened.
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name || github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync-files:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Harden Runner
|
||||||
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
|
- name: Setup GitHub App Bot
|
||||||
|
id: setup-bot
|
||||||
|
uses: ./.github/actions/setup-bot
|
||||||
|
with:
|
||||||
|
app-id: ${{ secrets.GH_APP_ID }}
|
||||||
|
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
||||||
|
with:
|
||||||
|
python-version: "3.12"
|
||||||
|
cache: "pip" # caching pip dependencies
|
||||||
|
|
||||||
|
- name: Sync translation property files
|
||||||
|
run: |
|
||||||
|
python .github/scripts/check_language_properties.py --reference-file "app/core/src/main/resources/messages_en_GB.properties" --branch main
|
||||||
|
|
||||||
|
- name: Commit translation files
|
||||||
|
run: |
|
||||||
|
git add app/core/src/main/resources/messages_*.properties
|
||||||
|
git diff --staged --quiet || git commit -m ":memo: Sync translation files" || echo "No changes detected"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pip install --require-hashes -r ./.github/scripts/requirements_sync_readme.txt
|
||||||
|
|
||||||
|
- name: Sync README.md
|
||||||
|
run: |
|
||||||
|
python scripts/counter_translation.py
|
||||||
|
|
||||||
|
- name: Run git add
|
||||||
|
run: |
|
||||||
|
git add README.md scripts/ignore_translation.toml
|
||||||
|
git diff --staged --quiet || git commit -m ":memo: Sync README.md & scripts/ignore_translation.toml" || echo "No changes detected"
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
if: always()
|
||||||
|
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
|
||||||
|
with:
|
||||||
|
token: ${{ steps.setup-bot.outputs.token }}
|
||||||
|
commit-message: Update files
|
||||||
|
committer: ${{ steps.setup-bot.outputs.committer }}
|
||||||
|
author: ${{ steps.setup-bot.outputs.committer }}
|
||||||
|
signoff: true
|
||||||
|
branch: sync_readme
|
||||||
|
title: ":globe_with_meridians: Sync Translations + Update README Progress Table"
|
||||||
|
body: |
|
||||||
|
### Description of Changes
|
||||||
|
|
||||||
|
This Pull Request was automatically generated to synchronize updates to translation files and documentation. Below are the details of the changes made:
|
||||||
|
|
||||||
|
#### **1. Synchronization of Translation Files**
|
||||||
|
- Updated translation files (`messages_*.properties`) to reflect changes in the reference file `messages_en_GB.properties`.
|
||||||
|
- Ensured consistency and synchronization across all supported language files.
|
||||||
|
- Highlighted any missing or incomplete translations.
|
||||||
|
|
||||||
|
#### **2. Update README.md**
|
||||||
|
- Generated the translation progress table in `README.md`.
|
||||||
|
- Added a summary of the current translation status for all supported languages.
|
||||||
|
- Included up-to-date statistics on translation coverage.
|
||||||
|
|
||||||
|
#### **Why these changes are necessary**
|
||||||
|
- Keeps translation files aligned with the latest reference updates.
|
||||||
|
- Ensures the documentation reflects the current translation progress.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Auto-generated by [create-pull-request][1].
|
||||||
|
|
||||||
|
[1]: https://github.com/peter-evans/create-pull-request
|
||||||
|
draft: false
|
||||||
|
delete-branch: true
|
||||||
|
labels: github-actions
|
||||||
|
sign-commits: true
|
||||||
|
add-paths: |
|
||||||
|
README.md
|
||||||
|
app/core/src/main/resources/messages_*.properties
|
||||||
@@ -1,17 +1,15 @@
|
|||||||
name: Sync Files (TOML)
|
name: Sync Files V2
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- V2
|
||||||
|
- syncLangTest
|
||||||
paths:
|
paths:
|
||||||
- "build.gradle"
|
- "build.gradle"
|
||||||
- "app/common/build.gradle"
|
|
||||||
- "app/core/build.gradle"
|
|
||||||
- "app/proprietary/build.gradle"
|
|
||||||
- "README.md"
|
- "README.md"
|
||||||
- "frontend/public/locales/*/translation.toml"
|
- "frontend/public/locales/*/translation.json"
|
||||||
- "app/core/src/main/resources/static/3rdPartyLicenses.json"
|
- "app/core/src/main/resources/static/3rdPartyLicenses.json"
|
||||||
- "scripts/ignore_translation.toml"
|
- "scripts/ignore_translation.toml"
|
||||||
|
|
||||||
@@ -35,11 +33,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Setup GitHub App Bot
|
- name: Setup GitHub App Bot
|
||||||
id: setup-bot
|
id: setup-bot
|
||||||
@@ -49,26 +47,26 @@ jobs:
|
|||||||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
|
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
|
||||||
with:
|
with:
|
||||||
python-version: "3.12"
|
python-version: "3.12"
|
||||||
cache: "pip" # caching pip dependencies
|
cache: "pip" # caching pip dependencies
|
||||||
|
|
||||||
- name: Install Python dependencies
|
- name: Sync translation JSON files
|
||||||
run: pip install --require-hashes -r ./.github/scripts/requirements_sync_readme.txt
|
|
||||||
|
|
||||||
- name: Sync translation TOML files
|
|
||||||
run: |
|
run: |
|
||||||
python .github/scripts/check_language_toml.py --reference-file "frontend/public/locales/en-GB/translation.toml" --branch main
|
python .github/scripts/check_language_json.py --reference-file "frontend/public/locales/en-GB/translation.json" --branch V2
|
||||||
|
|
||||||
- name: Commit translation files
|
- name: Commit translation files
|
||||||
run: |
|
run: |
|
||||||
git add frontend/public/locales/*/translation.toml
|
git add frontend/public/locales/*/translation.json
|
||||||
git diff --staged --quiet || git commit -m ":memo: Sync translation files (TOML)" || echo "No changes detected"
|
git diff --staged --quiet || git commit -m ":memo: Sync translation files" || echo "No changes detected"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pip install --require-hashes -r ./.github/scripts/requirements_sync_readme.txt
|
||||||
|
|
||||||
- name: Sync README.md
|
- name: Sync README.md
|
||||||
run: |
|
run: |
|
||||||
python scripts/counter_translation_v3.py
|
python scripts/counter_translation_v2.py
|
||||||
|
|
||||||
- name: Run git add
|
- name: Run git add
|
||||||
run: |
|
run: |
|
||||||
@@ -77,29 +75,28 @@ jobs:
|
|||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
if: always()
|
if: always()
|
||||||
uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v8.0.0
|
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
|
||||||
with:
|
with:
|
||||||
token: ${{ steps.setup-bot.outputs.token }}
|
token: ${{ steps.setup-bot.outputs.token }}
|
||||||
commit-message: Update files
|
commit-message: Update files
|
||||||
committer: ${{ steps.setup-bot.outputs.committer }}
|
committer: ${{ steps.setup-bot.outputs.committer }}
|
||||||
author: ${{ steps.setup-bot.outputs.committer }}
|
author: ${{ steps.setup-bot.outputs.committer }}
|
||||||
signoff: true
|
signoff: true
|
||||||
branch: sync_readme_v3
|
branch: sync_readme_v2
|
||||||
base: main
|
base: V2
|
||||||
title: ":globe_with_meridians: Sync Translations + Update README Progress Table"
|
title: ":globe_with_meridians: [V2] Sync Translations + Update README Progress Table"
|
||||||
body: |
|
body: |
|
||||||
### Description of Changes
|
### Description of Changes
|
||||||
|
|
||||||
This Pull Request was automatically generated to synchronize updates to translation files and documentation. Below are the details of the changes made:
|
This Pull Request was automatically generated to synchronize updates to translation files and documentation for the **V2 branch**. Below are the details of the changes made:
|
||||||
|
|
||||||
#### **1. Synchronization of Translation Files**
|
#### **1. Synchronization of Translation Files**
|
||||||
- Updated translation files (`frontend/public/locales/*/translation.toml`) to reflect changes in the reference file `en-GB/translation.toml`.
|
- Updated translation files (`frontend/public/locales/*/translation.json`) to reflect changes in the reference file `en-GB/translation.json`.
|
||||||
- Ensured consistency and synchronization across all supported language files.
|
- Ensured consistency and synchronization across all supported language files.
|
||||||
- Highlighted any missing or incomplete translations.
|
- Highlighted any missing or incomplete translations.
|
||||||
- **Format**: TOML
|
|
||||||
|
|
||||||
#### **2. Update README.md**
|
#### **2. Update README.md**
|
||||||
- Generated the translation progress table in `README.md` using `counter_translation_v3.py`.
|
- Generated the translation progress table in `README.md`.
|
||||||
- Added a summary of the current translation status for all supported languages.
|
- Added a summary of the current translation status for all supported languages.
|
||||||
- Included up-to-date statistics on translation coverage.
|
- Included up-to-date statistics on translation coverage.
|
||||||
|
|
||||||
@@ -118,5 +115,4 @@ jobs:
|
|||||||
sign-commits: true
|
sign-commits: true
|
||||||
add-paths: |
|
add-paths: |
|
||||||
README.md
|
README.md
|
||||||
frontend/public/locales/*/translation.toml
|
frontend/public/locales/*/translation.json
|
||||||
scripts/ignore_translation.toml
|
|
||||||
@@ -1,653 +0,0 @@
|
|||||||
name: Build Tauri Applications
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
platform:
|
|
||||||
description: "Platform to build (windows, macos, linux, or all)"
|
|
||||||
required: true
|
|
||||||
default: "all"
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- all
|
|
||||||
- windows
|
|
||||||
- macos
|
|
||||||
- linux
|
|
||||||
pull_request:
|
|
||||||
branches: [main, V2-tauri-windows]
|
|
||||||
paths:
|
|
||||||
- "frontend/src-tauri/**"
|
|
||||||
- "frontend/src/desktop/**"
|
|
||||||
- "frontend/tsconfig.desktop.json"
|
|
||||||
- ".github/workflows/tauri-build.yml"
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
determine-matrix:
|
|
||||||
if: ${{ vars.CI_PROFILE != 'lite' }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
||||||
steps:
|
|
||||||
- name: Determine build matrix
|
|
||||||
id: set-matrix
|
|
||||||
run: |
|
|
||||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
||||||
case "${{ github.event.inputs.platform }}" in
|
|
||||||
"windows")
|
|
||||||
echo 'matrix={"include":[{"platform":"windows-latest","args":"--target x86_64-pc-windows-msvc","name":"windows-x86_64"}]}' >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
"macos")
|
|
||||||
echo 'matrix={"include":[{"platform":"macos-15","args":"--target aarch64-apple-darwin","name":"macos-aarch64"},{"platform":"macos-15-intel","args":"--target x86_64-apple-darwin","name":"macos-x86_64"}]}' >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
"linux")
|
|
||||||
echo 'matrix={"include":[{"platform":"ubuntu-22.04","args":"","name":"linux-x86_64"}]}' >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo 'matrix={"include":[{"platform":"windows-latest","args":"--target x86_64-pc-windows-msvc","name":"windows-x86_64"},{"platform":"macos-15","args":"--target aarch64-apple-darwin","name":"macos-aarch64"},{"platform":"macos-15-intel","args":"--target x86_64-apple-darwin","name":"macos-x86_64"},{"platform":"ubuntu-22.04","args":"","name":"linux-x86_64"}]}' >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
# For PR/push events, build all platforms
|
|
||||||
echo 'matrix={"include":[{"platform":"windows-latest","args":"--target x86_64-pc-windows-msvc","name":"windows-x86_64"},{"platform":"macos-15","args":"--target aarch64-apple-darwin","name":"macos-aarch64"},{"platform":"macos-15-intel","args":"--target x86_64-apple-darwin","name":"macos-x86_64"},{"platform":"ubuntu-22.04","args":"","name":"linux-x86_64"}]}' >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
build:
|
|
||||||
needs: determine-matrix
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix: ${{ fromJson(needs.determine-matrix.outputs.matrix) }}
|
|
||||||
runs-on: ${{ matrix.platform }}
|
|
||||||
env:
|
|
||||||
SM_API_KEY: ${{ secrets.SM_API_KEY }}
|
|
||||||
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
|
||||||
steps:
|
|
||||||
- name: Harden Runner
|
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
||||||
|
|
||||||
- name: Install dependencies (ubuntu only)
|
|
||||||
if: matrix.platform == 'ubuntu-22.04'
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libjavascriptcoregtk-4.0-dev libsoup2.4-dev libjavascriptcoregtk-4.1-dev libsoup-3.0-dev
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
cache: "npm"
|
|
||||||
cache-dependency-path: frontend/package-lock.json
|
|
||||||
|
|
||||||
- name: Setup Rust
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
targets: ${{ (matrix.platform == 'macos-15' || matrix.platform == 'macos-15-intel') && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
|
|
||||||
|
|
||||||
- name: Set up JDK 21
|
|
||||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
|
||||||
with:
|
|
||||||
java-version: "21"
|
|
||||||
distribution: "temurin"
|
|
||||||
|
|
||||||
- name: Setup Gradle
|
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
|
||||||
with:
|
|
||||||
gradle-version: 8.14
|
|
||||||
|
|
||||||
- name: Build Java backend with JLink
|
|
||||||
working-directory: ./
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
chmod +x ./gradlew
|
|
||||||
echo "🔧 Building Stirling-PDF JAR..."
|
|
||||||
# STIRLING_PDF_DESKTOP_UI=false ./gradlew bootJar --no-daemon
|
|
||||||
./gradlew build -x spotlessApply -x spotlessCheck -x test -x sonarqube
|
|
||||||
|
|
||||||
# Find the built JAR
|
|
||||||
STIRLING_JAR=$(ls app/core/build/libs/stirling-pdf-*.jar | head -n 1)
|
|
||||||
echo "✅ Built JAR: $STIRLING_JAR"
|
|
||||||
|
|
||||||
# Create Tauri directories
|
|
||||||
mkdir -p ./frontend/src-tauri/libs
|
|
||||||
mkdir -p ./frontend/src-tauri/runtime
|
|
||||||
|
|
||||||
# Copy JAR to Tauri libs
|
|
||||||
cp "$STIRLING_JAR" ./frontend/src-tauri/libs/
|
|
||||||
echo "✅ JAR copied to Tauri libs"
|
|
||||||
|
|
||||||
# Analyze JAR dependencies for jlink modules
|
|
||||||
echo "🔍 Analyzing JAR dependencies..."
|
|
||||||
if command -v jdeps &> /dev/null; then
|
|
||||||
DETECTED_MODULES=$(jdeps --print-module-deps --ignore-missing-deps "$STIRLING_JAR" 2>/dev/null || echo "")
|
|
||||||
if [ -n "$DETECTED_MODULES" ]; then
|
|
||||||
echo "📋 jdeps detected modules: $DETECTED_MODULES"
|
|
||||||
MODULES="$DETECTED_MODULES,java.compiler,java.instrument,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.security.jgss,java.security.sasl,java.sql,java.transaction.xa,java.xml.crypto,jdk.crypto.ec,jdk.crypto.cryptoki,jdk.unsupported"
|
|
||||||
else
|
|
||||||
echo "⚠️ jdeps analysis failed, using predefined modules"
|
|
||||||
MODULES="java.base,java.compiler,java.desktop,java.instrument,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.security.jgss,java.security.sasl,java.sql,java.transaction.xa,java.xml,java.xml.crypto,jdk.crypto.ec,jdk.crypto.cryptoki,jdk.unsupported"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "⚠️ jdeps not available, using predefined modules"
|
|
||||||
MODULES="java.base,java.compiler,java.desktop,java.instrument,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.security.jgss,java.security.sasl,java.sql,java.transaction.xa,java.xml,java.xml.crypto,jdk.crypto.ec,jdk.crypto.cryptoki,jdk.unsupported"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create custom JRE with jlink (always rebuild)
|
|
||||||
echo "🔧 Creating custom JRE with jlink..."
|
|
||||||
echo "📋 Using modules: $MODULES"
|
|
||||||
|
|
||||||
# Remove any existing JRE
|
|
||||||
rm -rf ./frontend/src-tauri/runtime/jre
|
|
||||||
|
|
||||||
# Create the custom JRE
|
|
||||||
jlink \
|
|
||||||
--add-modules "$MODULES" \
|
|
||||||
--strip-debug \
|
|
||||||
--compress=2 \
|
|
||||||
--no-header-files \
|
|
||||||
--no-man-pages \
|
|
||||||
--output ./frontend/src-tauri/runtime/jre
|
|
||||||
|
|
||||||
if [ ! -d "./frontend/src-tauri/runtime/jre" ]; then
|
|
||||||
echo "❌ Failed to create JLink runtime"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Test the bundled runtime
|
|
||||||
if [ -f "./frontend/src-tauri/runtime/jre/bin/java" ]; then
|
|
||||||
RUNTIME_VERSION=$(./frontend/src-tauri/runtime/jre/bin/java --version 2>&1 | head -n 1)
|
|
||||||
echo "✅ Custom JRE created successfully: $RUNTIME_VERSION"
|
|
||||||
else
|
|
||||||
echo "❌ Custom JRE executable not found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Calculate runtime size
|
|
||||||
RUNTIME_SIZE=$(du -sh ./frontend/src-tauri/runtime/jre | cut -f1)
|
|
||||||
echo "📊 Custom JRE size: $RUNTIME_SIZE"
|
|
||||||
env:
|
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
DISABLE_ADDITIONAL_FEATURES: true
|
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
|
||||||
working-directory: ./frontend
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
# DigiCert KeyLocker Setup (Cloud HSM)
|
|
||||||
- name: Setup DigiCert KeyLocker
|
|
||||||
id: digicert-setup
|
|
||||||
if: ${{ matrix.platform == 'windows-latest' && env.SM_API_KEY != '' && github.ref == 'refs/heads/main' }}
|
|
||||||
uses: digicert/ssm-code-signing@v1.1.0
|
|
||||||
env:
|
|
||||||
SM_API_KEY: ${{ secrets.SM_API_KEY }}
|
|
||||||
SM_CLIENT_CERT_FILE_B64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}
|
|
||||||
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
|
|
||||||
SM_KEYPAIR_ALIAS: ${{ secrets.SM_KEYPAIR_ALIAS }}
|
|
||||||
SM_HOST: ${{ secrets.SM_HOST }}
|
|
||||||
|
|
||||||
- name: Setup DigiCert KeyLocker Certificate
|
|
||||||
if: ${{ matrix.platform == 'windows-latest' && env.SM_API_KEY != '' && github.ref == 'refs/heads/main' }}
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
Write-Host "Setting up DigiCert KeyLocker environment..."
|
|
||||||
|
|
||||||
# Decode client certificate
|
|
||||||
$certBytes = [Convert]::FromBase64String("${{ secrets.SM_CLIENT_CERT_FILE_B64 }}")
|
|
||||||
$certPath = "D:\Certificate_pkcs12.p12"
|
|
||||||
[IO.File]::WriteAllBytes($certPath, $certBytes)
|
|
||||||
|
|
||||||
# Set environment variables
|
|
||||||
echo "SM_CLIENT_CERT_FILE=D:\Certificate_pkcs12.p12" >> $env:GITHUB_ENV
|
|
||||||
echo "SM_HOST=${{ secrets.SM_HOST }}" >> $env:GITHUB_ENV
|
|
||||||
echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> $env:GITHUB_ENV
|
|
||||||
echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> $env:GITHUB_ENV
|
|
||||||
echo "SM_KEYPAIR_ALIAS=${{ secrets.SM_KEYPAIR_ALIAS }}" >> $env:GITHUB_ENV
|
|
||||||
|
|
||||||
# Get PKCS11 config path from DigiCert action
|
|
||||||
$pkcs11Config = $env:PKCS11_CONFIG
|
|
||||||
if ($pkcs11Config) {
|
|
||||||
Write-Host "Found PKCS11_CONFIG: $pkcs11Config"
|
|
||||||
echo "PKCS11_CONFIG=$pkcs11Config" >> $env:GITHUB_ENV
|
|
||||||
} else {
|
|
||||||
Write-Host "PKCS11_CONFIG not set by DigiCert action, using default path"
|
|
||||||
$defaultPath = "C:\Users\RUNNER~1\AppData\Local\Temp\smtools-windows-x64\pkcs11properties.cfg"
|
|
||||||
if (Test-Path $defaultPath) {
|
|
||||||
Write-Host "Found config at default path: $defaultPath"
|
|
||||||
echo "PKCS11_CONFIG=$defaultPath" >> $env:GITHUB_ENV
|
|
||||||
} else {
|
|
||||||
Write-Host "Warning: Could not find PKCS11 config file"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Traditional PFX Certificate Import (fallback if KeyLocker not configured)
|
|
||||||
- name: Import Windows Code Signing Certificate
|
|
||||||
if: ${{ matrix.platform == 'windows-latest' && env.SM_API_KEY == '' && github.ref == 'refs/heads/main' }}
|
|
||||||
env:
|
|
||||||
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
|
||||||
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
if ($env:WINDOWS_CERTIFICATE) {
|
|
||||||
Write-Host "Importing Windows Code Signing Certificate..."
|
|
||||||
|
|
||||||
# Decode base64 certificate and save to file
|
|
||||||
$certBytes = [Convert]::FromBase64String($env:WINDOWS_CERTIFICATE)
|
|
||||||
$certPath = Join-Path $env:RUNNER_TEMP "certificate.pfx"
|
|
||||||
[IO.File]::WriteAllBytes($certPath, $certBytes)
|
|
||||||
|
|
||||||
# Import certificate to CurrentUser\My store
|
|
||||||
$cert = Import-PfxCertificate -FilePath $certPath -CertStoreLocation Cert:\CurrentUser\My -Password (ConvertTo-SecureString -String $env:WINDOWS_CERTIFICATE_PASSWORD -AsPlainText -Force)
|
|
||||||
|
|
||||||
# Extract and set thumbprint as environment variable
|
|
||||||
$thumbprint = $cert.Thumbprint
|
|
||||||
Write-Host "Certificate imported with thumbprint: $thumbprint"
|
|
||||||
echo "WINDOWS_CERTIFICATE_THUMBPRINT=$thumbprint" >> $env:GITHUB_ENV
|
|
||||||
|
|
||||||
# Clean up certificate file
|
|
||||||
Remove-Item $certPath
|
|
||||||
|
|
||||||
Write-Host "Windows certificate import completed."
|
|
||||||
} else {
|
|
||||||
Write-Host "⚠️ WINDOWS_CERTIFICATE secret not set - building unsigned binary"
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Import Apple Developer Certificate
|
|
||||||
if: matrix.platform == 'macos-15' || matrix.platform == 'macos-15-intel'
|
|
||||||
env:
|
|
||||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
|
||||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
|
||||||
run: |
|
|
||||||
echo "Importing Apple Developer Certificate..."
|
|
||||||
echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
|
|
||||||
# Create temporary keychain
|
|
||||||
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
|
|
||||||
KEYCHAIN_PASSWORD=$(openssl rand -base64 32)
|
|
||||||
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
|
||||||
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
|
|
||||||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
|
||||||
# Import certificate
|
|
||||||
security import certificate.p12 -P "$APPLE_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
|
|
||||||
security list-keychain -d user -s $KEYCHAIN_PATH
|
|
||||||
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
|
||||||
# Clean up
|
|
||||||
rm certificate.p12
|
|
||||||
|
|
||||||
- name: Verify Certificate
|
|
||||||
if: matrix.platform == 'macos-15' || matrix.platform == 'macos-15-intel'
|
|
||||||
run: |
|
|
||||||
echo "Verifying Apple Developer Certificate..."
|
|
||||||
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
|
|
||||||
CERT_INFO=$(security find-identity -v -p codesigning $KEYCHAIN_PATH | grep "Developer ID Application")
|
|
||||||
echo "Certificate Info: $CERT_INFO"
|
|
||||||
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
|
|
||||||
echo "Certificate ID: $CERT_ID"
|
|
||||||
echo "APPLE_SIGNING_IDENTITY=$CERT_ID" >> $GITHUB_ENV
|
|
||||||
echo "Certificate imported successfully."
|
|
||||||
|
|
||||||
- name: Check DMG creation dependencies (macOS only)
|
|
||||||
if: matrix.platform == 'macos-15' || matrix.platform == 'macos-15-intel'
|
|
||||||
run: |
|
|
||||||
echo "🔍 Checking DMG creation dependencies on ${{ matrix.platform }}..."
|
|
||||||
echo "hdiutil version: $(hdiutil --version || echo 'NOT FOUND')"
|
|
||||||
echo "create-dmg availability: $(which create-dmg || echo 'NOT FOUND')"
|
|
||||||
echo "Available disk space: $(df -h /tmp | tail -1)"
|
|
||||||
echo "macOS version: $(sw_vers -productVersion)"
|
|
||||||
echo "Available tools:"
|
|
||||||
ls -la /usr/bin/hd* || echo "No hd* tools found"
|
|
||||||
|
|
||||||
- name: Build Tauri app
|
|
||||||
uses: tauri-apps/tauri-action@v0
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
|
||||||
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
|
||||||
APPLE_SIGNING_IDENTITY: ${{ env.APPLE_SIGNING_IDENTITY }}
|
|
||||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
|
||||||
APPLE_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
|
|
||||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
|
||||||
APPIMAGETOOL_SIGN_PASSPHRASE: ${{ secrets.APPIMAGETOOL_SIGN_PASSPHRASE }}
|
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
||||||
VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY: ${{ secrets.VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY }}
|
|
||||||
VITE_SAAS_SERVER_URL: ${{ secrets.VITE_SAAS_SERVER_URL }}
|
|
||||||
# Only enable Windows signing in Tauri when on main
|
|
||||||
SIGN: ${{ github.ref == 'refs/heads/main' && (env.SM_API_KEY == '' && env.WINDOWS_CERTIFICATE != '') && '1' || '0' }}
|
|
||||||
CI: true
|
|
||||||
with:
|
|
||||||
projectPath: ./frontend
|
|
||||||
tauriScript: npx tauri
|
|
||||||
args: ${{ matrix.args }}
|
|
||||||
|
|
||||||
# Sign with DigiCert KeyLocker (post-build)
|
|
||||||
- name: Sign Windows binaries with DigiCert KeyLocker
|
|
||||||
if: ${{ matrix.platform == 'windows-latest' && env.SM_API_KEY != '' && github.ref == 'refs/heads/main' }}
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
Write-Host "=== DigiCert KeyLocker Signing ==="
|
|
||||||
|
|
||||||
# Test smctl connectivity first
|
|
||||||
Write-Host "Testing smctl connection..."
|
|
||||||
$healthCheck = & smctl healthcheck 2>&1
|
|
||||||
if ($LASTEXITCODE -eq 0) {
|
|
||||||
Write-Host "[SUCCESS] Connected to DigiCert KeyLocker"
|
|
||||||
} else {
|
|
||||||
Write-Host "[ERROR] Failed to connect to DigiCert KeyLocker"
|
|
||||||
Write-Host $healthCheck
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
# Sync certificates to Windows certificate store
|
|
||||||
Write-Host "Syncing certificates to Windows certificate store..."
|
|
||||||
$syncOutput = & smctl windows certsync 2>&1
|
|
||||||
Write-Host "Cert sync result: $syncOutput"
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
# List available certificates and check if they have certificates attached
|
|
||||||
Write-Host "Checking for available certificates..."
|
|
||||||
$certList = & smctl keypair ls 2>&1
|
|
||||||
Write-Host "Keypair list output:"
|
|
||||||
Write-Host $certList
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
# Parse the output to check certificate status
|
|
||||||
$lines = $certList -split "`n"
|
|
||||||
$foundKeypair = $false
|
|
||||||
$hasCertificate = $false
|
|
||||||
|
|
||||||
foreach ($line in $lines) {
|
|
||||||
if ($line -match "${{ secrets.SM_KEYPAIR_ALIAS }}") {
|
|
||||||
$foundKeypair = $true
|
|
||||||
Write-Host "[SUCCESS] Found keypair in list"
|
|
||||||
|
|
||||||
# Check if this line has certificate info (not just empty spaces after alias)
|
|
||||||
$parts = $line -split "\s+"
|
|
||||||
if ($parts.Count -gt 2 -and $parts[1] -ne "" -and $parts[1] -ne "CERTIFICATE") {
|
|
||||||
$hasCertificate = $true
|
|
||||||
Write-Host "[SUCCESS] Certificate is associated with keypair"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not $foundKeypair) {
|
|
||||||
Write-Host "[ERROR] Keypair not found: ${{ secrets.SM_KEYPAIR_ALIAS }}"
|
|
||||||
Write-Host "Available keypairs are listed above"
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "Please verify:"
|
|
||||||
Write-Host " 1. Keypair alias is correct in GitHub secret"
|
|
||||||
Write-Host " 2. API key has access to this keypair"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not $hasCertificate) {
|
|
||||||
Write-Host "[ERROR] No certificate associated with keypair"
|
|
||||||
Write-Host "This usually means:"
|
|
||||||
Write-Host " 1. Certificate not yet synced to KeyLocker (run sync manually)"
|
|
||||||
Write-Host " 2. Certificate is pending approval"
|
|
||||||
Write-Host " 3. Certificate needs to be attached to the keypair"
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "Try running in DigiCert ONE portal:"
|
|
||||||
Write-Host " smctl keypair sync"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "[SUCCESS] Certificate check passed"
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
# Find only the files we need to sign (not build scripts)
|
|
||||||
$filesToSign = @()
|
|
||||||
|
|
||||||
# Main application executable
|
|
||||||
$mainExe = Get-ChildItem -Path "./frontend/src-tauri/target/x86_64-pc-windows-msvc/release" -Filter "stirling-pdf.exe" -File -ErrorAction SilentlyContinue
|
|
||||||
if ($mainExe) { $filesToSign += $mainExe }
|
|
||||||
|
|
||||||
# MSI installer
|
|
||||||
$msiFiles = Get-ChildItem -Path "./frontend/src-tauri/target" -Filter "*.msi" -Recurse -File
|
|
||||||
$filesToSign += $msiFiles
|
|
||||||
|
|
||||||
if ($filesToSign.Count -eq 0) {
|
|
||||||
Write-Host "[ERROR] No files found to sign"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Found $($filesToSign.Count) files to sign:"
|
|
||||||
foreach ($f in $filesToSign) { Write-Host " - $($f.Name)" }
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
$signedCount = 0
|
|
||||||
foreach ($file in $filesToSign) {
|
|
||||||
Write-Host "Signing: $($file.Name)"
|
|
||||||
|
|
||||||
# Get PKCS11 config file path (set by DigiCert action)
|
|
||||||
$pkcs11Config = $env:PKCS11_CONFIG
|
|
||||||
if (-not $pkcs11Config) {
|
|
||||||
Write-Host "[ERROR] PKCS11_CONFIG environment variable not set"
|
|
||||||
Write-Host "DigiCert KeyLocker action may not have run correctly"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Using PKCS11 config: $pkcs11Config"
|
|
||||||
|
|
||||||
# Try signing with certificate fingerprint first (if available)
|
|
||||||
$fingerprint = "${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}"
|
|
||||||
if ($fingerprint -and $fingerprint -ne "") {
|
|
||||||
Write-Host "Attempting to sign with certificate fingerprint..."
|
|
||||||
$output = & smctl sign --fingerprint "$fingerprint" --input "$($file.FullName)" --config-file "$pkcs11Config" --verbose 2>&1
|
|
||||||
$exitCode = $LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
Write-Host "No fingerprint provided, using keypair alias..."
|
|
||||||
# Use smctl to sign with keypair alias
|
|
||||||
$output = & smctl sign --keypair-alias "${{ secrets.SM_KEYPAIR_ALIAS }}" --input "$($file.FullName)" --config-file "$pkcs11Config" --verbose 2>&1
|
|
||||||
$exitCode = $LASTEXITCODE
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Exit code: $exitCode"
|
|
||||||
Write-Host "Output: $output"
|
|
||||||
|
|
||||||
# Check if output contains "FAILED" even with exit code 0
|
|
||||||
if ($output -match "FAILED" -or $output -match "error" -or $output -match "Error") {
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "[ERROR] Signing failed for $($file.Name)"
|
|
||||||
Write-Host "[ERROR] smctl returned success but output indicates failure"
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "Possible issues:"
|
|
||||||
Write-Host " 1. Certificate not fully synced to KeyLocker (wait a few minutes)"
|
|
||||||
Write-Host " 2. Incorrect keypair alias"
|
|
||||||
Write-Host " 3. API key lacks signing permissions"
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "Please verify in DigiCert ONE portal:"
|
|
||||||
Write-Host " - Certificate status is 'Issued' (not Pending)"
|
|
||||||
Write-Host " - Keypair status is 'Online'"
|
|
||||||
Write-Host " - 'Can sign' is set to 'Yes'"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($exitCode -ne 0) {
|
|
||||||
Write-Host "[ERROR] Failed to sign $($file.Name)"
|
|
||||||
Write-Host "Full error output:"
|
|
||||||
Write-Host $output
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
$signedCount++
|
|
||||||
Write-Host "[SUCCESS] Signed: $($file.Name)"
|
|
||||||
Write-Host ""
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "=== Summary ==="
|
|
||||||
Write-Host "[SUCCESS] Signed $signedCount/$($filesToSign.Count) files successfully"
|
|
||||||
|
|
||||||
- name: Verify notarization (macOS only)
|
|
||||||
if: matrix.platform == 'macos-15' || matrix.platform == 'macos-15-intel'
|
|
||||||
run: |
|
|
||||||
echo "🔍 Verifying notarization status..."
|
|
||||||
cd ./frontend/src-tauri/target
|
|
||||||
DMG_FILE=$(find . -name "*.dmg" | head -1)
|
|
||||||
if [ -n "$DMG_FILE" ]; then
|
|
||||||
echo "Found DMG: $DMG_FILE"
|
|
||||||
echo "Checking notarization ticket..."
|
|
||||||
spctl -a -vvv -t install "$DMG_FILE" || echo "⚠️ Notarization check failed or not yet complete"
|
|
||||||
stapler validate "$DMG_FILE" || echo "⚠️ No notarization ticket attached"
|
|
||||||
else
|
|
||||||
echo "⚠️ No DMG file found to verify"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Rename artifacts
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir -p ./dist
|
|
||||||
cd ./frontend/src-tauri/target
|
|
||||||
|
|
||||||
# Find and rename artifacts based on platform
|
|
||||||
if [ "${{ matrix.platform }}" = "windows-latest" ]; then
|
|
||||||
find . -name "*.exe" -exec cp {} "../../../dist/Stirling-PDF-${{ matrix.name }}.exe" \;
|
|
||||||
find . -name "*.msi" -exec cp {} "../../../dist/Stirling-PDF-${{ matrix.name }}.msi" \;
|
|
||||||
elif [ "${{ matrix.platform }}" = "macos-15" ] || [ "${{ matrix.platform }}" = "macos-15-intel" ]; then
|
|
||||||
find . -name "*.dmg" -exec cp {} "../../../dist/Stirling-PDF-${{ matrix.name }}.dmg" \;
|
|
||||||
else
|
|
||||||
find . -name "*.deb" -exec cp {} "../../../dist/Stirling-PDF-${{ matrix.name }}.deb" \;
|
|
||||||
find . -name "*.AppImage" -exec cp {} "../../../dist/Stirling-PDF-${{ matrix.name }}.AppImage" \;
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Verify Windows Code Signature
|
|
||||||
if: matrix.platform == 'windows-latest' && github.ref == 'refs/heads/main'
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
Write-Host "Verifying Windows code signatures..."
|
|
||||||
|
|
||||||
$exePath = "./dist/Stirling-PDF-${{ matrix.name }}.exe"
|
|
||||||
$msiPath = "./dist/Stirling-PDF-${{ matrix.name }}.msi"
|
|
||||||
|
|
||||||
$allSigned = $true
|
|
||||||
$usingKeyLocker = "${{ env.SM_API_KEY }}" -ne ""
|
|
||||||
$usingPfx = "${{ env.WINDOWS_CERTIFICATE }}" -ne ""
|
|
||||||
|
|
||||||
# Check EXE signature
|
|
||||||
if (Test-Path $exePath) {
|
|
||||||
$exeSig = Get-AuthenticodeSignature -FilePath $exePath
|
|
||||||
Write-Host "EXE Signature Status: $($exeSig.Status)"
|
|
||||||
Write-Host "EXE Signer: $($exeSig.SignerCertificate.Subject)"
|
|
||||||
Write-Host "EXE Timestamp: $($exeSig.TimeStamperCertificate.NotAfter)"
|
|
||||||
|
|
||||||
if ($exeSig.Status -ne "Valid") {
|
|
||||||
Write-Host "[WARNING] EXE is not properly signed (Status: $($exeSig.Status))"
|
|
||||||
if ($usingKeyLocker -or $usingPfx) {
|
|
||||||
Write-Host "[ERROR] Certificate was provided but signing failed"
|
|
||||||
$allSigned = $false
|
|
||||||
} else {
|
|
||||||
Write-Host "[INFO] Building unsigned binary (no certificate provided)"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Write-Host "[SUCCESS] EXE is properly signed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check MSI signature
|
|
||||||
if (Test-Path $msiPath) {
|
|
||||||
$msiSig = Get-AuthenticodeSignature -FilePath $msiPath
|
|
||||||
Write-Host "MSI Signature Status: $($msiSig.Status)"
|
|
||||||
Write-Host "MSI Signer: $($msiSig.SignerCertificate.Subject)"
|
|
||||||
Write-Host "MSI Timestamp: $($msiSig.TimeStamperCertificate.NotAfter)"
|
|
||||||
|
|
||||||
if ($msiSig.Status -ne "Valid") {
|
|
||||||
Write-Host "[WARNING] MSI is not properly signed (Status: $($msiSig.Status))"
|
|
||||||
if ($usingKeyLocker -or $usingPfx) {
|
|
||||||
Write-Host "[ERROR] Certificate was provided but signing failed"
|
|
||||||
$allSigned = $false
|
|
||||||
} else {
|
|
||||||
Write-Host "[INFO] Building unsigned binary (no certificate provided)"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Write-Host "[SUCCESS] MSI is properly signed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($usingKeyLocker -or $usingPfx) -and -not $allSigned) {
|
|
||||||
Write-Host "[ERROR] Code signing verification failed"
|
|
||||||
exit 1
|
|
||||||
} else {
|
|
||||||
Write-Host "[SUCCESS] Code signature verification completed"
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
||||||
with:
|
|
||||||
name: Stirling-PDF-${{ matrix.name }}
|
|
||||||
path: ./dist/*
|
|
||||||
retention-days: 7
|
|
||||||
|
|
||||||
- name: Verify build artifacts
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd ./frontend/src-tauri/target
|
|
||||||
|
|
||||||
# Check for expected artifacts based on platform
|
|
||||||
if [ "${{ matrix.platform }}" = "windows-latest" ]; then
|
|
||||||
echo "Checking for Windows artifacts..."
|
|
||||||
find . -name "*.exe" -o -name "*.msi" | head -5
|
|
||||||
if [ $(find . -name "*.exe" | wc -l) -eq 0 ]; then
|
|
||||||
echo "❌ No Windows executable found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif [ "${{ matrix.platform }}" = "macos-15" ] || [ "${{ matrix.platform }}" = "macos-15-intel" ]; then
|
|
||||||
echo "Checking for macOS artifacts..."
|
|
||||||
find . -name "*.dmg" | head -5
|
|
||||||
if [ $(find . -name "*.dmg" | wc -l) -eq 0 ]; then
|
|
||||||
echo "❌ No macOS artifacts found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Checking for Linux artifacts..."
|
|
||||||
find . -name "*.deb" -o -name "*.AppImage" | head -5
|
|
||||||
if [ $(find . -name "*.deb" -o -name "*.AppImage" | wc -l) -eq 0 ]; then
|
|
||||||
echo "❌ No Linux artifacts found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "✅ Build artifacts found for ${{ matrix.name }}"
|
|
||||||
|
|
||||||
- name: Test artifact sizes
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd ./frontend/src-tauri/target
|
|
||||||
echo "Artifact sizes for ${{ matrix.name }}:"
|
|
||||||
find . -name "*.exe" -o -name "*.dmg" -o -name "*.deb" -o -name "*.AppImage" -o -name "*.msi" | while read file; do
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
size=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file" 2>/dev/null || echo "unknown")
|
|
||||||
echo "$file: $size bytes"
|
|
||||||
# Check if file is suspiciously small (less than 1MB)
|
|
||||||
if [ "$size" != "unknown" ] && [ "$size" -lt 1048576 ]; then
|
|
||||||
echo "⚠️ Warning: $file is smaller than 1MB"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
report:
|
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: always()
|
|
||||||
steps:
|
|
||||||
- name: Report build results
|
|
||||||
run: |
|
|
||||||
if [ "${{ needs.build.result }}" = "success" ]; then
|
|
||||||
echo "✅ All Tauri builds completed successfully!"
|
|
||||||
echo "Artifacts are ready for distribution."
|
|
||||||
elif [ "${{ needs.build.result }}" = "skipped" ]; then
|
|
||||||
echo "⏭️ Tauri builds skipped (CI lite mode enabled)"
|
|
||||||
else
|
|
||||||
echo "❌ Some Tauri builds failed."
|
|
||||||
echo "Please check the logs and fix any issues."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@@ -21,38 +21,34 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
if: ${{ vars.CI_PROFILE != 'lite' }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||||
with:
|
with:
|
||||||
java-version: "21"
|
java-version: '17'
|
||||||
distribution: "temurin"
|
distribution: 'temurin'
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
|
||||||
with:
|
with:
|
||||||
gradle-version: 8.14
|
gradle-version: 8.14
|
||||||
|
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build
|
run: ./gradlew clean build
|
||||||
env:
|
env:
|
||||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
|
||||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
|
||||||
MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
|
|
||||||
DISABLE_ADDITIONAL_FEATURES: true
|
DISABLE_ADDITIONAL_FEATURES: true
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
||||||
|
|
||||||
- name: Get version number
|
- name: Get version number
|
||||||
id: versionNumber
|
id: versionNumber
|
||||||
@@ -61,7 +57,7 @@ jobs:
|
|||||||
echo "versionNumber=$VERSION" >> $GITHUB_OUTPUT
|
echo "versionNumber=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_HUB_API }}
|
password: ${{ secrets.DOCKER_HUB_API }}
|
||||||
@@ -70,7 +66,7 @@ jobs:
|
|||||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/embedded/Dockerfile
|
file: ./Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:test-${{ github.sha }}
|
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:test-${{ github.sha }}
|
||||||
build-args: VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
|
build-args: VERSION_TAG=${{ steps.versionNumber.outputs.versionNumber }}
|
||||||
@@ -79,7 +75,7 @@ jobs:
|
|||||||
- name: Set up SSH
|
- name: Set up SSH
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh/
|
mkdir -p ~/.ssh/
|
||||||
echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key
|
echo "${{ secrets.VPS_SSH_KEY }}" > ../private.key
|
||||||
sudo chmod 600 ../private.key
|
sudo chmod 600 ../private.key
|
||||||
|
|
||||||
- name: Deploy to VPS
|
- name: Deploy to VPS
|
||||||
@@ -110,9 +106,9 @@ jobs:
|
|||||||
restart: on-failure:5
|
restart: on-failure:5
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }}:/tmp/docker-compose.yml
|
scp -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null docker-compose.yml ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }}:/tmp/docker-compose.yml
|
||||||
|
|
||||||
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << EOF
|
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }} << EOF
|
||||||
mkdir -p /stirling/test-${{ github.sha }}/{data,config,logs}
|
mkdir -p /stirling/test-${{ github.sha }}/{data,config,logs}
|
||||||
mv /tmp/docker-compose.yml /stirling/test-${{ github.sha }}/docker-compose.yml
|
mv /tmp/docker-compose.yml /stirling/test-${{ github.sha }}/docker-compose.yml
|
||||||
cd /stirling/test-${{ github.sha }}
|
cd /stirling/test-${{ github.sha }}
|
||||||
@@ -120,51 +116,32 @@ jobs:
|
|||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
files-changed:
|
|
||||||
if: always()
|
|
||||||
name: detect what files changed
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 3
|
|
||||||
outputs:
|
|
||||||
frontend: ${{ steps.changes.outputs.frontend }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
||||||
|
|
||||||
- name: Check for file changes
|
|
||||||
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
|
|
||||||
id: changes
|
|
||||||
with:
|
|
||||||
filters: ".github/config/.files.yaml"
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
if: needs.files-changed.outputs.frontend == 'true'
|
needs: deploy
|
||||||
needs: [deploy, files-changed]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
with:
|
with:
|
||||||
cache: "npm"
|
cache: 'npm'
|
||||||
cache-dependency-path: frontend/package-lock.json
|
|
||||||
|
|
||||||
- name: Run TestDriver.ai
|
- name: Run TestDriver.ai
|
||||||
uses: testdriverai/action@f0d0f45fdd684db628baa843fe9313f3ca3a8aa8 #1.1.3
|
uses: testdriverai/action@f0d0f45fdd684db628baa843fe9313f3ca3a8aa8 #1.1.3
|
||||||
with:
|
with:
|
||||||
key: ${{secrets.TESTDRIVER_API_KEY}}
|
key: ${{secrets.TESTDRIVER_API_KEY}}
|
||||||
prerun: |
|
prerun: |
|
||||||
cd frontend
|
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
npm install dashcam-chrome --save
|
npm install dashcam-chrome --save
|
||||||
Start-Process "C:/Program Files/Google/Chrome/Application/chrome.exe" -ArgumentList "--start-maximized", "--load-extension=$(pwd)/node_modules/dashcam-chrome/build", "http://${{ secrets.NEW_VPS_HOST }}:1337"
|
Start-Process "C:/Program Files/Google/Chrome/Application/chrome.exe" -ArgumentList "--start-maximized", "--load-extension=$(pwd)/node_modules/dashcam-chrome/build", "http://${{ secrets.VPS_HOST }}:1337"
|
||||||
Start-Sleep -Seconds 20
|
Start-Sleep -Seconds 20
|
||||||
prompt: |
|
prompt: |
|
||||||
1. /run testing/testdriver/test.yml
|
1. /run testing/testdriver/test.yml
|
||||||
@@ -179,23 +156,21 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
- name: Harden Runner
|
||||||
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
|
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Set up SSH
|
- name: Set up SSH
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh/
|
mkdir -p ~/.ssh/
|
||||||
echo "${{ secrets.NEW_VPS_SSH_KEY }}" > ../private.key
|
echo "${{ secrets.VPS_SSH_KEY }}" > ../private.key
|
||||||
sudo chmod 600 ../private.key
|
sudo chmod 600 ../private.key
|
||||||
|
|
||||||
- name: Cleanup deployment
|
- name: Cleanup deployment
|
||||||
if: always()
|
|
||||||
run: |
|
run: |
|
||||||
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ secrets.NEW_VPS_USERNAME }}@${{ secrets.NEW_VPS_HOST }} << EOF
|
ssh -i ../private.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }} << EOF
|
||||||
cd /stirling/test-${{ github.sha }}
|
cd /stirling/test-${{ github.sha }}
|
||||||
docker-compose down
|
docker-compose down
|
||||||
cd /stirling
|
cd /stirling
|
||||||
rm -rf test-${{ github.sha }}
|
rm -rf test-${{ github.sha }}
|
||||||
EOF
|
EOF
|
||||||
continue-on-error: true # Ensure cleanup runs even if previous steps fail
|
|
||||||
|
|||||||
+3
-37
@@ -17,8 +17,8 @@ local.properties
|
|||||||
version.properties
|
version.properties
|
||||||
|
|
||||||
#### Stirling-PDF Files ###
|
#### Stirling-PDF Files ###
|
||||||
pipeline/
|
pipeline/watchedFolders/
|
||||||
!pipeline/.gitkeep
|
pipeline/finishedFolders/
|
||||||
customFiles/
|
customFiles/
|
||||||
configs/
|
configs/
|
||||||
watchedFolders/
|
watchedFolders/
|
||||||
@@ -31,25 +31,8 @@ exampleYmlFiles/stirling/
|
|||||||
/testing/file_snapshots
|
/testing/file_snapshots
|
||||||
SwaggerDoc.json
|
SwaggerDoc.json
|
||||||
|
|
||||||
# Frontend build artifacts copied to backend static resources
|
|
||||||
# These are generated by npm build and should not be committed
|
|
||||||
app/core/src/main/resources/static/assets/
|
|
||||||
app/core/src/main/resources/static/index.html
|
|
||||||
app/core/src/main/resources/static/locales/
|
|
||||||
app/core/src/main/resources/static/Login/
|
|
||||||
app/core/src/main/resources/static/classic-logo/
|
|
||||||
app/core/src/main/resources/static/modern-logo/
|
|
||||||
app/core/src/main/resources/static/og_images/
|
|
||||||
app/core/src/main/resources/static/samples/
|
|
||||||
app/core/src/main/resources/static/manifest-classic.json
|
|
||||||
app/core/src/main/resources/static/robots.txt
|
|
||||||
app/core/src/main/resources/static/pdfium/
|
|
||||||
app/core/src/main/resources/static/vendor/
|
|
||||||
# Note: Keep backend-managed files like fonts/, css/, js/, pdfjs/, etc.
|
|
||||||
|
|
||||||
# Gradle
|
# Gradle
|
||||||
.gradle
|
.gradle
|
||||||
.gradle-home
|
|
||||||
.lock
|
.lock
|
||||||
|
|
||||||
# External tool builders
|
# External tool builders
|
||||||
@@ -213,7 +196,7 @@ id_ed25519.pub
|
|||||||
.mypy_cache
|
.mypy_cache
|
||||||
.pytest_cache
|
.pytest_cache
|
||||||
.ipynb_checkpoints
|
.ipynb_checkpoints
|
||||||
.build-cache
|
|
||||||
|
|
||||||
|
|
||||||
**/jcef-bundle/
|
**/jcef-bundle/
|
||||||
@@ -221,26 +204,9 @@ id_ed25519.pub
|
|||||||
# node_modules
|
# node_modules
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
# weasyPrint
|
|
||||||
**/LOCAL_APPDATA_FONTCONFIG_CACHE/**
|
|
||||||
|
|
||||||
# Translation temp files
|
# Translation temp files
|
||||||
*_compact.json
|
*_compact.json
|
||||||
*compact*.json
|
*compact*.json
|
||||||
test_batch.json
|
test_batch.json
|
||||||
*.backup.*.json
|
*.backup.*.json
|
||||||
frontend/public/locales/*/translation.backup*.json
|
frontend/public/locales/*/translation.backup*.json
|
||||||
|
|
||||||
# Development/build artifacts
|
|
||||||
.gradle-cache/
|
|
||||||
scripts/pdf-collection/
|
|
||||||
**/tmp/
|
|
||||||
*.backup
|
|
||||||
|
|
||||||
# Type3 development data
|
|
||||||
docs/type3/signatures/
|
|
||||||
|
|
||||||
|
|
||||||
# Type3 sample PDFs (development only)
|
|
||||||
**/type3/samples/
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.14.8
|
rev: v0.12.7
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args:
|
args:
|
||||||
@@ -22,11 +22,11 @@ repos:
|
|||||||
files: \.(html|css|js|py|md)$
|
files: \.(html|css|js|py|md)$
|
||||||
exclude: (.vscode|.devcontainer|app/core/src/main/resources|app/proprietary/src/main/resources|Dockerfile|.*/pdfjs.*|.*/thirdParty.*|bootstrap.*|.*\.min\..*|.*diff\.js)
|
exclude: (.vscode|.devcontainer|app/core/src/main/resources|app/proprietary/src/main/resources|Dockerfile|.*/pdfjs.*|.*/thirdParty.*|bootstrap.*|.*\.min\..*|.*diff\.js)
|
||||||
- repo: https://github.com/gitleaks/gitleaks
|
- repo: https://github.com/gitleaks/gitleaks
|
||||||
rev: v8.30.0
|
rev: v8.28.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: gitleaks
|
- id: gitleaks
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v6.0.0
|
rev: v5.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
files: ^.*(\.js|\.java|\.py|\.yml)$
|
files: ^.*(\.js|\.java|\.py|\.yml)$
|
||||||
|
|||||||
+15
-7
@@ -1,6 +1,6 @@
|
|||||||
# Adding New React Tools to Stirling PDF
|
# Adding New React Tools to Stirling PDF
|
||||||
|
|
||||||
This guide covers how to add new PDF tools to the React frontend.
|
This guide covers how to add new PDF tools to the React frontend, either by migrating existing Thymeleaf templates or creating entirely new tools.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ import { use[ToolName]Tips } from "../components/tooltips/use[ToolName]Tips";
|
|||||||
|
|
||||||
const [ToolName] = (props: BaseToolProps) => {
|
const [ToolName] = (props: BaseToolProps) => {
|
||||||
const tips = use[ToolName]Tips();
|
const tips = use[ToolName]Tips();
|
||||||
|
|
||||||
// In your steps array:
|
// In your steps array:
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
@@ -202,10 +202,10 @@ const [ToolName] = (props: BaseToolProps) => {
|
|||||||
## 5. Add Translations
|
## 5. Add Translations
|
||||||
Update translation files. **Important: Only update `en-GB` files** - other languages are handled separately.
|
Update translation files. **Important: Only update `en-GB` files** - other languages are handled separately.
|
||||||
|
|
||||||
**File to update:** `frontend/public/locales/en-GB/translation.toml`
|
**File to update:** `frontend/public/locales/en-GB/translation.json`
|
||||||
|
|
||||||
**Required Translation Keys**:
|
**Required Translation Keys**:
|
||||||
```toml
|
```json
|
||||||
{
|
{
|
||||||
"home": {
|
"home": {
|
||||||
"[toolName]": {
|
"[toolName]": {
|
||||||
@@ -251,20 +251,28 @@ Update translation files. **Important: Only update `en-GB` files** - other langu
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Translation Notes:**
|
**Translation Notes:**
|
||||||
- **Only update `en-GB/translation.toml`** - other locale files are managed separately
|
- **Only update `en-GB/translation.json`** - other locale files are managed separately
|
||||||
- Use descriptive keys that match your component's `t()` calls
|
- Use descriptive keys that match your component's `t()` calls
|
||||||
- Include tooltip translations if you created tooltip hooks
|
- Include tooltip translations if you created tooltip hooks
|
||||||
- Add `options.*` keys if your tool has settings with descriptions
|
- Add `options.*` keys if your tool has settings with descriptions
|
||||||
|
|
||||||
**Tooltip Writing Guidelines:**
|
**Tooltip Writing Guidelines:**
|
||||||
- **Use simple, everyday language** - avoid technical terms like "converts interactive elements"
|
- **Use simple, everyday language** - avoid technical terms like "converts interactive elements"
|
||||||
- **Focus on benefits** - explain what the user gains, not how it works internally
|
- **Focus on benefits** - explain what the user gains, not how it works internally
|
||||||
- **Use concrete examples** - "text boxes become regular text" vs "form fields are flattened"
|
- **Use concrete examples** - "text boxes become regular text" vs "form fields are flattened"
|
||||||
- **Answer user questions** - "What does this do?", "When should I use this?", "What's this option for?"
|
- **Answer user questions** - "What does this do?", "When should I use this?", "What's this option for?"
|
||||||
- **Keep descriptions concise** - 1-2 sentences maximum per section
|
- **Keep descriptions concise** - 1-2 sentences maximum per section
|
||||||
- **Use bullet points** for multiple benefits or features
|
- **Use bullet points** for multiple benefits or features
|
||||||
|
|
||||||
## 6. Testing Your Tool
|
## 6. Migration from Thymeleaf
|
||||||
|
When migrating existing Thymeleaf templates:
|
||||||
|
|
||||||
|
1. **Identify Form Parameters**: Look at the original `<form>` inputs to determine parameter structure
|
||||||
|
2. **Extract Translation Keys**: Find `#{key.name}` references and add them to JSON translations (For many tools these translations will already exist but some parts will be missing)
|
||||||
|
3. **Map API Endpoint**: Note the `th:action` URL for the operation hook
|
||||||
|
4. **Preserve Functionality**: Ensure all original form behaviour is replicated which is applicable to V2 react UI
|
||||||
|
|
||||||
|
## 7. Testing Your Tool
|
||||||
- Verify tool appears in UI with correct icon and description
|
- Verify tool appears in UI with correct icon and description
|
||||||
- Test with various file sizes and types
|
- Test with various file sizes and types
|
||||||
- Confirm translations work
|
- Confirm translations work
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ return useToolOperation({
|
|||||||
## Architecture Overview
|
## Architecture Overview
|
||||||
|
|
||||||
### Project Structure
|
### Project Structure
|
||||||
- **Backend**: Spring Boot application
|
- **Backend**: Spring Boot application with Thymeleaf templating
|
||||||
- **Frontend**: React-based SPA in `/frontend` directory
|
- **Frontend**: React-based SPA in `/frontend` directory (Thymeleaf templates fully replaced)
|
||||||
- **File Storage**: IndexedDB for client-side file persistence and thumbnails
|
- **File Storage**: IndexedDB for client-side file persistence and thumbnails
|
||||||
- **Internationalization**: JSON-based translations (converted from backend .properties)
|
- **Internationalization**: JSON-based translations (converted from backend .properties)
|
||||||
- **PDF Processing**: PDFBox for core PDF operations, LibreOffice for conversions, PDF.js for client-side rendering
|
- **PDF Processing**: PDFBox for core PDF operations, LibreOffice for conversions, PDF.js for client-side rendering
|
||||||
@@ -140,6 +140,8 @@ return useToolOperation({
|
|||||||
- **API Controllers** (`src/main/java/.../controller/api/`): REST endpoints for PDF operations
|
- **API Controllers** (`src/main/java/.../controller/api/`): REST endpoints for PDF operations
|
||||||
- Organized by function: converters, security, misc, pipeline
|
- Organized by function: converters, security, misc, pipeline
|
||||||
- Follow pattern: `@RestController` + `@RequestMapping("/api/v1/...")`
|
- Follow pattern: `@RestController` + `@RequestMapping("/api/v1/...")`
|
||||||
|
- **Web Controllers** (`src/main/java/.../controller/web/`): Serve Thymeleaf templates
|
||||||
|
- Pattern: `@Controller` + return template names
|
||||||
|
|
||||||
### Key Components
|
### Key Components
|
||||||
- **SPDFApplication.java**: Main application class with desktop UI and browser launching logic
|
- **SPDFApplication.java**: Main application class with desktop UI and browser launching logic
|
||||||
@@ -199,6 +201,7 @@ return useToolOperation({
|
|||||||
|
|
||||||
- **Java Version**: Minimum JDK 17, supports and recommends JDK 21
|
- **Java Version**: Minimum JDK 17, supports and recommends JDK 21
|
||||||
- **Lombok**: Used extensively - ensure IDE plugin is installed
|
- **Lombok**: Used extensively - ensure IDE plugin is installed
|
||||||
|
- **Desktop Mode**: Set `STIRLING_PDF_DESKTOP_UI=true` for desktop application mode
|
||||||
- **File Persistence**:
|
- **File Persistence**:
|
||||||
- **Backend**: Designed to be stateless - files are processed in memory/temp locations only
|
- **Backend**: Designed to be stateless - files are processed in memory/temp locations only
|
||||||
- **Frontend**: Uses IndexedDB for client-side file storage and caching (with thumbnails)
|
- **Frontend**: Uses IndexedDB for client-side file storage and caching (with thumbnails)
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
The newly introduced feature enhances the application with robust database backup and import capabilities. This feature is designed to ensure data integrity and provide a straightforward way to manage database backups. Here's how it works:
|
The newly introduced feature enhances the application with robust database backup and import capabilities. This feature is designed to ensure data integrity and provide a straightforward way to manage database backups. Here's how it works:
|
||||||
|
|
||||||
1. Automatic Backup Creation
|
1. Automatic Backup Creation
|
||||||
- The system automatically creates a database backup on a configurable schedule (default: daily at midnight via `system.databaseBackup.cron`). This ensures that there is always a recent backup available, minimizing the risk of data loss.
|
- The system automatically creates a database backup every day at midnight. This ensures that there is always a recent backup available, minimizing the risk of data loss.
|
||||||
2. Manual Backup Export
|
2. Manual Backup Export
|
||||||
- Admin actions that modify the user database trigger a manual export of the database. This keeps the backup up-to-date with the latest changes and provides an extra layer of data security.
|
- Admin actions that modify the user database trigger a manual export of the database. This keeps the backup up-to-date with the latest changes and provides an extra layer of data security.
|
||||||
3. Importing Database Backups
|
3. Importing Database Backups
|
||||||
|
|||||||
+166
-25
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## 1. Introduction
|
## 1. Introduction
|
||||||
|
|
||||||
Stirling-PDF is a robust, locally hosted, web-based PDF manipulation tool. **Stirling 2.0** represents a complete frontend rewrite with a modern React SPA (Single Page Application).
|
Stirling-PDF is a robust, locally hosted, web-based PDF manipulation tool. **Stirling 2.0** represents a complete frontend rewrite, replacing the legacy Thymeleaf-based UI with a modern React SPA (Single Page Application).
|
||||||
|
|
||||||
This guide focuses on developing for Stirling 2.0, including both the React frontend and Spring Boot backend development workflows.
|
This guide focuses on developing for Stirling 2.0, including both the React frontend and Spring Boot backend development workflows.
|
||||||
|
|
||||||
@@ -32,11 +32,8 @@ This guide focuses on developing for Stirling 2.0, including both the React fron
|
|||||||
- Docker for containerization
|
- Docker for containerization
|
||||||
- Gradle for build management
|
- Gradle for build management
|
||||||
|
|
||||||
**Desktop Application (Tauri):**
|
**Legacy (reference only during development):**
|
||||||
- Tauri for cross-platform desktop app packaging
|
- Thymeleaf templates (being completely replaced in 2.0)
|
||||||
- Rust backend for system integration
|
|
||||||
- PDF file association support
|
|
||||||
- Self-contained JRE bundling with JLink
|
|
||||||
|
|
||||||
## 3. Development Environment Setup
|
## 3. Development Environment Setup
|
||||||
|
|
||||||
@@ -47,8 +44,6 @@ This guide focuses on developing for Stirling 2.0, including both the React fron
|
|||||||
- Java JDK 17 or later (JDK 21 recommended)
|
- Java JDK 17 or later (JDK 21 recommended)
|
||||||
- Node.js 18+ and npm (required for frontend development)
|
- Node.js 18+ and npm (required for frontend development)
|
||||||
- Gradle 7.0 or later (Included within the repo)
|
- Gradle 7.0 or later (Included within the repo)
|
||||||
- Rust and Cargo (required for Tauri desktop app development)
|
|
||||||
- Tauri CLI (install with `cargo install tauri-cli`)
|
|
||||||
|
|
||||||
### Setup Steps
|
### Setup Steps
|
||||||
|
|
||||||
@@ -97,9 +92,8 @@ Stirling 2.0 uses client-side file storage:
|
|||||||
- **PDF.js**: Handles client-side PDF rendering and processing
|
- **PDF.js**: Handles client-side PDF rendering and processing
|
||||||
- **URL Parameters**: Support for deep linking and tool state persistence
|
- **URL Parameters**: Support for deep linking and tool state persistence
|
||||||
|
|
||||||
### Tauri Desktop App Development
|
### Legacy Code Reference
|
||||||
Stirling-PDF can be packaged as a cross-platform desktop application using Tauri with PDF file association support and bundled JRE.
|
The existing Thymeleaf templates remain in the codebase during development as reference material but will be completely removed for the 2.0 release.
|
||||||
See [the frontend README](frontend/README.md#tauri) for build instructions.
|
|
||||||
|
|
||||||
## 5. Project Structure
|
## 5. Project Structure
|
||||||
|
|
||||||
@@ -115,12 +109,6 @@ Stirling-PDF/
|
|||||||
│ │ ├── services/ # API and utility services
|
│ │ ├── services/ # API and utility services
|
||||||
│ │ ├── types/ # TypeScript type definitions
|
│ │ ├── types/ # TypeScript type definitions
|
||||||
│ │ └── utils/ # Utility functions
|
│ │ └── utils/ # Utility functions
|
||||||
│ ├── src-tauri/ # Tauri desktop app configuration
|
|
||||||
│ │ ├── src/ # Rust backend code
|
|
||||||
│ │ ├── libs/ # JAR files (generated by build scripts)
|
|
||||||
│ │ ├── runtime/ # Bundled JRE (generated by build scripts)
|
|
||||||
│ │ ├── Cargo.toml # Rust dependencies
|
|
||||||
│ │ └── tauri.conf.json # Tauri configuration
|
|
||||||
│ ├── public/
|
│ ├── public/
|
||||||
│ │ └── locales/ # Internationalization files (JSON)
|
│ │ └── locales/ # Internationalization files (JSON)
|
||||||
│ ├── package.json # Frontend dependencies
|
│ ├── package.json # Frontend dependencies
|
||||||
@@ -148,6 +136,7 @@ Stirling-PDF/
|
|||||||
│ │ │ ├── css/
|
│ │ │ ├── css/
|
||||||
│ │ │ ├── js/
|
│ │ │ ├── js/
|
||||||
│ │ │ └── pdfjs/
|
│ │ │ └── pdfjs/
|
||||||
|
│ │ └── templates/ # Legacy Thymeleaf templates (reference only)
|
||||||
│ └── test/
|
│ └── test/
|
||||||
├── testing/ # Cucumber and integration tests
|
├── testing/ # Cucumber and integration tests
|
||||||
│ └── cucumber/ # Cucumber test files
|
│ └── cucumber/ # Cucumber test files
|
||||||
@@ -302,6 +291,7 @@ For quick iterations and development of Java backend, JavaScript, and UI compone
|
|||||||
- RESTful API endpoints
|
- RESTful API endpoints
|
||||||
- JavaScript functionality
|
- JavaScript functionality
|
||||||
- User interface components and styling
|
- User interface components and styling
|
||||||
|
- Thymeleaf templates
|
||||||
|
|
||||||
To run Stirling-PDF locally:
|
To run Stirling-PDF locally:
|
||||||
|
|
||||||
@@ -393,7 +383,7 @@ Remember to test your changes thoroughly to ensure they don't break any existing
|
|||||||
|
|
||||||
### React Component Development (Stirling 2.0)
|
### React Component Development (Stirling 2.0)
|
||||||
|
|
||||||
For Stirling 2.0, new features are built as React components:
|
For Stirling 2.0, new features are built as React components instead of Thymeleaf templates:
|
||||||
|
|
||||||
#### Creating a New Tool Component
|
#### Creating a New Tool Component
|
||||||
|
|
||||||
@@ -402,23 +392,23 @@ For Stirling 2.0, new features are built as React components:
|
|||||||
// frontend/src/tools/NewTool.tsx
|
// frontend/src/tools/NewTool.tsx
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Button, FileInput, Container } from '@mantine/core';
|
import { Button, FileInput, Container } from '@mantine/core';
|
||||||
|
|
||||||
interface NewToolProps {
|
interface NewToolProps {
|
||||||
params: Record<string, any>;
|
params: Record<string, any>;
|
||||||
updateParams: (updates: Record<string, any>) => void;
|
updateParams: (updates: Record<string, any>) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function NewTool({ params, updateParams }: NewToolProps) {
|
export default function NewTool({ params, updateParams }: NewToolProps) {
|
||||||
const [files, setFiles] = useState<File[]>([]);
|
const [files, setFiles] = useState<File[]>([]);
|
||||||
|
|
||||||
const handleProcess = async () => {
|
const handleProcess = async () => {
|
||||||
// Process files using API or client-side logic
|
// Process files using API or client-side logic
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<FileInput
|
<FileInput
|
||||||
multiple
|
multiple
|
||||||
accept="application/pdf"
|
accept="application/pdf"
|
||||||
onChange={setFiles}
|
onChange={setFiles}
|
||||||
/>
|
/>
|
||||||
@@ -440,6 +430,61 @@ For Stirling 2.0, new features are built as React components:
|
|||||||
3. **Register in Tool Picker:**
|
3. **Register in Tool Picker:**
|
||||||
Update the tool picker component to include the new tool with proper routing and URL parameter support.
|
Update the tool picker component to include the new tool with proper routing and URL parameter support.
|
||||||
|
|
||||||
|
### Legacy Reference: Overview of Thymeleaf
|
||||||
|
|
||||||
|
Thymeleaf is a server-side Java HTML template engine. It is used in Stirling-PDF to render dynamic web pages. Thymeleaf integrates heavily with Spring Boot.
|
||||||
|
|
||||||
|
### Thymeleaf overview
|
||||||
|
|
||||||
|
In Stirling-PDF, Thymeleaf is used to create HTML templates that are rendered on the server side. These templates are located in the `stirling-pdf/src/main/resources/templates` directory. Thymeleaf templates use a combination of HTML and special Thymeleaf attributes to dynamically generate content.
|
||||||
|
|
||||||
|
Some examples of this are:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<th:block th:insert="~{fragments/navbar.html :: navbar}"></th:block>
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```html
|
||||||
|
<th:block th:insert="~{fragments/footer.html :: footer}"></th:block>
|
||||||
|
```
|
||||||
|
|
||||||
|
Where it uses the `th:block`, `th:` indicating it's a special Thymeleaf element to be used server-side in generating the HTML, and block being the actual element type.
|
||||||
|
In this case, we are inserting the `navbar` entry within the `fragments/navbar.html` fragment into the `th:block` element.
|
||||||
|
|
||||||
|
They can be more complex, such as:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<th:block th:insert="~{fragments/common :: head(title=#{pageExtracter.title}, header=#{pageExtracter.header})}"></th:block>
|
||||||
|
```
|
||||||
|
|
||||||
|
Which is the same as above but passes the parameters title and header into the fragment `common.html` to be used in its HTML generation.
|
||||||
|
|
||||||
|
Thymeleaf can also be used to loop through objects or pass things from the Java side into the HTML side.
|
||||||
|
|
||||||
|
```java
|
||||||
|
@GetMapping
|
||||||
|
public String newFeaturePage(Model model) {
|
||||||
|
model.addAttribute("exampleData", exampleData);
|
||||||
|
return "new-feature";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
In the above example, if exampleData is a list of plain java objects of class Person and within it, you had id, name, age, etc. You can reference it like so
|
||||||
|
|
||||||
|
```html
|
||||||
|
<tbody>
|
||||||
|
<!-- Use th:each to iterate over the list -->
|
||||||
|
<tr th:each="person : ${exampleData}">
|
||||||
|
<td th:text="${person.id}"></td>
|
||||||
|
<td th:text="${person.name}"></td>
|
||||||
|
<td th:text="${person.age}"></td>
|
||||||
|
<td th:text="${person.email}"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
```
|
||||||
|
|
||||||
|
This would generate n entries of tr for each person in exampleData
|
||||||
|
|
||||||
### Adding a New Feature to the Backend (API)
|
### Adding a New Feature to the Backend (API)
|
||||||
|
|
||||||
1. **Create a New Controller:**
|
1. **Create a New Controller:**
|
||||||
@@ -464,7 +509,7 @@ For Stirling 2.0, new features are built as React components:
|
|||||||
@GetMapping
|
@GetMapping
|
||||||
@Operation(summary = "New Feature", description = "This is a new feature endpoint.")
|
@Operation(summary = "New Feature", description = "This is a new feature endpoint.")
|
||||||
public String newFeature() {
|
public String newFeature() {
|
||||||
return "NewFeatureResponse";
|
return "NewFeatureResponse"; // This refers to the NewFeatureResponse.html template presenting the user with the generated html from that file when they navigate to /api/v1/new-feature
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -519,6 +564,91 @@ For Stirling 2.0, new features are built as React components:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Adding a New Feature to the Frontend (UI)
|
||||||
|
|
||||||
|
1. **Create a New Thymeleaf Template:**
|
||||||
|
- Create a new HTML file in the `stirling-pdf/src/main/resources/templates` directory.
|
||||||
|
- Use Thymeleaf attributes to dynamically generate content.
|
||||||
|
- Use `extract-page.html` as a base example for the HTML template, which is useful to ensure importing of the general layout, navbar, and footer.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html th:lang="${#locale.language}" th:dir="#{language.direction}" th:data-language="${#locale.toString()}" xmlns:th="https://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<th:block th:insert="~{fragments/common :: head(title=#{newFeature.title}, header=#{newFeature.header})}"></th:block>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="page-container">
|
||||||
|
<div id="content-wrap">
|
||||||
|
<th:block th:insert="~{fragments/navbar.html :: navbar}"></th:block>
|
||||||
|
<br><br>
|
||||||
|
<div class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6 bg-card">
|
||||||
|
<div class="tool-header">
|
||||||
|
<span class="material-symbols-rounded tool-header-icon organize">upload</span>
|
||||||
|
<span class="tool-header-text" th:text="#{newFeature.header}"></span>
|
||||||
|
</div>
|
||||||
|
<form th:action="@{'/api/v1/new-feature'}" method="post" enctype="multipart/form-data">
|
||||||
|
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='application/pdf')}"></div>
|
||||||
|
<input type="hidden" id="customMode" name="customMode" value="">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="featureInput" th:text="#{newFeature.prompt}"></label>
|
||||||
|
<input type="text" class="form-control" id="featureInput" name="featureInput" th:placeholder="#{newFeature.placeholder}" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{newFeature.submit}"></button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<th:block th:insert="~{fragments/footer.html :: footer}"></th:block>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Create a New Controller for the UI:**
|
||||||
|
- Create a new Java class in the `stirling-pdf/src/main/java/stirling/software/SPDF/controller/ui` directory.
|
||||||
|
- Annotate the class with `@Controller` and `@RequestMapping` to define the UI endpoint.
|
||||||
|
|
||||||
|
```java
|
||||||
|
package stirling.software.SPDF.controller.ui;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import stirling.software.SPDF.service.NewFeatureService;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/new-feature")
|
||||||
|
public class NewFeatureUIController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NewFeatureService newFeatureService;
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public String newFeaturePage(Model model) {
|
||||||
|
model.addAttribute("newFeatureData", newFeatureService.getNewFeatureData());
|
||||||
|
return "new-feature";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Update the Navigation Bar:**
|
||||||
|
- Add a link to the new feature page in the navigation bar.
|
||||||
|
- Update the `stirling-pdf/src/main/resources/templates/fragments/navbar.html` file.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" th:href="@{'/new-feature'}">New Feature</a>
|
||||||
|
</li>
|
||||||
|
```
|
||||||
|
|
||||||
## Adding New Translations to Existing Language Files in Stirling-PDF
|
## Adding New Translations to Existing Language Files in Stirling-PDF
|
||||||
|
|
||||||
When adding a new feature or modifying existing ones in Stirling-PDF, you'll need to add new translation entries to the existing language files. Here's a step-by-step guide:
|
When adding a new feature or modifying existing ones in Stirling-PDF, you'll need to add new translation entries to the existing language files. Here's a step-by-step guide:
|
||||||
@@ -548,4 +678,15 @@ pdfSplitter.input.pages=Enter page numbers to split
|
|||||||
|
|
||||||
Add these entries to the default GB language file and any others you wish, translating the values as appropriate for each language.
|
Add these entries to the default GB language file and any others you wish, translating the values as appropriate for each language.
|
||||||
|
|
||||||
|
### 3. Use Translations in Thymeleaf Templates
|
||||||
|
|
||||||
|
In your Thymeleaf templates, use the `#{key}` syntax to reference the new translations:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<h1 th:text="#{pdfSplitter.title}">PDF Splitter</h1>
|
||||||
|
<p th:text="#{pdfSplitter.description}">Split your PDF into multiple documents</p>
|
||||||
|
<input type="text" th:placeholder="#{pdfSplitter.input.pages}">
|
||||||
|
<button th:text="#{pdfSplitter.button.split}">Split PDF</button>
|
||||||
|
```
|
||||||
|
|
||||||
Remember, never hard-code text in your templates or Java code. Always use translation keys to ensure proper localization.
|
Remember, never hard-code text in your templates or Java code. Always use translation keys to ensure proper localization.
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ Portions of this software are licensed as follows:
|
|||||||
|
|
||||||
* All content that resides under the "app/proprietary/" directory of this repository,
|
* All content that resides under the "app/proprietary/" directory of this repository,
|
||||||
if that directory exists, is licensed under the license defined in "app/proprietary/LICENSE".
|
if that directory exists, is licensed under the license defined in "app/proprietary/LICENSE".
|
||||||
* All content that resides under the "frontend/src/proprietary/" directory of this repository,
|
|
||||||
if that directory exists, is licensed under the license defined in "frontend/src/proprietary/LICENSE".
|
|
||||||
* All content that resides under the "frontend/src/desktop/" directory of this repository,
|
|
||||||
if that directory exists, is licensed under the license defined in "frontend/src/desktop/LICENSE".
|
|
||||||
* Content outside of the above mentioned directories or restrictions above is
|
* Content outside of the above mentioned directories or restrictions above is
|
||||||
available under the MIT License as defined below.
|
available under the MIT License as defined below.
|
||||||
|
|
||||||
|
|||||||
@@ -1,69 +1,173 @@
|
|||||||
<p align="center">
|
<p align="center"><img src="https://raw.githubusercontent.com/Stirling-Tools/Stirling-PDF/main/docs/stirling.png" width="80"></p>
|
||||||
<img src="https://raw.githubusercontent.com/Stirling-Tools/Stirling-PDF/main/docs/stirling.png" width="80" alt="Stirling PDF logo">
|
<h1 align="center">Stirling-PDF</h1>
|
||||||
</p>
|
|
||||||
|
|
||||||
<h1 align="center">Stirling PDF - The Open-Source PDF Platform</h1>
|
[](https://hub.docker.com/r/frooodle/s-pdf)
|
||||||
|
[](https://discord.gg/HYmhKj45pU)
|
||||||
|
[](https://scorecard.dev/viewer/?uri=github.com/Stirling-Tools/Stirling-PDF)
|
||||||
|
[](https://github.com/Stirling-Tools/stirling-pdf)
|
||||||
|
|
||||||
Stirling PDF is a powerful, open-source PDF editing platform. Run it as a personal desktop app, in the browser, or deploy it on your own servers with a private API. Edit, sign, redact, convert, and automate PDFs without sending documents to external services.
|
<a href="https://www.producthunt.com/posts/stirling-pdf?embed=true&utm_source=badge-featured&utm_medium=badge&utm_souce=badge-stirling-pdf" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=641239&theme=light" alt="Stirling PDF - Open source locally hosted web PDF editor | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
||||||
|
[](https://cloud.digitalocean.com/apps/new?repo=https://github.com/Stirling-Tools/Stirling-PDF/tree/digitalOcean&refcode=c3210994b1af)
|
||||||
|
|
||||||
<p align="center">
|
[Stirling-PDF](https://www.stirlingpdf.com) is a robust, locally hosted web-based PDF manipulation tool using Docker. It enables you to carry out various operations on PDF files, including splitting, merging, converting, reorganizing, adding images, rotating, compressing, and more. This locally hosted web application has evolved to encompass a comprehensive set of features, addressing all your PDF requirements.
|
||||||
<a href="https://hub.docker.com/r/stirlingtools/stirling-pdf">
|
|
||||||
<img src="https://img.shields.io/docker/pulls/frooodle/s-pdf" alt="Docker Pulls">
|
|
||||||
</a>
|
|
||||||
<a href="https://discord.gg/HYmhKj45pU">
|
|
||||||
<img src="https://img.shields.io/discord/1068636748814483718?label=Discord" alt="Discord">
|
|
||||||
</a>
|
|
||||||
<a href="https://scorecard.dev/viewer/?uri=github.com/Stirling-Tools/Stirling-PDF">
|
|
||||||
<img src="https://api.scorecard.dev/projects/github.com/Stirling-Tools/Stirling-PDF/badge" alt="OpenSSF Scorecard">
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/Stirling-Tools/stirling-pdf">
|
|
||||||
<img src="https://img.shields.io/github/stars/stirling-tools/stirling-pdf?style=social" alt="GitHub Repo stars">
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||

|
All files and PDFs exist either exclusively on the client side, reside in server memory only during task execution, or temporarily reside in a file solely for the execution of the task. Any file downloaded by the user will have been deleted from the server by that point.
|
||||||
|
|
||||||
## Key Capabilities
|
Homepage: [https://stirlingpdf.com](https://stirlingpdf.com)
|
||||||
|
|
||||||
- **Everywhere you work** - Desktop client, browser UI, and self-hosted server with a private API.
|
All documentation available at [https://docs.stirlingpdf.com/](https://docs.stirlingpdf.com/)
|
||||||
- **50+ PDF tools** - Edit, merge, split, sign, redact, convert, OCR, compress, and more.
|
|
||||||
- **Automation & workflows** - No-code pipelines direct in UI with APIs to process millions of PDFs.
|
|
||||||
- **Enterprise‑grade** - SSO, auditing, and flexible on‑prem deployments.
|
|
||||||
- **Developer platform** - REST APIs available for nearly all tools to integrate into your existing systems.
|
|
||||||
- **Global UI** - Interface available in 40+ languages.
|
|
||||||
|
|
||||||
For a full feature list, see the docs: **https://docs.stirlingpdf.com**
|

|
||||||
|
|
||||||
## Quick Start
|
## Features
|
||||||
|
|
||||||
```bash
|
- 50+ PDF Operations
|
||||||
docker run -p 8080:8080 docker.stirlingpdf.com/stirlingtools/stirling-pdf
|
- Parallel file processing and downloads
|
||||||
```
|
- Dark mode support
|
||||||
|
- Custom download options
|
||||||
|
- Custom 'Pipelines' to run multiple features in a automated queue
|
||||||
|
- API for integration with external scripts
|
||||||
|
- Optional Login and Authentication support (see [here](https://docs.stirlingpdf.com/Advanced%20Configuration/System%20and%20Security) for documentation)
|
||||||
|
- Database Backup and Import (see [here](https://docs.stirlingpdf.com/Advanced%20Configuration/DATABASE) for documentation)
|
||||||
|
- Enterprise features like SSO (see [here](https://docs.stirlingpdf.com/Advanced%20Configuration/Single%20Sign-On%20Configuration) for documentation)
|
||||||
|
|
||||||
Then open: http://localhost:8080
|
## PDF Features
|
||||||
|
|
||||||
For full installation options (including desktop and Kubernetes), see our [Documentation Guide](https://docs.stirlingpdf.com/#documentation-guide).
|
### Page Operations
|
||||||
|
|
||||||
## Resources
|
- View and modify PDFs - View multi-page PDFs with custom viewing, sorting, and searching. Plus, on-page edit features like annotating, drawing, and adding text and images. (Using PDF.js with Joxit and Liberation fonts)
|
||||||
|
- Full interactive GUI for merging/splitting/rotating/moving PDFs and their pages
|
||||||
|
- Merge multiple PDFs into a single resultant file
|
||||||
|
- Split PDFs into multiple files at specified page numbers or extract all pages as individual files
|
||||||
|
- Reorganize PDF pages into different orders
|
||||||
|
- Rotate PDFs in 90-degree increments
|
||||||
|
- Remove pages
|
||||||
|
- Multi-page layout (format PDFs into a multi-paged page)
|
||||||
|
- Scale page contents size by set percentage
|
||||||
|
- Adjust contrast
|
||||||
|
- Crop PDF
|
||||||
|
- Auto-split PDF (with physically scanned page dividers)
|
||||||
|
- Extract page(s)
|
||||||
|
- Convert PDF to a single page
|
||||||
|
- Overlay PDFs on top of each other
|
||||||
|
- PDF to a single page
|
||||||
|
- Split PDF by sections
|
||||||
|
|
||||||
- [**Documentation**](https://docs.stirlingpdf.com)
|
### Conversion Operations
|
||||||
- [**Homepage**](https://stirling.com)
|
|
||||||
- [**API Docs**](https://registry.scalar.com/@stirlingpdf/apis/stirling-pdf-processing-api/)
|
|
||||||
- [**Server Plan & Enterprise**](https://docs.stirlingpdf.com/Paid-Offerings)
|
|
||||||
|
|
||||||
## Support
|
- Convert PDFs to and from images
|
||||||
|
- Convert any common file to PDF (using LibreOffice)
|
||||||
|
- Convert PDF to Word/PowerPoint/others (using LibreOffice)
|
||||||
|
- Convert HTML to PDF
|
||||||
|
- Convert PDF to XML
|
||||||
|
- Convert PDF to CSV
|
||||||
|
- URL to PDF
|
||||||
|
- Markdown to PDF
|
||||||
|
|
||||||
- **Community** [Discord](https://discord.gg/HYmhKj45pU)
|
### Security & Permissions
|
||||||
- **Bug Reports**: [Github issues](https://github.com/Stirling-Tools/Stirling-PDF/issues)
|
|
||||||
|
|
||||||
## Contributing
|
- Add and remove passwords
|
||||||
|
- Change/set PDF permissions
|
||||||
|
- Add watermark(s)
|
||||||
|
- Certify/sign PDFs
|
||||||
|
- Sanitize PDFs
|
||||||
|
- Auto-redact text
|
||||||
|
|
||||||
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
### Other Operations
|
||||||
|
|
||||||
For development setup, see the [Developer Guide](DeveloperGuide.md).
|
- Add/generate/write signatures
|
||||||
|
- Split by Size or PDF
|
||||||
|
- Repair PDFs
|
||||||
|
- Detect and remove blank pages
|
||||||
|
- Compare two PDFs and show differences in text
|
||||||
|
- Add images to PDFs
|
||||||
|
- Compress PDFs to decrease their filesize (using qpdf)
|
||||||
|
- Extract images from PDF
|
||||||
|
- Remove images from PDF
|
||||||
|
- Extract images from scans
|
||||||
|
- Remove annotations
|
||||||
|
- Add page numbers
|
||||||
|
- Auto-rename files by detecting PDF header text
|
||||||
|
- OCR on PDF (using Tesseract OCR)
|
||||||
|
- PDF/A conversion (using LibreOffice)
|
||||||
|
- Edit metadata
|
||||||
|
- Flatten PDFs
|
||||||
|
- Get all information on a PDF to view or export as JSON
|
||||||
|
- Show/detect embedded JavaScript
|
||||||
|
|
||||||
For adding translations, see the [Translation Guide](devGuide/HowToAddNewLanguage.md).
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Stirling PDF is open-core. See [LICENSE](LICENSE) for details.
|
# 📖 Get Started
|
||||||
|
|
||||||
|
Visit our comprehensive documentation at [docs.stirlingpdf.com](https://docs.stirlingpdf.com) for:
|
||||||
|
|
||||||
|
- Installation guides for all platforms
|
||||||
|
- Configuration options
|
||||||
|
- Feature documentation
|
||||||
|
- API reference
|
||||||
|
- Security setup
|
||||||
|
- Enterprise features
|
||||||
|
|
||||||
|
|
||||||
|
## Supported Languages
|
||||||
|
|
||||||
|
Stirling-PDF currently supports 40 languages!
|
||||||
|
|
||||||
|
| Language | Progress |
|
||||||
|
| -------------------------------------------- | -------------------------------------- |
|
||||||
|
| Arabic (العربية) (ar_AR) |  |
|
||||||
|
| Azerbaijani (Azərbaycan Dili) (az_AZ) |  |
|
||||||
|
| Basque (Euskara) (eu_ES) |  |
|
||||||
|
| Bulgarian (Български) (bg_BG) |  |
|
||||||
|
| Catalan (Català) (ca_CA) |  |
|
||||||
|
| Croatian (Hrvatski) (hr_HR) |  |
|
||||||
|
| Czech (Česky) (cs_CZ) |  |
|
||||||
|
| Danish (Dansk) (da_DK) |  |
|
||||||
|
| Dutch (Nederlands) (nl_NL) |  |
|
||||||
|
| English (English) (en_GB) |  |
|
||||||
|
| English (US) (en_US) |  |
|
||||||
|
| French (Français) (fr_FR) |  |
|
||||||
|
| German (Deutsch) (de_DE) |  |
|
||||||
|
| Greek (Ελληνικά) (el_GR) |  |
|
||||||
|
| Hindi (हिंदी) (hi_IN) |  |
|
||||||
|
| Hungarian (Magyar) (hu_HU) |  |
|
||||||
|
| Indonesian (Bahasa Indonesia) (id_ID) |  |
|
||||||
|
| Irish (Gaeilge) (ga_IE) |  |
|
||||||
|
| Italian (Italiano) (it_IT) |  |
|
||||||
|
| Japanese (日本語) (ja_JP) |  |
|
||||||
|
| Korean (한국어) (ko_KR) |  |
|
||||||
|
| Norwegian (Norsk) (no_NB) |  |
|
||||||
|
| Persian (فارسی) (fa_IR) |  |
|
||||||
|
| Polish (Polski) (pl_PL) |  |
|
||||||
|
| Portuguese (Português) (pt_PT) |  |
|
||||||
|
| Portuguese Brazilian (Português) (pt_BR) |  |
|
||||||
|
| Romanian (Română) (ro_RO) |  |
|
||||||
|
| Russian (Русский) (ru_RU) |  |
|
||||||
|
| Serbian Latin alphabet (Srpski) (sr_LATN_RS) |  |
|
||||||
|
| Simplified Chinese (简体中文) (zh_CN) |  |
|
||||||
|
| Slovakian (Slovensky) (sk_SK) |  |
|
||||||
|
| Slovenian (Slovenščina) (sl_SI) |  |
|
||||||
|
| Spanish (Español) (es_ES) |  |
|
||||||
|
| Swedish (Svenska) (sv_SE) |  |
|
||||||
|
| Thai (ไทย) (th_TH) |  |
|
||||||
|
| Tibetan (བོད་ཡིག་) (bo_CN) |  |
|
||||||
|
| Traditional Chinese (繁體中文) (zh_TW) |  |
|
||||||
|
| Turkish (Türkçe) (tr_TR) |  |
|
||||||
|
| Ukrainian (Українська) (uk_UA) |  |
|
||||||
|
| Vietnamese (Tiếng Việt) (vi_VN) |  |
|
||||||
|
| Malayalam (മലയാളം) (ml_IN) |  |
|
||||||
|
|
||||||
|
## Stirling PDF Enterprise
|
||||||
|
|
||||||
|
Stirling PDF offers an Enterprise edition of its software. This is the same great software but with added features, support and comforts.
|
||||||
|
Check out our [Enterprise docs](https://docs.stirlingpdf.com/Pro)
|
||||||
|
|
||||||
|
|
||||||
|
## 🤝 Looking to contribute?
|
||||||
|
|
||||||
|
Join our community:
|
||||||
|
- [Contribution Guidelines](CONTRIBUTING.md)
|
||||||
|
- [Translation Guide (How to add custom languages)](devGuide/HowToAddNewLanguage.md)
|
||||||
|
- [Developer Guide](devGuide/DeveloperGuide.md)
|
||||||
|
- [Issue Tracker](https://github.com/Stirling-Tools/Stirling-PDF/issues)
|
||||||
|
- [Discord Community](https://discord.gg/HYmhKj45pU)
|
||||||
|
|||||||
@@ -1,258 +0,0 @@
|
|||||||
# Windows Code Signing Setup Guide
|
|
||||||
|
|
||||||
This guide explains how to set up Windows code signing for Stirling-PDF desktop application builds.
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
Windows code signing is essential for:
|
|
||||||
- Preventing Windows SmartScreen warnings
|
|
||||||
- Building trust with users
|
|
||||||
- Enabling Microsoft Store distribution
|
|
||||||
- Professional application distribution
|
|
||||||
|
|
||||||
## Certificate Types
|
|
||||||
|
|
||||||
### OV Certificate (Organization Validated)
|
|
||||||
- More affordable option
|
|
||||||
- Requires business verification
|
|
||||||
- May trigger SmartScreen warnings initially until reputation builds
|
|
||||||
- Suitable for most independent software vendors
|
|
||||||
|
|
||||||
### EV Certificate (Extended Validation)
|
|
||||||
- Premium option with immediate SmartScreen reputation
|
|
||||||
- Requires hardware security module (HSM) or cloud-based signing
|
|
||||||
- Higher cost but provides immediate trust
|
|
||||||
- Required since June 2023 for new certificates
|
|
||||||
|
|
||||||
## Obtaining a Certificate
|
|
||||||
|
|
||||||
### Certificate Authorities
|
|
||||||
Popular certificate authorities for Windows code signing:
|
|
||||||
- DigiCert
|
|
||||||
- Sectigo (formerly Comodo)
|
|
||||||
- GlobalSign
|
|
||||||
- SSL.com
|
|
||||||
|
|
||||||
### Certificate Format
|
|
||||||
You'll receive a certificate in one of these formats:
|
|
||||||
- `.pfx` or `.p12` (preferred - contains both certificate and private key)
|
|
||||||
- `.cer` + private key (needs conversion to .pfx)
|
|
||||||
|
|
||||||
### Converting to PFX (if needed)
|
|
||||||
If you have separate certificate and private key files:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
openssl pkcs12 -export -out certificate.pfx -inkey private-key.key -in certificate.cer
|
|
||||||
```
|
|
||||||
|
|
||||||
## Setting Up GitHub Secrets
|
|
||||||
|
|
||||||
### Required Secrets
|
|
||||||
|
|
||||||
Navigate to your GitHub repository → Settings → Secrets and variables → Actions
|
|
||||||
|
|
||||||
Add the following secrets:
|
|
||||||
|
|
||||||
#### 1. `WINDOWS_CERTIFICATE`
|
|
||||||
- **Description**: Base64-encoded .pfx certificate file
|
|
||||||
- **How to create**:
|
|
||||||
|
|
||||||
**On macOS/Linux:**
|
|
||||||
```bash
|
|
||||||
base64 -i certificate.pfx | pbcopy # Copies to clipboard
|
|
||||||
```
|
|
||||||
|
|
||||||
**On Windows (PowerShell):**
|
|
||||||
```powershell
|
|
||||||
[Convert]::ToBase64String([IO.File]::ReadAllBytes("certificate.pfx")) | Set-Clipboard
|
|
||||||
```
|
|
||||||
|
|
||||||
Paste the entire base64 string into the GitHub secret.
|
|
||||||
|
|
||||||
#### 2. `WINDOWS_CERTIFICATE_PASSWORD`
|
|
||||||
- **Description**: Password for the .pfx certificate
|
|
||||||
- **Value**: The password you set when creating/exporting the .pfx file
|
|
||||||
|
|
||||||
### Optional Secrets for Tauri Updater
|
|
||||||
|
|
||||||
If you're using Tauri's built-in updater feature:
|
|
||||||
|
|
||||||
#### `TAURI_SIGNING_PRIVATE_KEY`
|
|
||||||
- Generated using Tauri CLI: `npm run tauri signer generate`
|
|
||||||
- Used for update package verification
|
|
||||||
|
|
||||||
#### `TAURI_SIGNING_PRIVATE_KEY_PASSWORD`
|
|
||||||
- Password for the Tauri signing key
|
|
||||||
|
|
||||||
## Configuration Files
|
|
||||||
|
|
||||||
### 1. Tauri Configuration (frontend/src-tauri/tauri.conf.json)
|
|
||||||
|
|
||||||
The Windows signing configuration is already set up:
|
|
||||||
|
|
||||||
```json
|
|
||||||
"windows": {
|
|
||||||
"certificateThumbprint": null,
|
|
||||||
"digestAlgorithm": "sha256",
|
|
||||||
"timestampUrl": "http://timestamp.digicert.com"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Configuration Options:**
|
|
||||||
- `certificateThumbprint`: Automatically extracted from imported certificate (leave as `null`)
|
|
||||||
- `digestAlgorithm`: Hashing algorithm - `sha256` is recommended
|
|
||||||
- `timestampUrl`: Timestamp server to prove signing time (survives certificate expiration)
|
|
||||||
|
|
||||||
**Alternative Timestamp Servers:**
|
|
||||||
- DigiCert: `http://timestamp.digicert.com`
|
|
||||||
- Sectigo: `http://timestamp.sectigo.com`
|
|
||||||
- GlobalSign: `http://timestamp.globalsign.com`
|
|
||||||
|
|
||||||
### 2. GitHub Workflow (.github/workflows/tauri-build.yml)
|
|
||||||
|
|
||||||
The workflow includes three Windows signing steps:
|
|
||||||
|
|
||||||
1. **Import Certificate**: Decodes and imports the .pfx certificate into Windows certificate store
|
|
||||||
2. **Build Tauri App**: Builds and signs the application using the imported certificate
|
|
||||||
3. **Verify Signature**: Validates that both .exe and .msi files are properly signed
|
|
||||||
|
|
||||||
## Testing the Setup
|
|
||||||
|
|
||||||
### 1. Local Testing (Windows Only)
|
|
||||||
|
|
||||||
Before pushing to GitHub, test locally:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
# Set environment variables
|
|
||||||
$env:WINDOWS_CERTIFICATE = [Convert]::ToBase64String([IO.File]::ReadAllBytes("certificate.pfx"))
|
|
||||||
$env:WINDOWS_CERTIFICATE_PASSWORD = "your-certificate-password"
|
|
||||||
|
|
||||||
# Build the application
|
|
||||||
cd frontend
|
|
||||||
npm run tauri build
|
|
||||||
|
|
||||||
# Verify the signature
|
|
||||||
Get-AuthenticodeSignature "./src-tauri/target/release/bundle/msi/Stirling-PDF_*.msi"
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. GitHub Actions Testing
|
|
||||||
|
|
||||||
1. Push your changes to a branch
|
|
||||||
2. Manually trigger the workflow:
|
|
||||||
- Go to Actions → Build Tauri Applications
|
|
||||||
- Click "Run workflow"
|
|
||||||
- Select "windows" platform
|
|
||||||
3. Check the build logs for:
|
|
||||||
- ✅ Certificate import success
|
|
||||||
- ✅ Build completion
|
|
||||||
- ✅ Signature verification
|
|
||||||
|
|
||||||
### 3. Verifying Signed Binaries
|
|
||||||
|
|
||||||
After downloading the built artifacts:
|
|
||||||
|
|
||||||
**Windows (PowerShell):**
|
|
||||||
```powershell
|
|
||||||
Get-AuthenticodeSignature "Stirling-PDF-windows-x86_64.exe"
|
|
||||||
Get-AuthenticodeSignature "Stirling-PDF-windows-x86_64.msi"
|
|
||||||
```
|
|
||||||
|
|
||||||
Look for:
|
|
||||||
- Status: `Valid`
|
|
||||||
- Signer: Your organization name
|
|
||||||
- Timestamp: Recent date/time
|
|
||||||
|
|
||||||
**Windows (GUI):**
|
|
||||||
1. Right-click the .exe or .msi file
|
|
||||||
2. Select "Properties"
|
|
||||||
3. Go to "Digital Signatures" tab
|
|
||||||
4. Verify signature details
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### "HashMismatch" Status
|
|
||||||
- Certificate doesn't match the binary
|
|
||||||
- Possible file corruption during download
|
|
||||||
- Re-download and verify
|
|
||||||
|
|
||||||
### "NotSigned" Status
|
|
||||||
- Certificate wasn't imported correctly
|
|
||||||
- Check GitHub secrets are set correctly
|
|
||||||
- Verify base64 encoding is complete (no truncation)
|
|
||||||
|
|
||||||
### "UnknownError" Status
|
|
||||||
- Timestamp server unreachable
|
|
||||||
- Try alternative timestamp URL in tauri.conf.json
|
|
||||||
- Check network connectivity in GitHub Actions
|
|
||||||
|
|
||||||
### SmartScreen Still Shows Warnings
|
|
||||||
- Normal for OV certificates initially
|
|
||||||
- Reputation builds over time with user downloads
|
|
||||||
- Consider EV certificate for immediate reputation
|
|
||||||
|
|
||||||
### Certificate Not Found During Build
|
|
||||||
- Verify `WINDOWS_CERTIFICATE` secret is set
|
|
||||||
- Check base64 encoding is correct (no extra whitespace)
|
|
||||||
- Ensure password is correct
|
|
||||||
|
|
||||||
## Security Best Practices
|
|
||||||
|
|
||||||
1. **Never commit certificates to version control**
|
|
||||||
- Keep .pfx files secure and backed up
|
|
||||||
- Use GitHub secrets for CI/CD
|
|
||||||
|
|
||||||
2. **Rotate certificates before expiration**
|
|
||||||
- Set calendar reminders
|
|
||||||
- Update GitHub secrets with new certificate
|
|
||||||
|
|
||||||
3. **Use strong passwords**
|
|
||||||
- Certificate password should be complex
|
|
||||||
- Store securely (password manager)
|
|
||||||
|
|
||||||
4. **Monitor certificate usage**
|
|
||||||
- Review GitHub Actions logs
|
|
||||||
- Set up notifications for failed builds
|
|
||||||
|
|
||||||
5. **Limit access to secrets**
|
|
||||||
- Only repository admins should access secrets
|
|
||||||
- Audit secret access regularly
|
|
||||||
|
|
||||||
## Certificate Lifecycle
|
|
||||||
|
|
||||||
### Before Expiration
|
|
||||||
1. Obtain new certificate from CA (typically annual renewal)
|
|
||||||
2. Convert to .pfx format if needed
|
|
||||||
3. Update `WINDOWS_CERTIFICATE` secret with new base64-encoded certificate
|
|
||||||
4. Update `WINDOWS_CERTIFICATE_PASSWORD` if password changed
|
|
||||||
5. Test build to verify new certificate works
|
|
||||||
|
|
||||||
### Expired Certificates
|
|
||||||
- Signed binaries remain valid (timestamp proves signing time)
|
|
||||||
- New builds will fail until certificate is renewed
|
|
||||||
- Users can still install previously signed versions
|
|
||||||
|
|
||||||
## Cost Considerations
|
|
||||||
|
|
||||||
### Certificate Costs (Annual, as of 2024)
|
|
||||||
- **OV Certificate**: $100-400/year
|
|
||||||
- **EV Certificate**: $400-1000/year
|
|
||||||
|
|
||||||
### Choosing the Right Certificate
|
|
||||||
- **Open source / early stage**: Start with OV
|
|
||||||
- **Commercial / enterprise**: Consider EV for better trust
|
|
||||||
- **Microsoft Store**: EV certificate required
|
|
||||||
|
|
||||||
## Additional Resources
|
|
||||||
|
|
||||||
- [Tauri Windows Signing Documentation](https://v2.tauri.app/distribute/sign/windows/)
|
|
||||||
- [Microsoft Code Signing Overview](https://docs.microsoft.com/windows/win32/seccrypto/cryptography-tools)
|
|
||||||
- [DigiCert Code Signing Guide](https://www.digicert.com/signing/code-signing-certificates)
|
|
||||||
- [Windows SmartScreen FAQ](https://support.microsoft.com/windows/smartscreen-faq)
|
|
||||||
|
|
||||||
## Support
|
|
||||||
|
|
||||||
If you encounter issues with Windows code signing:
|
|
||||||
1. Check GitHub Actions logs for detailed error messages
|
|
||||||
2. Verify all secrets are set correctly
|
|
||||||
3. Test certificate locally first (Windows environment required)
|
|
||||||
4. Open an issue in the repository with relevant logs (remove sensitive data)
|
|
||||||
@@ -96,22 +96,6 @@
|
|||||||
"moduleName": ".*",
|
"moduleName": ".*",
|
||||||
"moduleLicense": "MPL 2.0"
|
"moduleLicense": "MPL 2.0"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"moduleName": ".*",
|
|
||||||
"moduleLicense": "Mozilla Public License, Version 2.0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"moduleName": ".*",
|
|
||||||
"moduleLicense": "Mozilla Public License 2.0 (MPL-2.0)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"moduleName": ".*",
|
|
||||||
"moduleLicense": "CDDL+GPL License"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"moduleName": ".*",
|
|
||||||
"moduleLicense": "BSD"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"moduleName": ".*",
|
"moduleName": ".*",
|
||||||
"moduleLicense": "UnboundID SCIM2 SDK Free Use License"
|
"moduleLicense": "UnboundID SCIM2 SDK Free Use License"
|
||||||
@@ -183,10 +167,6 @@
|
|||||||
{
|
{
|
||||||
"moduleName": ".*",
|
"moduleName": ".*",
|
||||||
"moduleLicense": "The W3C License"
|
"moduleLicense": "The W3C License"
|
||||||
},
|
|
||||||
{
|
|
||||||
"moduleName": ".*",
|
|
||||||
"moduleLicense": "UnRar License"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-12
@@ -29,23 +29,17 @@ spotless {
|
|||||||
dependencies {
|
dependencies {
|
||||||
api 'org.springframework.boot:spring-boot-starter-web'
|
api 'org.springframework.boot:spring-boot-starter-web'
|
||||||
api 'org.springframework.boot:spring-boot-starter-aop'
|
api 'org.springframework.boot:spring-boot-starter-aop'
|
||||||
|
// api 'org.springframework.boot:spring-boot-starter-thymeleaf' // Deprecated - UI moved to React frontend
|
||||||
api 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20240325.1'
|
api 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20240325.1'
|
||||||
api 'com.fathzer:javaluator:3.0.6'
|
api 'com.fathzer:javaluator:3.0.6'
|
||||||
api 'com.posthog.java:posthog:1.2.0'
|
api 'com.posthog.java:posthog:1.2.0'
|
||||||
api 'org.apache.commons:commons-lang3:3.20.0'
|
api 'org.apache.commons:commons-lang3:3.18.0'
|
||||||
api 'com.drewnoakes:metadata-extractor:2.19.0' // Image metadata extractor
|
api 'com.drewnoakes:metadata-extractor:2.19.0' // Image metadata extractor
|
||||||
api 'com.vladsch.flexmark:flexmark-html2md-converter:0.64.8'
|
api 'com.vladsch.flexmark:flexmark-html2md-converter:0.64.8'
|
||||||
api "org.apache.pdfbox:pdfbox:$pdfboxVersion"
|
api "org.apache.pdfbox:pdfbox:$pdfboxVersion"
|
||||||
api "org.apache.pdfbox:pdfbox-io:$pdfboxVersion"
|
|
||||||
api "org.apache.pdfbox:xmpbox:$pdfboxVersion"
|
|
||||||
api "org.apache.pdfbox:preflight:$pdfboxVersion"
|
|
||||||
api 'com.github.junrar:junrar:7.5.7' // RAR archive support for CBR files
|
|
||||||
api 'jakarta.servlet:jakarta.servlet-api:6.1.0'
|
api 'jakarta.servlet:jakarta.servlet-api:6.1.0'
|
||||||
api 'org.snakeyaml:snakeyaml-engine:3.0.1'
|
api 'org.snakeyaml:snakeyaml-engine:2.10'
|
||||||
api "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.15"
|
api "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.9"
|
||||||
// Simple Java Mail for EML/MSG parsing (replaces direct Angus Mail usage)
|
api 'jakarta.mail:jakarta.mail-api:2.1.3'
|
||||||
api 'org.simplejavamail:simple-java-mail:8.12.6'
|
runtimeOnly 'org.eclipse.angus:angus-mail:2.0.4'
|
||||||
api 'org.simplejavamail:outlook-module:8.12.6' // MSG file support
|
|
||||||
api 'jakarta.mail:jakarta.mail-api:2.1.5'
|
|
||||||
runtimeOnly 'org.eclipse.angus:angus-mail:2.0.5'
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -3,7 +3,6 @@ package stirling.software.common.annotations;
|
|||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
import org.springframework.core.annotation.AliasFor;
|
import org.springframework.core.annotation.AliasFor;
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ public @interface AutoJobPostMapping {
|
|||||||
|
|
||||||
/** MIME types this endpoint accepts. Defaults to {@code multipart/form-data}. */
|
/** MIME types this endpoint accepts. Defaults to {@code multipart/form-data}. */
|
||||||
@AliasFor(annotation = RequestMapping.class, attribute = "consumes")
|
@AliasFor(annotation = RequestMapping.class, attribute = "consumes")
|
||||||
String[] consumes() default {MediaType.MULTIPART_FORM_DATA_VALUE};
|
String[] consumes() default {"multipart/form-data"};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum execution time in milliseconds before the job is aborted. A negative value means "use
|
* Maximum execution time in milliseconds before the job is aborted. A negative value means "use
|
||||||
|
|||||||
@@ -22,13 +22,25 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
name = "Analysis",
|
name = "Analysis",
|
||||||
description =
|
description =
|
||||||
"""
|
"""
|
||||||
Read-only inspection of PDFs: page count, page sizes, fonts, form fields, annotations, document properties, and security details.
|
Document analysis and information extraction services for content intelligence and insights.
|
||||||
Use these endpoints to understand what's inside a document without changing it.
|
|
||||||
|
|
||||||
Typical uses:
|
This endpoint group provides analytical capabilities to understand document structure,
|
||||||
• Get page counts and dimensions for layout or print rules
|
extract information, and generate insights from PDF content for automated processing.
|
||||||
• List fonts and annotations to spot compatibility issues
|
|
||||||
• Inspect form fields before deciding how to fill or modify them
|
Common use cases:
|
||||||
• Pull metadata and security settings for audits or reports
|
• Document inventory management and content audit for compliance verification
|
||||||
|
• Quality assurance workflows and business intelligence analytics
|
||||||
|
• Migration planning, accessibility evaluation, and document forensics
|
||||||
|
|
||||||
|
Business applications:
|
||||||
|
• Legal discovery, financial document review, and healthcare records analysis
|
||||||
|
• Academic research, government processing, and publishing optimization
|
||||||
|
|
||||||
|
Operational scenarios:
|
||||||
|
• Large-scale profiling, migration assessment, and performance optimization
|
||||||
|
• Automated quality control and content strategy development
|
||||||
|
|
||||||
|
Target users: Data analysts, QA teams, administrators, and business intelligence
|
||||||
|
professionals requiring detailed document insights.
|
||||||
""")
|
""")
|
||||||
public @interface AnalysisApi {}
|
public @interface AnalysisApi {}
|
||||||
|
|||||||
@@ -22,13 +22,25 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
name = "Convert",
|
name = "Convert",
|
||||||
description =
|
description =
|
||||||
"""
|
"""
|
||||||
Convert PDFs to and from other formats (Word, images, HTML, Markdown, PDF/A, CBZ/CBR, EML, etc.).
|
Document format transformation services for cross-platform compatibility and workflow integration.
|
||||||
This group also powers the text-editor / jobId-based editing flow for incremental PDF edits.
|
|
||||||
|
|
||||||
Typical uses:
|
This endpoint group enables transformation between various formats, supporting
|
||||||
• Turn PDFs into Word or text for editing
|
diverse business workflows and system integrations for mixed document ecosystems.
|
||||||
• Convert office files, images, HTML, or email (EML) into PDFs
|
|
||||||
• Create PDF/A for long-term archiving
|
Common use cases:
|
||||||
• Export PDFs as images, HTML, CSV, or Markdown for search, analysis, or reuse
|
• Legacy system integration, document migration, and cross-platform sharing
|
||||||
|
• Archive standardization, publishing preparation, and content adaptation
|
||||||
|
• Accessibility compliance and mobile-friendly document preparation
|
||||||
|
|
||||||
|
Business applications:
|
||||||
|
• Enterprise content management, digital publishing, and educational platforms
|
||||||
|
• Legal document processing, healthcare interoperability, and government standardization
|
||||||
|
|
||||||
|
Integration scenarios:
|
||||||
|
• API-driven pipelines, automated workflow preparation, and batch conversions
|
||||||
|
• Real-time format adaptation for user requests
|
||||||
|
|
||||||
|
Target users: System integrators, content managers, digital archivists, and
|
||||||
|
organizations requiring flexible document format interoperability.
|
||||||
""")
|
""")
|
||||||
public @interface ConvertApi {}
|
public @interface ConvertApi {}
|
||||||
|
|||||||
@@ -22,13 +22,25 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
name = "Filter",
|
name = "Filter",
|
||||||
description =
|
description =
|
||||||
"""
|
"""
|
||||||
Check basic properties of PDFs before you process them: page count, file size, page size/rotation, and whether they contain text or images.
|
Document content filtering and search operations for information discovery and organization.
|
||||||
Use these endpoints as a "pre-check" step to decide what to do with a file next.
|
|
||||||
|
|
||||||
Typical uses:
|
This endpoint group enables intelligent content discovery and organization within
|
||||||
• Reject files that are too big or too small
|
document collections for content-based processing and information extraction.
|
||||||
• Detect image-only PDFs that should go through OCR
|
|
||||||
• Ensure a document has enough pages before it enters a workflow
|
Common use cases:
|
||||||
• Check orientation of pages before printing or merging
|
• Legal discovery, research organization, and compliance auditing
|
||||||
|
• Content moderation, academic research, and business intelligence
|
||||||
|
• Quality assurance and content validation workflows
|
||||||
|
|
||||||
|
Business applications:
|
||||||
|
• Contract analysis, financial review, and healthcare records organization
|
||||||
|
• Government processing, educational curation, and IP protection
|
||||||
|
|
||||||
|
Workflow scenarios:
|
||||||
|
• Large-scale processing, automated classification, and information extraction
|
||||||
|
• Document preparation for further processing or analysis
|
||||||
|
|
||||||
|
Target users: Legal professionals, researchers, compliance officers, and
|
||||||
|
organizations requiring intelligent document content discovery and organization.
|
||||||
""")
|
""")
|
||||||
public @interface FilterApi {}
|
public @interface FilterApi {}
|
||||||
|
|||||||
@@ -22,13 +22,21 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
name = "General",
|
name = "General",
|
||||||
description =
|
description =
|
||||||
"""
|
"""
|
||||||
Page-level PDF editing: split, merge, rotate, crop, rearrange, and scale pages.
|
Core PDF processing operations for fundamental document manipulation workflows.
|
||||||
These endpoints handle most daily "I opened a PDF editor just to…" type tasks.
|
|
||||||
|
|
||||||
Typical uses:
|
This endpoint group provides essential PDF functionality that forms the foundation
|
||||||
• Split a large PDF into smaller files (by pages, chapters, or size)
|
of most document processing workflows across various industries.
|
||||||
• Merge several PDFs into one report or pack
|
|
||||||
• Rotate or reorder pages before sending or archiving
|
Common use cases:
|
||||||
• Turn a multi-page document into one long scrolling page
|
• Document preparation for archival systems and content organization
|
||||||
|
• File preparation for distribution, accessibility compliance, and batch processing
|
||||||
|
• Document consolidation for reporting and legal compliance workflows
|
||||||
|
|
||||||
|
Typical applications:
|
||||||
|
• Content management, publishing workflows, and educational content distribution
|
||||||
|
• Business process automation and archive management
|
||||||
|
|
||||||
|
Target users: Content managers, document processors, and organizations requiring
|
||||||
|
reliable foundational PDF manipulation capabilities.
|
||||||
""")
|
""")
|
||||||
public @interface GeneralApi {}
|
public @interface GeneralApi {}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package stirling.software.common.annotations.api;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Combined annotation for Invite management controllers.
|
|
||||||
* Includes @RestController, @RequestMapping("/api/v1/invite"), and OpenAPI @Tag.
|
|
||||||
*/
|
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/v1/invite")
|
|
||||||
@Tag(
|
|
||||||
name = "Invite",
|
|
||||||
description =
|
|
||||||
"""
|
|
||||||
Invite-link generation and acceptance endpoints for onboarding new users.
|
|
||||||
|
|
||||||
Provides the ability to issue invitation tokens, send optional email invites,
|
|
||||||
validate and accept invite links, and manage pending invitations for teams.
|
|
||||||
|
|
||||||
Typical use cases include:
|
|
||||||
• Admin workflows for issuing time-limited invitations to external users
|
|
||||||
• Self-service invite acceptance and team assignment
|
|
||||||
• License limit enforcement when provisioning new accounts
|
|
||||||
|
|
||||||
Target users: administrators and automation scripts orchestrating user onboarding.
|
|
||||||
""")
|
|
||||||
public @interface InviteApi {}
|
|
||||||
@@ -22,15 +22,25 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
name = "Misc",
|
name = "Misc",
|
||||||
description =
|
description =
|
||||||
"""
|
"""
|
||||||
Tools that don't fit neatly elsewhere: OCR, compress, repair, flatten, extract images, update metadata, add stamps/page numbers/images, and more.
|
Specialized utilities and supplementary tools for enhanced document processing workflows.
|
||||||
These endpoints help fix problem PDFs and prepare them for sharing, storage, or further processing.
|
|
||||||
|
|
||||||
Typical uses:
|
This endpoint group provides utility operations that support core document processing
|
||||||
• Repair a damaged PDF or remove blank pages
|
tasks and address specific workflow needs in real-world scenarios.
|
||||||
• Run OCR on scanned PDFs so they become searchable
|
|
||||||
• Compress large PDFs for email or web download
|
Common use cases:
|
||||||
• Extract embedded images or scans
|
• Document optimization for bandwidth-limited environments and storage cost management
|
||||||
• Add page numbers, stamps, or overlay an image (e.g. logo, seal)
|
• Document repair, content extraction, and validation for quality assurance
|
||||||
• Update PDF metadata (title, author, etc.)
|
• Accessibility improvement and custom processing for specialized needs
|
||||||
|
|
||||||
|
Business applications:
|
||||||
|
• Web publishing optimization, email attachment management, and archive efficiency
|
||||||
|
• Mobile compatibility, print production, and legacy document recovery
|
||||||
|
|
||||||
|
Operational scenarios:
|
||||||
|
• Batch processing, quality control, and performance optimization
|
||||||
|
• Troubleshooting and recovery of problematic documents
|
||||||
|
|
||||||
|
Target users: System administrators, document specialists, and organizations requiring
|
||||||
|
specialized document processing and optimization tools.
|
||||||
""")
|
""")
|
||||||
public @interface MiscApi {}
|
public @interface MiscApi {}
|
||||||
|
|||||||
@@ -22,12 +22,25 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
name = "Pipeline",
|
name = "Pipeline",
|
||||||
description =
|
description =
|
||||||
"""
|
"""
|
||||||
Run several PDF operations in one configured pipeline instead of calling multiple endpoints yourself.
|
Automated document processing workflows for complex multi-stage business operations.
|
||||||
Useful when you always do the same steps in sequence (for example: convert → OCR → compress → watermark).
|
|
||||||
|
|
||||||
Typical uses:
|
This endpoint group enables organizations to create sophisticated document processing
|
||||||
• Process incoming invoices in one go (clean, OCR, compress, stamp, etc.)
|
workflows that combine multiple operations into streamlined, repeatable processes.
|
||||||
• Normalise documents before they enter an archive
|
|
||||||
• Wrap a complex document flow behind a single API call for your own apps
|
Common use cases:
|
||||||
|
• Invoice processing, legal document review, and healthcare records standardization
|
||||||
|
• Government processing, educational content preparation, and publishing automation
|
||||||
|
• Contract lifecycle management and approval processes
|
||||||
|
|
||||||
|
Business applications:
|
||||||
|
• Automated compliance reporting, large-scale migration, and quality assurance
|
||||||
|
• Archive preparation, content delivery, and document approval workflows
|
||||||
|
|
||||||
|
Operational scenarios:
|
||||||
|
• Scheduled batch processing and event-driven document processing
|
||||||
|
• Multi-department coordination and business system integration
|
||||||
|
|
||||||
|
Target users: Business process managers, IT automation specialists, and organizations
|
||||||
|
requiring consistent, repeatable document processing workflows.
|
||||||
""")
|
""")
|
||||||
public @interface PipelineApi {}
|
public @interface PipelineApi {}
|
||||||
|
|||||||
@@ -22,13 +22,25 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
name = "Security",
|
name = "Security",
|
||||||
description =
|
description =
|
||||||
"""
|
"""
|
||||||
Protect and clean PDFs: passwords, digital signatures, redaction, and sanitizing.
|
Document security and protection services for confidential and sensitive content.
|
||||||
These endpoints help you control who can open a file, what they can do with it, and remove sensitive content when needed.
|
|
||||||
|
|
||||||
Typical uses:
|
This endpoint group provides essential security operations for organizations handling
|
||||||
• Add or remove a password on a PDF
|
sensitive documents and materials requiring controlled access.
|
||||||
• Redact personal or confidential information (manually or automatically)
|
|
||||||
• Validate or remove digital signatures
|
Common use cases:
|
||||||
• Sanitize a PDF to strip scripts and embedded content
|
• Legal confidentiality, healthcare privacy (HIPAA), and financial regulatory compliance
|
||||||
|
• Government classified handling, corporate IP protection, and educational privacy (FERPA)
|
||||||
|
• Contract security for business transactions
|
||||||
|
|
||||||
|
Business applications:
|
||||||
|
• Document authentication, confidential sharing, and secure archiving
|
||||||
|
• Content watermarking, access control, and privacy protection through redaction
|
||||||
|
|
||||||
|
Industry scenarios:
|
||||||
|
• Legal discovery, medical records exchange, financial audit documentation
|
||||||
|
• Enterprise policy enforcement and data governance
|
||||||
|
|
||||||
|
Target users: Legal professionals, healthcare administrators, compliance officers,
|
||||||
|
government agencies, and enterprises handling sensitive content.
|
||||||
""")
|
""")
|
||||||
public @interface SecurityApi {}
|
public @interface SecurityApi {}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
|
|
||||||
import stirling.software.common.annotations.AutoJobPostMapping;
|
import stirling.software.common.annotations.AutoJobPostMapping;
|
||||||
import stirling.software.common.model.api.PDFFile;
|
import stirling.software.common.model.api.PDFFile;
|
||||||
|
import stirling.software.common.service.FileOrUploadService;
|
||||||
import stirling.software.common.service.FileStorage;
|
import stirling.software.common.service.FileStorage;
|
||||||
import stirling.software.common.service.JobExecutorService;
|
import stirling.software.common.service.JobExecutorService;
|
||||||
|
|
||||||
@@ -33,11 +34,12 @@ public class AutoJobAspect {
|
|||||||
|
|
||||||
private final JobExecutorService jobExecutorService;
|
private final JobExecutorService jobExecutorService;
|
||||||
private final HttpServletRequest request;
|
private final HttpServletRequest request;
|
||||||
|
private final FileOrUploadService fileOrUploadService;
|
||||||
private final FileStorage fileStorage;
|
private final FileStorage fileStorage;
|
||||||
|
|
||||||
@Around("@annotation(autoJobPostMapping)")
|
@Around("@annotation(autoJobPostMapping)")
|
||||||
public Object wrapWithJobExecution(
|
public Object wrapWithJobExecution(
|
||||||
ProceedingJoinPoint joinPoint, AutoJobPostMapping autoJobPostMapping) throws Exception {
|
ProceedingJoinPoint joinPoint, AutoJobPostMapping autoJobPostMapping) {
|
||||||
// This aspect will run before any audit aspects due to @Order(0)
|
// This aspect will run before any audit aspects due to @Order(0)
|
||||||
// Extract parameters from the request and annotation
|
// Extract parameters from the request and annotation
|
||||||
boolean async = Boolean.parseBoolean(request.getParameter("async"));
|
boolean async = Boolean.parseBoolean(request.getParameter("async"));
|
||||||
@@ -51,8 +53,7 @@ public class AutoJobAspect {
|
|||||||
boolean trackProgress = autoJobPostMapping.trackProgress();
|
boolean trackProgress = autoJobPostMapping.trackProgress();
|
||||||
|
|
||||||
log.debug(
|
log.debug(
|
||||||
"AutoJobPostMapping execution with async={}, timeout={}, retryCount={},"
|
"AutoJobPostMapping execution with async={}, timeout={}, retryCount={}, trackProgress={}",
|
||||||
+ " trackProgress={}",
|
|
||||||
async,
|
async,
|
||||||
timeout > 0 ? timeout : "default",
|
timeout > 0 ? timeout : "default",
|
||||||
retryCount,
|
retryCount,
|
||||||
@@ -81,18 +82,13 @@ public class AutoJobAspect {
|
|||||||
"AutoJobAspect caught exception during job execution: {}",
|
"AutoJobAspect caught exception during job execution: {}",
|
||||||
ex.getMessage(),
|
ex.getMessage(),
|
||||||
ex);
|
ex);
|
||||||
// Rethrow RuntimeException as-is to preserve exception type
|
|
||||||
if (ex instanceof RuntimeException) {
|
|
||||||
throw (RuntimeException) ex;
|
|
||||||
}
|
|
||||||
// Wrap checked exceptions - GlobalExceptionHandler will unwrap
|
|
||||||
// BaseAppException
|
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeout,
|
timeout,
|
||||||
queueable,
|
queueable,
|
||||||
resourceWeight);
|
resourceWeight,
|
||||||
|
trackProgress);
|
||||||
} else {
|
} else {
|
||||||
// Use retry logic
|
// Use retry logic
|
||||||
return executeWithRetries(
|
return executeWithRetries(
|
||||||
@@ -115,8 +111,7 @@ public class AutoJobAspect {
|
|||||||
int maxRetries,
|
int maxRetries,
|
||||||
boolean trackProgress,
|
boolean trackProgress,
|
||||||
boolean queueable,
|
boolean queueable,
|
||||||
int resourceWeight)
|
int resourceWeight) {
|
||||||
throws Exception {
|
|
||||||
|
|
||||||
// Keep jobId reference for progress tracking in TaskManager
|
// Keep jobId reference for progress tracking in TaskManager
|
||||||
AtomicReference<String> jobIdRef = new AtomicReference<>();
|
AtomicReference<String> jobIdRef = new AtomicReference<>();
|
||||||
@@ -154,8 +149,7 @@ public class AutoJobAspect {
|
|||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
lastException = ex;
|
lastException = ex;
|
||||||
log.error(
|
log.error(
|
||||||
"AutoJobAspect caught exception during job execution (attempt"
|
"AutoJobAspect caught exception during job execution (attempt {}/{}): {}",
|
||||||
+ " {}/{}): {}",
|
|
||||||
currentAttempt,
|
currentAttempt,
|
||||||
maxRetries,
|
maxRetries,
|
||||||
ex.getMessage(),
|
ex.getMessage(),
|
||||||
@@ -214,12 +208,6 @@ public class AutoJobAspect {
|
|||||||
|
|
||||||
// If we get here, all retries failed
|
// If we get here, all retries failed
|
||||||
if (lastException != null) {
|
if (lastException != null) {
|
||||||
// Rethrow RuntimeException as-is to preserve exception type
|
|
||||||
if (lastException instanceof RuntimeException) {
|
|
||||||
throw (RuntimeException) lastException;
|
|
||||||
}
|
|
||||||
// Wrap checked exceptions - GlobalExceptionHandler will unwrap
|
|
||||||
// BaseAppException
|
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"Job failed after "
|
"Job failed after "
|
||||||
+ maxRetries
|
+ maxRetries
|
||||||
@@ -233,7 +221,8 @@ public class AutoJobAspect {
|
|||||||
},
|
},
|
||||||
timeout,
|
timeout,
|
||||||
queueable,
|
queueable,
|
||||||
resourceWeight);
|
resourceWeight,
|
||||||
|
trackProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ public class AppConfig {
|
|||||||
|
|
||||||
private final ApplicationProperties applicationProperties;
|
private final ApplicationProperties applicationProperties;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Value("${baseUrl:http://localhost}")
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Value("${server.servlet.context-path:/}")
|
@Value("${server.servlet.context-path:/}")
|
||||||
private String contextPath;
|
private String contextPath;
|
||||||
@@ -45,17 +49,6 @@ public class AppConfig {
|
|||||||
@Value("${server.port:8080}")
|
@Value("${server.port:8080}")
|
||||||
private String serverPort;
|
private String serverPort;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the backend URL from system configuration. Falls back to http://localhost if not
|
|
||||||
* configured.
|
|
||||||
*
|
|
||||||
* @return The backend base URL for SAML/OAuth/API callbacks
|
|
||||||
*/
|
|
||||||
public String getBackendUrl() {
|
|
||||||
String backendUrl = applicationProperties.getSystem().getBackendUrl();
|
|
||||||
return (backendUrl != null && !backendUrl.isBlank()) ? backendUrl : "http://localhost";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Value("${v2}")
|
@Value("${v2}")
|
||||||
public boolean v2Enabled;
|
public boolean v2Enabled;
|
||||||
|
|
||||||
@@ -64,14 +57,25 @@ public class AppConfig {
|
|||||||
return v2Enabled;
|
return v2Enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Commented out Thymeleaf template engine bean - to be removed when frontend migration is complete
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(name = "system.customHTMLFiles", havingValue = "true")
|
||||||
|
public SpringTemplateEngine templateEngine(ResourceLoader resourceLoader) {
|
||||||
|
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
|
||||||
|
templateEngine.addTemplateResolver(new FileFallbackTemplateResolver(resourceLoader));
|
||||||
|
return templateEngine;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@Bean(name = "loginEnabled")
|
@Bean(name = "loginEnabled")
|
||||||
public boolean loginEnabled() {
|
public boolean loginEnabled() {
|
||||||
return applicationProperties.getSecurity().isEnableLogin();
|
return applicationProperties.getSecurity().getEnableLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "appName")
|
@Bean(name = "appName")
|
||||||
public String appName() {
|
public String appName() {
|
||||||
return "Stirling PDF";
|
String homeTitle = applicationProperties.getUi().getAppName();
|
||||||
|
return (homeTitle != null) ? homeTitle : "Stirling PDF";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "appVersion")
|
@Bean(name = "appVersion")
|
||||||
@@ -89,7 +93,9 @@ public class AppConfig {
|
|||||||
|
|
||||||
@Bean(name = "homeText")
|
@Bean(name = "homeText")
|
||||||
public String homeText() {
|
public String homeText() {
|
||||||
return "null";
|
return (applicationProperties.getUi().getHomeDescription() != null)
|
||||||
|
? applicationProperties.getUi().getHomeDescription()
|
||||||
|
: "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "languages")
|
@Bean(name = "languages")
|
||||||
@@ -104,13 +110,18 @@ public class AppConfig {
|
|||||||
|
|
||||||
@Bean(name = "navBarText")
|
@Bean(name = "navBarText")
|
||||||
public String navBarText() {
|
public String navBarText() {
|
||||||
String navBar = applicationProperties.getUi().getAppNameNavbar();
|
String defaultNavBar =
|
||||||
return (navBar != null) ? navBar : "Stirling PDF";
|
applicationProperties.getUi().getAppNameNavbar() != null
|
||||||
|
? applicationProperties.getUi().getAppNameNavbar()
|
||||||
|
: applicationProperties.getUi().getAppName();
|
||||||
|
return (defaultNavBar != null) ? defaultNavBar : "Stirling PDF";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "enableAlphaFunctionality")
|
@Bean(name = "enableAlphaFunctionality")
|
||||||
public boolean enableAlphaFunctionality() {
|
public boolean enableAlphaFunctionality() {
|
||||||
return applicationProperties.getSystem().isEnableAlphaFunctionality();
|
return applicationProperties.getSystem().getEnableAlphaFunctionality() != null
|
||||||
|
? applicationProperties.getSystem().getEnableAlphaFunctionality()
|
||||||
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "rateLimit")
|
@Bean(name = "rateLimit")
|
||||||
@@ -253,14 +264,9 @@ public class AppConfig {
|
|||||||
return "NORMAL";
|
return "NORMAL";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "scarfEnabled")
|
@Bean(name = "disablePixel")
|
||||||
public boolean scarfEnabled() {
|
public boolean disablePixel() {
|
||||||
return applicationProperties.getSystem().isScarfEnabled();
|
return Boolean.parseBoolean(env.getProperty("DISABLE_PIXEL", "false"));
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(name = "posthogEnabled")
|
|
||||||
public boolean posthogEnabled() {
|
|
||||||
return applicationProperties.getSystem().isPosthogEnabled();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "machineType")
|
@Bean(name = "machineType")
|
||||||
|
|||||||
+1
-21
@@ -23,30 +23,10 @@ import stirling.software.common.util.YamlHelper;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ConfigInitializer {
|
public class ConfigInitializer {
|
||||||
|
|
||||||
private static final int MIN_SETTINGS_FILE_LINES = 31;
|
|
||||||
|
|
||||||
public void ensureConfigExists() throws IOException, URISyntaxException {
|
public void ensureConfigExists() throws IOException, URISyntaxException {
|
||||||
// 1) If settings file doesn't exist, create from template
|
// 1) If settings file doesn't exist, create from template
|
||||||
Path destPath = Paths.get(InstallationPathConfig.getSettingsPath());
|
Path destPath = Paths.get(InstallationPathConfig.getSettingsPath());
|
||||||
|
if (Files.notExists(destPath)) {
|
||||||
boolean settingsFileExists = Files.exists(destPath);
|
|
||||||
|
|
||||||
long lineCount = settingsFileExists ? Files.readAllLines(destPath).size() : 0;
|
|
||||||
|
|
||||||
log.info("Current settings file line count: {}", lineCount);
|
|
||||||
|
|
||||||
if (!settingsFileExists || lineCount < MIN_SETTINGS_FILE_LINES) {
|
|
||||||
if (settingsFileExists) {
|
|
||||||
// move settings.yml to settings.yml.{timestamp}.bak
|
|
||||||
Path backupPath =
|
|
||||||
Paths.get(
|
|
||||||
InstallationPathConfig.getSettingsPath()
|
|
||||||
+ "."
|
|
||||||
+ System.currentTimeMillis()
|
|
||||||
+ ".bak");
|
|
||||||
Files.move(destPath, backupPath, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
log.info("Moved existing settings file to backup: {}", backupPath);
|
|
||||||
}
|
|
||||||
Files.createDirectories(destPath.getParent());
|
Files.createDirectories(destPath.getParent());
|
||||||
try (InputStream in =
|
try (InputStream in =
|
||||||
getClass().getClassLoader().getResourceAsStream("settings.yml.template")) {
|
getClass().getClassLoader().getResourceAsStream("settings.yml.template")) {
|
||||||
|
|||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package stirling.software.common.configuration;
|
||||||
|
|
||||||
|
/* Commented out entire FileFallbackTemplateResolver class - Thymeleaf dependency removed
|
||||||
|
* This class will be removed when frontend migration to React is complete
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class FileFallbackTemplateResolver extends AbstractConfigurableTemplateResolver {
|
||||||
|
|
||||||
|
private final ResourceLoader resourceLoader;
|
||||||
|
|
||||||
|
public FileFallbackTemplateResolver(ResourceLoader resourceLoader) {
|
||||||
|
super();
|
||||||
|
this.resourceLoader = resourceLoader;
|
||||||
|
setSuffix(".html");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note this does not work in local IDE, Prod jar only.
|
||||||
|
@Override
|
||||||
|
protected ITemplateResource computeTemplateResource(
|
||||||
|
IEngineConfiguration configuration,
|
||||||
|
String ownerTemplate,
|
||||||
|
String template,
|
||||||
|
String resourceName,
|
||||||
|
String characterEncoding,
|
||||||
|
Map<String, Object> templateResolutionAttributes) {
|
||||||
|
Resource resource =
|
||||||
|
resourceLoader.getResource(
|
||||||
|
"file:" + InstallationPathConfig.getTemplatesPath() + resourceName);
|
||||||
|
try {
|
||||||
|
if (resource.exists() && resource.isReadable()) {
|
||||||
|
return new FileTemplateResource(resource.getFile().getPath(), characterEncoding);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Log the exception to help with debugging issues loading external templates
|
||||||
|
log.warn("Unable to read template '{}' from file system", resourceName, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputStream inputStream =
|
||||||
|
Thread.currentThread()
|
||||||
|
.getContextClassLoader()
|
||||||
|
.getResourceAsStream("templates/" + resourceName);
|
||||||
|
if (inputStream != null) {
|
||||||
|
return new InputStreamTemplateResource(inputStream, "UTF-8");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
+25
-16
@@ -1,6 +1,7 @@
|
|||||||
package stirling.software.common.configuration;
|
package stirling.software.common.configuration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@@ -13,17 +14,12 @@ public class InstallationPathConfig {
|
|||||||
private static final String CONFIG_PATH;
|
private static final String CONFIG_PATH;
|
||||||
private static final String CUSTOM_FILES_PATH;
|
private static final String CUSTOM_FILES_PATH;
|
||||||
private static final String CLIENT_WEBUI_PATH;
|
private static final String CLIENT_WEBUI_PATH;
|
||||||
|
private static final String SCRIPTS_PATH;
|
||||||
private static final String PIPELINE_PATH;
|
private static final String PIPELINE_PATH;
|
||||||
|
|
||||||
// Config paths
|
// Config paths
|
||||||
private static final String SETTINGS_PATH;
|
private static final String SETTINGS_PATH;
|
||||||
private static final String CUSTOM_SETTINGS_PATH;
|
private static final String CUSTOM_SETTINGS_PATH;
|
||||||
private static final String SCRIPTS_PATH;
|
|
||||||
private static final String BACKUP_PATH;
|
|
||||||
|
|
||||||
// Backup paths
|
|
||||||
private static final String BACKUP_DB_PATH;
|
|
||||||
private static final String BACKUP_PRIVATE_KEY_PATH;
|
|
||||||
|
|
||||||
// Custom file paths
|
// Custom file paths
|
||||||
private static final String STATIC_PATH;
|
private static final String STATIC_PATH;
|
||||||
@@ -45,11 +41,6 @@ public class InstallationPathConfig {
|
|||||||
SETTINGS_PATH = CONFIG_PATH + "settings.yml";
|
SETTINGS_PATH = CONFIG_PATH + "settings.yml";
|
||||||
CUSTOM_SETTINGS_PATH = CONFIG_PATH + "custom_settings.yml";
|
CUSTOM_SETTINGS_PATH = CONFIG_PATH + "custom_settings.yml";
|
||||||
SCRIPTS_PATH = CONFIG_PATH + "scripts" + File.separator;
|
SCRIPTS_PATH = CONFIG_PATH + "scripts" + File.separator;
|
||||||
BACKUP_PATH = CONFIG_PATH + "backup" + File.separator;
|
|
||||||
|
|
||||||
// Initialize backup paths
|
|
||||||
BACKUP_DB_PATH = BACKUP_PATH + "db" + File.separator;
|
|
||||||
BACKUP_PRIVATE_KEY_PATH = BACKUP_PATH + "keys" + File.separator;
|
|
||||||
|
|
||||||
// Initialize custom file paths
|
// Initialize custom file paths
|
||||||
STATIC_PATH = CUSTOM_FILES_PATH + "static" + File.separator;
|
STATIC_PATH = CUSTOM_FILES_PATH + "static" + File.separator;
|
||||||
@@ -59,6 +50,28 @@ public class InstallationPathConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String initializeBasePath() {
|
private static String initializeBasePath() {
|
||||||
|
if (Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))) {
|
||||||
|
String os = System.getProperty("os.name").toLowerCase();
|
||||||
|
if (os.contains("win")) {
|
||||||
|
return Paths.get(
|
||||||
|
System.getenv("APPDATA"), // parent path
|
||||||
|
"Stirling-PDF")
|
||||||
|
+ File.separator;
|
||||||
|
} else if (os.contains("mac")) {
|
||||||
|
return Paths.get(
|
||||||
|
System.getProperty("user.home"),
|
||||||
|
"Library",
|
||||||
|
"Application Support",
|
||||||
|
"Stirling-PDF")
|
||||||
|
+ File.separator;
|
||||||
|
} else {
|
||||||
|
return Paths.get(
|
||||||
|
System.getProperty("user.home"), // parent path
|
||||||
|
".config",
|
||||||
|
"Stirling-PDF")
|
||||||
|
+ File.separator;
|
||||||
|
}
|
||||||
|
}
|
||||||
return "." + File.separator;
|
return "." + File.separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,10 +124,6 @@ public class InstallationPathConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getPrivateKeyPath() {
|
public static String getPrivateKeyPath() {
|
||||||
return BACKUP_PRIVATE_KEY_PATH;
|
return PRIVATE_KEY_PATH;
|
||||||
}
|
|
||||||
|
|
||||||
public static String getBackupPath() {
|
|
||||||
return BACKUP_DB_PATH;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-123
@@ -2,9 +2,6 @@ package stirling.software.common.configuration;
|
|||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -13,12 +10,8 @@ import lombok.Getter;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import stirling.software.common.model.ApplicationProperties;
|
import stirling.software.common.model.ApplicationProperties;
|
||||||
import stirling.software.common.model.ApplicationProperties.CustomPaths;
|
|
||||||
import stirling.software.common.model.ApplicationProperties.CustomPaths.Operations;
|
import stirling.software.common.model.ApplicationProperties.CustomPaths.Operations;
|
||||||
import stirling.software.common.model.ApplicationProperties.CustomPaths.Pipeline;
|
import stirling.software.common.model.ApplicationProperties.CustomPaths.Pipeline;
|
||||||
import stirling.software.common.model.ApplicationProperties.System;
|
|
||||||
import stirling.software.common.util.ProcessExecutor;
|
|
||||||
import stirling.software.common.util.UnoServerPool;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
@@ -26,18 +19,8 @@ import stirling.software.common.util.UnoServerPool;
|
|||||||
public class RuntimePathConfig {
|
public class RuntimePathConfig {
|
||||||
private final ApplicationProperties properties;
|
private final ApplicationProperties properties;
|
||||||
private final String basePath;
|
private final String basePath;
|
||||||
|
|
||||||
// Operation paths
|
|
||||||
private final String weasyPrintPath;
|
private final String weasyPrintPath;
|
||||||
private final String unoConvertPath;
|
private final String unoConvertPath;
|
||||||
private final String calibrePath;
|
|
||||||
private final String ocrMyPdfPath;
|
|
||||||
private final String sOfficePath;
|
|
||||||
|
|
||||||
// Tesseract data path
|
|
||||||
private final String tessDataPath;
|
|
||||||
|
|
||||||
private final List<ApplicationProperties.ProcessExecutor.UnoServerEndpoint> unoServerEndpoints;
|
|
||||||
|
|
||||||
// Pipeline paths
|
// Pipeline paths
|
||||||
private final String pipelineWatchedFoldersPath;
|
private final String pipelineWatchedFoldersPath;
|
||||||
@@ -54,10 +37,7 @@ public class RuntimePathConfig {
|
|||||||
String defaultFinishedFolders = Path.of(this.pipelinePath, "finishedFolders").toString();
|
String defaultFinishedFolders = Path.of(this.pipelinePath, "finishedFolders").toString();
|
||||||
String defaultWebUIConfigs = Path.of(this.pipelinePath, "defaultWebUIConfigs").toString();
|
String defaultWebUIConfigs = Path.of(this.pipelinePath, "defaultWebUIConfigs").toString();
|
||||||
|
|
||||||
System system = properties.getSystem();
|
Pipeline pipeline = properties.getSystem().getCustomPaths().getPipeline();
|
||||||
CustomPaths customPaths = system.getCustomPaths();
|
|
||||||
|
|
||||||
Pipeline pipeline = customPaths.getPipeline();
|
|
||||||
|
|
||||||
this.pipelineWatchedFoldersPath =
|
this.pipelineWatchedFoldersPath =
|
||||||
resolvePath(
|
resolvePath(
|
||||||
@@ -77,11 +57,8 @@ public class RuntimePathConfig {
|
|||||||
// Initialize Operation paths
|
// Initialize Operation paths
|
||||||
String defaultWeasyPrintPath = isDocker ? "/opt/venv/bin/weasyprint" : "weasyprint";
|
String defaultWeasyPrintPath = isDocker ? "/opt/venv/bin/weasyprint" : "weasyprint";
|
||||||
String defaultUnoConvertPath = isDocker ? "/opt/venv/bin/unoconvert" : "unoconvert";
|
String defaultUnoConvertPath = isDocker ? "/opt/venv/bin/unoconvert" : "unoconvert";
|
||||||
String defaultCalibrePath = isDocker ? "/opt/calibre/ebook-convert" : "ebook-convert";
|
|
||||||
String defaultOcrMyPdfPath = isDocker ? "/usr/bin/ocrmypdf" : "ocrmypdf";
|
|
||||||
String defaultSOfficePath = isDocker ? "/usr/bin/soffice" : "soffice";
|
|
||||||
|
|
||||||
Operations operations = customPaths.getOperations();
|
Operations operations = properties.getSystem().getCustomPaths().getOperations();
|
||||||
this.weasyPrintPath =
|
this.weasyPrintPath =
|
||||||
resolvePath(
|
resolvePath(
|
||||||
defaultWeasyPrintPath,
|
defaultWeasyPrintPath,
|
||||||
@@ -90,39 +67,6 @@ public class RuntimePathConfig {
|
|||||||
resolvePath(
|
resolvePath(
|
||||||
defaultUnoConvertPath,
|
defaultUnoConvertPath,
|
||||||
operations != null ? operations.getUnoconvert() : null);
|
operations != null ? operations.getUnoconvert() : null);
|
||||||
this.calibrePath =
|
|
||||||
resolvePath(
|
|
||||||
defaultCalibrePath, operations != null ? operations.getCalibre() : null);
|
|
||||||
this.ocrMyPdfPath =
|
|
||||||
resolvePath(
|
|
||||||
defaultOcrMyPdfPath, operations != null ? operations.getOcrmypdf() : null);
|
|
||||||
this.sOfficePath =
|
|
||||||
resolvePath(
|
|
||||||
defaultSOfficePath, operations != null ? operations.getSoffice() : null);
|
|
||||||
|
|
||||||
// Initialize Tesseract data path
|
|
||||||
// Priority: config setting > TESSDATA_PREFIX env var > default path
|
|
||||||
String tessPath = system.getTessdataDir();
|
|
||||||
String tessdataPrefix = java.lang.System.getenv("TESSDATA_PREFIX");
|
|
||||||
String defaultPath = "/usr/share/tesseract-ocr/5/tessdata";
|
|
||||||
|
|
||||||
if (tessPath != null && !tessPath.isEmpty()) {
|
|
||||||
this.tessDataPath = tessPath;
|
|
||||||
} else if (tessdataPrefix != null && !tessdataPrefix.isEmpty()) {
|
|
||||||
this.tessDataPath = tessdataPrefix;
|
|
||||||
} else {
|
|
||||||
this.tessDataPath = defaultPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("Using Tesseract data path: {}", this.tessDataPath);
|
|
||||||
|
|
||||||
ApplicationProperties.ProcessExecutor processExecutor = properties.getProcessExecutor();
|
|
||||||
int libreOfficeLimit = 1;
|
|
||||||
if (processExecutor != null && processExecutor.getSessionLimit() != null) {
|
|
||||||
libreOfficeLimit = processExecutor.getSessionLimit().getLibreOfficeSessionLimit();
|
|
||||||
}
|
|
||||||
this.unoServerEndpoints = buildUnoServerEndpoints(processExecutor, libreOfficeLimit);
|
|
||||||
ProcessExecutor.setUnoServerPool(new UnoServerPool(this.unoServerEndpoints));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolvePath(String defaultPath, String customPath) {
|
private String resolvePath(String defaultPath, String customPath) {
|
||||||
@@ -132,69 +76,4 @@ public class RuntimePathConfig {
|
|||||||
private boolean isRunningInDocker() {
|
private boolean isRunningInDocker() {
|
||||||
return Files.exists(Path.of("/.dockerenv"));
|
return Files.exists(Path.of("/.dockerenv"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ApplicationProperties.ProcessExecutor.UnoServerEndpoint> buildUnoServerEndpoints(
|
|
||||||
ApplicationProperties.ProcessExecutor processExecutor, int sessionLimit) {
|
|
||||||
if (processExecutor == null) {
|
|
||||||
log.warn("ProcessExecutor config missing; defaulting to a single UNO endpoint.");
|
|
||||||
return Collections.singletonList(
|
|
||||||
new ApplicationProperties.ProcessExecutor.UnoServerEndpoint());
|
|
||||||
}
|
|
||||||
if (!processExecutor.isAutoUnoServer()) {
|
|
||||||
List<ApplicationProperties.ProcessExecutor.UnoServerEndpoint> configured =
|
|
||||||
sanitizeUnoServerEndpoints(processExecutor.getUnoServerEndpoints());
|
|
||||||
if (!configured.isEmpty()) {
|
|
||||||
// Warn if manual endpoint count doesn't match sessionLimit
|
|
||||||
if (configured.size() != sessionLimit) {
|
|
||||||
log.warn(
|
|
||||||
"Manual UNO endpoint count ({}) differs from libreOfficeSessionLimit ({}). "
|
|
||||||
+ "Concurrency will be limited by endpoint count, not sessionLimit.",
|
|
||||||
configured.size(),
|
|
||||||
sessionLimit);
|
|
||||||
}
|
|
||||||
return configured;
|
|
||||||
}
|
|
||||||
log.warn(
|
|
||||||
"autoUnoServer disabled but no unoServerEndpoints configured; defaulting to 127.0.0.1:2003.");
|
|
||||||
return Collections.singletonList(
|
|
||||||
new ApplicationProperties.ProcessExecutor.UnoServerEndpoint());
|
|
||||||
}
|
|
||||||
int count = sessionLimit > 0 ? sessionLimit : 1;
|
|
||||||
return buildAutoUnoServerEndpoints(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ApplicationProperties.ProcessExecutor.UnoServerEndpoint>
|
|
||||||
buildAutoUnoServerEndpoints(int count) {
|
|
||||||
List<ApplicationProperties.ProcessExecutor.UnoServerEndpoint> endpoints = new ArrayList<>();
|
|
||||||
int basePort = 2003;
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
ApplicationProperties.ProcessExecutor.UnoServerEndpoint endpoint =
|
|
||||||
new ApplicationProperties.ProcessExecutor.UnoServerEndpoint();
|
|
||||||
endpoint.setHost("127.0.0.1");
|
|
||||||
endpoint.setPort(basePort + (i * 2));
|
|
||||||
endpoints.add(endpoint);
|
|
||||||
}
|
|
||||||
return endpoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ApplicationProperties.ProcessExecutor.UnoServerEndpoint>
|
|
||||||
sanitizeUnoServerEndpoints(
|
|
||||||
List<ApplicationProperties.ProcessExecutor.UnoServerEndpoint> endpoints) {
|
|
||||||
if (endpoints == null || endpoints.isEmpty()) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
List<ApplicationProperties.ProcessExecutor.UnoServerEndpoint> sanitized = new ArrayList<>();
|
|
||||||
for (ApplicationProperties.ProcessExecutor.UnoServerEndpoint endpoint : endpoints) {
|
|
||||||
if (endpoint == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String host = endpoint.getHost();
|
|
||||||
int port = endpoint.getPort();
|
|
||||||
if (host == null || host.isBlank() || port <= 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
sanitized.add(endpoint);
|
|
||||||
}
|
|
||||||
return sanitized;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package stirling.software.common.context;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds contextual information for the currently executing job. Backed by a {@link ThreadLocal} so
|
||||||
|
* worker threads can retrieve the job ID and progress tracking preference while processing
|
||||||
|
* asynchronous work dispatched by {@link stirling.software.common.service.JobExecutorService
|
||||||
|
* JobExecutorService}.
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
|
public final class JobContextHolder {
|
||||||
|
|
||||||
|
private static final ThreadLocal<String> JOB_ID = new ThreadLocal<>();
|
||||||
|
private static final ThreadLocal<Boolean> PROGRESS_ENABLED = new ThreadLocal<>();
|
||||||
|
|
||||||
|
/** Store context for the current thread. */
|
||||||
|
public static void setContext(String jobId, boolean progressEnabled) {
|
||||||
|
if (jobId == null) {
|
||||||
|
clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JOB_ID.set(jobId);
|
||||||
|
PROGRESS_ENABLED.set(progressEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the job ID bound to the current thread, or {@code null} if none. */
|
||||||
|
public static String getJobId() {
|
||||||
|
return JOB_ID.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether progress tracking is enabled for the current job (defaults to {@code false}). */
|
||||||
|
public static boolean isProgressEnabled() {
|
||||||
|
Boolean enabled = PROGRESS_ENABLED.get();
|
||||||
|
return enabled != null && enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Remove all context associated with the current thread. */
|
||||||
|
public static void clear() {
|
||||||
|
JOB_ID.remove();
|
||||||
|
PROGRESS_ENABLED.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
-325
@@ -12,7 +12,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -42,7 +41,6 @@ import stirling.software.common.model.oauth2.GitHubProvider;
|
|||||||
import stirling.software.common.model.oauth2.GoogleProvider;
|
import stirling.software.common.model.oauth2.GoogleProvider;
|
||||||
import stirling.software.common.model.oauth2.KeycloakProvider;
|
import stirling.software.common.model.oauth2.KeycloakProvider;
|
||||||
import stirling.software.common.model.oauth2.Provider;
|
import stirling.software.common.model.oauth2.Provider;
|
||||||
import stirling.software.common.service.SsrfProtectionService.SsrfProtectionLevel;
|
|
||||||
import stirling.software.common.util.ValidationUtils;
|
import stirling.software.common.util.ValidationUtils;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -61,7 +59,6 @@ public class ApplicationProperties {
|
|||||||
private AutomaticallyGenerated automaticallyGenerated = new AutomaticallyGenerated();
|
private AutomaticallyGenerated automaticallyGenerated = new AutomaticallyGenerated();
|
||||||
|
|
||||||
private Mail mail = new Mail();
|
private Mail mail = new Mail();
|
||||||
private Telegram telegram = new Telegram();
|
|
||||||
|
|
||||||
private Premium premium = new Premium();
|
private Premium premium = new Premium();
|
||||||
|
|
||||||
@@ -70,17 +67,16 @@ public class ApplicationProperties {
|
|||||||
|
|
||||||
private AutoPipeline autoPipeline = new AutoPipeline();
|
private AutoPipeline autoPipeline = new AutoPipeline();
|
||||||
private ProcessExecutor processExecutor = new ProcessExecutor();
|
private ProcessExecutor processExecutor = new ProcessExecutor();
|
||||||
private PdfEditor pdfEditor = new PdfEditor();
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public PropertySource<?> dynamicYamlPropertySource(ConfigurableEnvironment environment)
|
public PropertySource<?> dynamicYamlPropertySource(ConfigurableEnvironment environment)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
String configPath = InstallationPathConfig.getSettingsPath();
|
String configPath = InstallationPathConfig.getSettingsPath();
|
||||||
log.debug("Attempting to load settings from: {}", configPath);
|
log.debug("Attempting to load settings from: " + configPath);
|
||||||
|
|
||||||
File file = new File(configPath);
|
File file = new File(configPath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
log.error("Warning: Settings file does not exist at: {}", configPath);
|
log.error("Warning: Settings file does not exist at: " + configPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Resource resource = new FileSystemResource(configPath);
|
Resource resource = new FileSystemResource(configPath);
|
||||||
@@ -93,7 +89,7 @@ public class ApplicationProperties {
|
|||||||
new YamlPropertySourceFactory().createPropertySource(null, encodedResource);
|
new YamlPropertySourceFactory().createPropertySource(null, encodedResource);
|
||||||
environment.getPropertySources().addFirst(propertySource);
|
environment.getPropertySources().addFirst(propertySource);
|
||||||
|
|
||||||
log.debug("Loaded properties: {}", propertySource.getSource());
|
log.debug("Loaded properties: " + propertySource.getSource());
|
||||||
|
|
||||||
return propertySource;
|
return propertySource;
|
||||||
}
|
}
|
||||||
@@ -103,46 +99,6 @@ public class ApplicationProperties {
|
|||||||
private String outputFolder;
|
private String outputFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class PdfEditor {
|
|
||||||
private Cache cache = new Cache();
|
|
||||||
private FontNormalization fontNormalization = new FontNormalization();
|
|
||||||
private CffConverter cffConverter = new CffConverter();
|
|
||||||
private Type3 type3 = new Type3();
|
|
||||||
private String fallbackFont = "classpath:/static/fonts/NotoSans-Regular.ttf";
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Cache {
|
|
||||||
private long maxBytes = -1;
|
|
||||||
private int maxPercent = 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class FontNormalization {
|
|
||||||
private boolean enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class CffConverter {
|
|
||||||
private boolean enabled = true;
|
|
||||||
private String method = "python";
|
|
||||||
private String pythonCommand = "/opt/venv/bin/python3";
|
|
||||||
private String pythonScript = "/scripts/convert_cff_to_ttf.py";
|
|
||||||
private String fontforgeCommand = "fontforge";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Type3 {
|
|
||||||
private Library library = new Library();
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Library {
|
|
||||||
private boolean enabled = true;
|
|
||||||
private String index = "classpath:/type3/library/index.json";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Legal {
|
public static class Legal {
|
||||||
private String termsAndConditions;
|
private String termsAndConditions;
|
||||||
@@ -154,7 +110,8 @@ public class ApplicationProperties {
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Security {
|
public static class Security {
|
||||||
private boolean enableLogin;
|
private Boolean enableLogin;
|
||||||
|
private Boolean csrfDisabled;
|
||||||
private InitialLogin initialLogin = new InitialLogin();
|
private InitialLogin initialLogin = new InitialLogin();
|
||||||
private OAUTH2 oauth2 = new OAUTH2();
|
private OAUTH2 oauth2 = new OAUTH2();
|
||||||
private SAML2 saml2 = new SAML2();
|
private SAML2 saml2 = new SAML2();
|
||||||
@@ -163,7 +120,6 @@ public class ApplicationProperties {
|
|||||||
private String loginMethod = "all";
|
private String loginMethod = "all";
|
||||||
private String customGlobalAPIKey;
|
private String customGlobalAPIKey;
|
||||||
private Jwt jwt = new Jwt();
|
private Jwt jwt = new Jwt();
|
||||||
private Validation validation = new Validation();
|
|
||||||
|
|
||||||
public Boolean isAltLogin() {
|
public Boolean isAltLogin() {
|
||||||
return saml2.getEnabled() || oauth2.getEnabled();
|
return saml2.getEnabled() || oauth2.getEnabled();
|
||||||
@@ -329,7 +285,7 @@ public class ApplicationProperties {
|
|||||||
private KeycloakProvider keycloak = new KeycloakProvider();
|
private KeycloakProvider keycloak = new KeycloakProvider();
|
||||||
|
|
||||||
public Provider get(String registrationId) throws UnsupportedProviderException {
|
public Provider get(String registrationId) throws UnsupportedProviderException {
|
||||||
return switch (registrationId.toLowerCase(Locale.ROOT)) {
|
return switch (registrationId.toLowerCase()) {
|
||||||
case "google" -> getGoogle();
|
case "google" -> getGoogle();
|
||||||
case "github" -> getGithub();
|
case "github" -> getGithub();
|
||||||
case "keycloak" -> getKeycloak();
|
case "keycloak" -> getKeycloak();
|
||||||
@@ -337,8 +293,8 @@ public class ApplicationProperties {
|
|||||||
throw new UnsupportedProviderException(
|
throw new UnsupportedProviderException(
|
||||||
"Logout from the provider "
|
"Logout from the provider "
|
||||||
+ registrationId
|
+ registrationId
|
||||||
+ " is not supported. Report it at"
|
+ " is not supported. "
|
||||||
+ " https://github.com/Stirling-Tools/Stirling-PDF/issues");
|
+ "Report it at https://github.com/Stirling-Tools/Stirling-PDF/issues");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -350,105 +306,32 @@ public class ApplicationProperties {
|
|||||||
private boolean enableKeyRotation = false;
|
private boolean enableKeyRotation = false;
|
||||||
private boolean enableKeyCleanup = true;
|
private boolean enableKeyCleanup = true;
|
||||||
private int keyRetentionDays = 7;
|
private int keyRetentionDays = 7;
|
||||||
}
|
private boolean secureCookie;
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Validation {
|
|
||||||
private Trust trust = new Trust();
|
|
||||||
private boolean allowAIA = false;
|
|
||||||
private Aatl aatl = new Aatl();
|
|
||||||
private Eutl eutl = new Eutl();
|
|
||||||
private Revocation revocation = new Revocation();
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Trust {
|
|
||||||
private boolean serverAsAnchor = true;
|
|
||||||
private boolean useSystemTrust = false;
|
|
||||||
private boolean useMozillaBundle = false;
|
|
||||||
private boolean useAATL = false;
|
|
||||||
private boolean useEUTL = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Aatl {
|
|
||||||
private String url = "https://trustlist.adobe.com/tl.pdf";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Eutl {
|
|
||||||
private String lotlUrl = "https://ec.europa.eu/tools/lotl/eu-lotl.xml";
|
|
||||||
private boolean acceptTransitional = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Revocation {
|
|
||||||
private String mode = "none";
|
|
||||||
private boolean hardFail = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class System {
|
public static class System {
|
||||||
private String defaultLocale;
|
private String defaultLocale;
|
||||||
private boolean googlevisibility;
|
private Boolean googlevisibility;
|
||||||
private boolean showUpdate;
|
private boolean showUpdate;
|
||||||
private boolean showUpdateOnlyAdmin;
|
private Boolean showUpdateOnlyAdmin;
|
||||||
private boolean showSettingsWhenNoLogin = true;
|
|
||||||
private boolean customHTMLFiles;
|
private boolean customHTMLFiles;
|
||||||
private String tessdataDir;
|
private String tessdataDir;
|
||||||
private boolean enableAlphaFunctionality;
|
private Boolean enableAlphaFunctionality;
|
||||||
private Boolean enableAnalytics;
|
private Boolean enableAnalytics;
|
||||||
private Boolean enablePosthog;
|
|
||||||
private Boolean enableScarf;
|
|
||||||
private Boolean enableDesktopInstallSlide;
|
|
||||||
private Datasource datasource;
|
private Datasource datasource;
|
||||||
private boolean disableSanitize;
|
private Boolean disableSanitize;
|
||||||
private int maxDPI;
|
private int maxDPI;
|
||||||
private boolean enableUrlToPDF;
|
private Boolean enableUrlToPDF;
|
||||||
private Html html = new Html();
|
private Html html = new Html();
|
||||||
private CustomPaths customPaths = new CustomPaths();
|
private CustomPaths customPaths = new CustomPaths();
|
||||||
private String fileUploadLimit;
|
private String fileUploadLimit;
|
||||||
private TempFileManagement tempFileManagement = new TempFileManagement();
|
private TempFileManagement tempFileManagement = new TempFileManagement();
|
||||||
private DatabaseBackup databaseBackup = new DatabaseBackup();
|
|
||||||
private List<String> corsAllowedOrigins = new ArrayList<>();
|
|
||||||
private String backendUrl; // Backend base URL for SAML/OAuth/API callbacks (e.g.
|
|
||||||
// 'http://localhost:8080', 'https://api.example.com'). Required for
|
|
||||||
// SSO.
|
|
||||||
private String frontendUrl; // Frontend URL for invite email links (e.g.
|
|
||||||
|
|
||||||
// 'https://app.example.com'). If not set, falls back to backendUrl.
|
|
||||||
private boolean enableMobileScanner = false; // Enable mobile phone QR code upload feature
|
|
||||||
private MobileScannerSettings mobileScannerSettings = new MobileScannerSettings();
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class MobileScannerSettings {
|
|
||||||
private boolean convertToPdf = true; // Whether to automatically convert images to PDF
|
|
||||||
private String imageResolution = "full"; // Options: "full", "reduced"
|
|
||||||
private String pageFormat = "A4"; // Options: "keep", "A4", "letter"
|
|
||||||
private boolean stretchToFit = false; // Whether to stretch image to fill page
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAnalyticsEnabled() {
|
public boolean isAnalyticsEnabled() {
|
||||||
return this.getEnableAnalytics() != null && this.getEnableAnalytics();
|
return this.getEnableAnalytics() != null && this.getEnableAnalytics();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPosthogEnabled() {
|
|
||||||
// Treat null as enabled when analytics is enabled
|
|
||||||
return this.isAnalyticsEnabled()
|
|
||||||
&& (this.getEnablePosthog() == null || this.getEnablePosthog());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isScarfEnabled() {
|
|
||||||
// Treat null as enabled when analytics is enabled
|
|
||||||
return this.isAnalyticsEnabled()
|
|
||||||
&& (this.getEnableScarf() == null || this.getEnableScarf());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class DatabaseBackup {
|
|
||||||
private String cron = "0 0 0 * * ?"; // daily at midnight
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -467,9 +350,6 @@ public class ApplicationProperties {
|
|||||||
public static class Operations {
|
public static class Operations {
|
||||||
private String weasyprint;
|
private String weasyprint;
|
||||||
private String unoconvert;
|
private String unoconvert;
|
||||||
private String calibre;
|
|
||||||
private String ocrmypdf;
|
|
||||||
private String soffice;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,19 +370,17 @@ public class ApplicationProperties {
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String getBaseTmpDir() {
|
public String getBaseTmpDir() {
|
||||||
if (baseTmpDir != null && !baseTmpDir.isEmpty()) {
|
return baseTmpDir != null && !baseTmpDir.isEmpty()
|
||||||
return baseTmpDir;
|
? baseTmpDir
|
||||||
}
|
: java.lang.System.getProperty("java.io.tmpdir").replaceAll("/+$", "")
|
||||||
String tmp = java.lang.System.getProperty("java.io.tmpdir");
|
+ "/stirling-pdf";
|
||||||
return new File(tmp, "stirling-pdf").getPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String getLibreofficeDir() {
|
public String getLibreofficeDir() {
|
||||||
if (libreofficeDir != null && !libreofficeDir.isEmpty()) {
|
return libreofficeDir != null && !libreofficeDir.isEmpty()
|
||||||
return libreofficeDir;
|
? libreofficeDir
|
||||||
}
|
: getBaseTmpDir() + "/libreoffice";
|
||||||
return new File(getBaseTmpDir(), "libreoffice").getPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +391,7 @@ public class ApplicationProperties {
|
|||||||
@Data
|
@Data
|
||||||
public static class UrlSecurity {
|
public static class UrlSecurity {
|
||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
private SsrfProtectionLevel level = SsrfProtectionLevel.MEDIUM; // MAX, MEDIUM, OFF
|
private String level = "MEDIUM"; // MAX, MEDIUM, OFF
|
||||||
private List<String> allowedDomains = new ArrayList<>();
|
private List<String> allowedDomains = new ArrayList<>();
|
||||||
private List<String> blockedDomains = new ArrayList<>();
|
private List<String> blockedDomains = new ArrayList<>();
|
||||||
private List<String> internalTlds =
|
private List<String> internalTlds =
|
||||||
@@ -552,30 +430,35 @@ public class ApplicationProperties {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return """
|
return """
|
||||||
Driver {
|
Driver {
|
||||||
driverName='%s'
|
driverName='%s'
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
.formatted(driverName);
|
.formatted(driverName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Ui {
|
public static class Ui {
|
||||||
|
private String appName;
|
||||||
|
private String homeDescription;
|
||||||
private String appNameNavbar;
|
private String appNameNavbar;
|
||||||
private List<String> languages;
|
private List<String> languages;
|
||||||
private String logoStyle = "classic"; // Options: "classic" (default) or "modern"
|
|
||||||
|
|
||||||
public String getAppNameNavbar() {
|
public String getAppName() {
|
||||||
return appNameNavbar != null && !appNameNavbar.trim().isEmpty() ? appNameNavbar : null;
|
return appName != null && appName.trim().length() > 0 ? appName : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLogoStyle() {
|
public String getHomeDescription() {
|
||||||
// Validate and return either "modern" or "classic"
|
return homeDescription != null && homeDescription.trim().length() > 0
|
||||||
if ("modern".equalsIgnoreCase(logoStyle)) {
|
? homeDescription
|
||||||
return "modern";
|
: null;
|
||||||
}
|
}
|
||||||
return "classic"; // default
|
|
||||||
|
public String getAppNameNavbar() {
|
||||||
|
return appNameNavbar != null && appNameNavbar.trim().length() > 0
|
||||||
|
? appNameNavbar
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,7 +470,7 @@ public class ApplicationProperties {
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Metrics {
|
public static class Metrics {
|
||||||
private boolean enabled;
|
private Boolean enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -595,7 +478,6 @@ public class ApplicationProperties {
|
|||||||
@ToString.Exclude private String key;
|
@ToString.Exclude private String key;
|
||||||
private String UUID;
|
private String UUID;
|
||||||
private String appVersion;
|
private String appVersion;
|
||||||
private Boolean isNewServer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove post migration
|
// TODO: Remove post migration
|
||||||
@@ -608,7 +490,6 @@ public class ApplicationProperties {
|
|||||||
private boolean ssoAutoLogin;
|
private boolean ssoAutoLogin;
|
||||||
private CustomMetadata customMetadata = new CustomMetadata();
|
private CustomMetadata customMetadata = new CustomMetadata();
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@Data
|
@Data
|
||||||
public static class CustomMetadata {
|
public static class CustomMetadata {
|
||||||
private boolean autoUpdateMetadata;
|
private boolean autoUpdateMetadata;
|
||||||
@@ -616,139 +497,24 @@ public class ApplicationProperties {
|
|||||||
private String creator;
|
private String creator;
|
||||||
private String producer;
|
private String producer;
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public String getCreator() {
|
public String getCreator() {
|
||||||
return creator == null || creator.trim().isEmpty() ? "Stirling-PDF" : creator;
|
return creator == null || creator.trim().isEmpty() ? "Stirling-PDF" : creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public String getProducer() {
|
public String getProducer() {
|
||||||
return producer == null || producer.trim().isEmpty() ? "Stirling-PDF" : producer;
|
return producer == null || producer.trim().isEmpty() ? "Stirling-PDF" : producer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Mail server configuration properties.
|
|
||||||
*
|
|
||||||
* @since 0.46.1
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
public static class Mail {
|
public static class Mail {
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private boolean enableInvites = false;
|
|
||||||
private int inviteLinkExpiryHours = 72; // Default: 72 hours (3 days)
|
|
||||||
private String host;
|
private String host;
|
||||||
private int port;
|
private int port;
|
||||||
private String username;
|
private String username;
|
||||||
@ToString.Exclude private String password;
|
@ToString.Exclude private String password;
|
||||||
private String from;
|
private String from;
|
||||||
// STARTTLS upgrades a plain SMTP connection to TLS after connecting (RFC 3207)
|
|
||||||
private Boolean startTlsEnable = true;
|
|
||||||
private Boolean startTlsRequired;
|
|
||||||
// SSL/TLS wrapper for implicit TLS (typically port 465)
|
|
||||||
private Boolean sslEnable;
|
|
||||||
// Hostnames or patterns (e.g., "smtp.example.com" or "*") to trust for TLS certificates;
|
|
||||||
// defaults to "*" (trust all) when not set
|
|
||||||
private String sslTrust;
|
|
||||||
// Enables hostname verification for TLS connections
|
|
||||||
private Boolean sslCheckServerIdentity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Telegram bot configuration properties.
|
|
||||||
*
|
|
||||||
* @since 2.2.x
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class Telegram {
|
|
||||||
private Boolean enabled = false;
|
|
||||||
@ToString.Exclude private String botToken;
|
|
||||||
private String botUsername;
|
|
||||||
private String pipelineInboxFolder = "telegram";
|
|
||||||
private Boolean customFolderSuffix = false;
|
|
||||||
private Boolean enableAllowUserIDs = false;
|
|
||||||
private List<Long> allowUserIDs = new ArrayList<>();
|
|
||||||
private Boolean enableAllowChannelIDs = false;
|
|
||||||
private List<Long> allowChannelIDs = new ArrayList<>();
|
|
||||||
private long processingTimeoutSeconds = 180;
|
|
||||||
private long pollingIntervalMillis = 2000;
|
|
||||||
private Feedback feedback = new Feedback();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration for feedback messages sent by the Telegram bot.
|
|
||||||
*
|
|
||||||
* @since 2.2.x
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class Feedback {
|
|
||||||
private Channel channel = new Channel();
|
|
||||||
private User user = new User();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Channel-specific feedback settings.
|
|
||||||
*
|
|
||||||
* @since 2.2.x
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class Channel {
|
|
||||||
/**
|
|
||||||
* Set to {@code false} to hide/suppress "no valid document" feedback messages to
|
|
||||||
* the channel (to avoid spam).
|
|
||||||
*/
|
|
||||||
private Boolean noValidDocument = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set to {@code false} to hide/suppress generic error feedback messages to the
|
|
||||||
* channel (to avoid spam).
|
|
||||||
*/
|
|
||||||
private Boolean errorMessage = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set to {@code false} to hide/suppress processing error feedback messages to the
|
|
||||||
* channel (to avoid spam).
|
|
||||||
*/
|
|
||||||
private Boolean errorProcessing = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set to {@code false} to hide/suppress "processing" feedback messages to the
|
|
||||||
* channel (to avoid spam).
|
|
||||||
*/
|
|
||||||
private Boolean processing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User-specific feedback settings.
|
|
||||||
*
|
|
||||||
* @since 2.2.x
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class User {
|
|
||||||
/**
|
|
||||||
* Set to {@code false} to hide/suppress "no valid document" feedback messages to
|
|
||||||
* users (to avoid spam).
|
|
||||||
*/
|
|
||||||
private Boolean noValidDocument = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set to {@code false} to hide/suppress generic error feedback messages to users
|
|
||||||
* (to avoid spam).
|
|
||||||
*/
|
|
||||||
private Boolean errorMessage = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set to {@code false} to hide/suppress processing error feedback messages to users
|
|
||||||
* (to avoid spam).
|
|
||||||
*/
|
|
||||||
private Boolean errorProcessing = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set to {@code false} to hide/suppress "processing" feedback messages to users (to
|
|
||||||
* avoid spam).
|
|
||||||
*/
|
|
||||||
private Boolean processing = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -788,25 +554,6 @@ public class ApplicationProperties {
|
|||||||
public static class EnterpriseFeatures {
|
public static class EnterpriseFeatures {
|
||||||
private PersistentMetrics persistentMetrics = new PersistentMetrics();
|
private PersistentMetrics persistentMetrics = new PersistentMetrics();
|
||||||
private Audit audit = new Audit();
|
private Audit audit = new Audit();
|
||||||
private DatabaseNotifications databaseNotifications = new DatabaseNotifications();
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class DatabaseNotifications {
|
|
||||||
private Backup backups = new Backup();
|
|
||||||
private Imports imports = new Imports();
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Backup {
|
|
||||||
private boolean successful = false;
|
|
||||||
private boolean failed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class Imports {
|
|
||||||
private boolean successful = false;
|
|
||||||
private boolean failed = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Audit {
|
public static class Audit {
|
||||||
@@ -827,16 +574,6 @@ public class ApplicationProperties {
|
|||||||
public static class ProcessExecutor {
|
public static class ProcessExecutor {
|
||||||
private SessionLimit sessionLimit = new SessionLimit();
|
private SessionLimit sessionLimit = new SessionLimit();
|
||||||
private TimeoutMinutes timeoutMinutes = new TimeoutMinutes();
|
private TimeoutMinutes timeoutMinutes = new TimeoutMinutes();
|
||||||
private boolean autoUnoServer = true;
|
|
||||||
private List<UnoServerEndpoint> unoServerEndpoints = new ArrayList<>();
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class UnoServerEndpoint {
|
|
||||||
private String host = "127.0.0.1";
|
|
||||||
private int port = 2003;
|
|
||||||
private String hostLocation = "auto"; // auto|local|remote
|
|
||||||
private String protocol = "http"; // http|https
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class SessionLimit {
|
public static class SessionLimit {
|
||||||
@@ -846,12 +583,10 @@ public class ApplicationProperties {
|
|||||||
private int weasyPrintSessionLimit;
|
private int weasyPrintSessionLimit;
|
||||||
private int installAppSessionLimit;
|
private int installAppSessionLimit;
|
||||||
private int calibreSessionLimit;
|
private int calibreSessionLimit;
|
||||||
private int imageMagickSessionLimit;
|
|
||||||
private int qpdfSessionLimit;
|
private int qpdfSessionLimit;
|
||||||
private int tesseractSessionLimit;
|
private int tesseractSessionLimit;
|
||||||
private int ghostscriptSessionLimit;
|
private int ghostscriptSessionLimit;
|
||||||
private int ocrMyPdfSessionLimit;
|
private int ocrMyPdfSessionLimit;
|
||||||
private int ffmpegSessionLimit;
|
|
||||||
|
|
||||||
public int getQpdfSessionLimit() {
|
public int getQpdfSessionLimit() {
|
||||||
return qpdfSessionLimit > 0 ? qpdfSessionLimit : 2;
|
return qpdfSessionLimit > 0 ? qpdfSessionLimit : 2;
|
||||||
@@ -885,10 +620,6 @@ public class ApplicationProperties {
|
|||||||
return calibreSessionLimit > 0 ? calibreSessionLimit : 1;
|
return calibreSessionLimit > 0 ? calibreSessionLimit : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getImageMagickSessionLimit() {
|
|
||||||
return imageMagickSessionLimit > 0 ? imageMagickSessionLimit : 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGhostscriptSessionLimit() {
|
public int getGhostscriptSessionLimit() {
|
||||||
return ghostscriptSessionLimit > 0 ? ghostscriptSessionLimit : 8;
|
return ghostscriptSessionLimit > 0 ? ghostscriptSessionLimit : 8;
|
||||||
}
|
}
|
||||||
@@ -896,10 +627,6 @@ public class ApplicationProperties {
|
|||||||
public int getOcrMyPdfSessionLimit() {
|
public int getOcrMyPdfSessionLimit() {
|
||||||
return ocrMyPdfSessionLimit > 0 ? ocrMyPdfSessionLimit : 2;
|
return ocrMyPdfSessionLimit > 0 ? ocrMyPdfSessionLimit : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFfmpegSessionLimit() {
|
|
||||||
return ffmpegSessionLimit > 0 ? ffmpegSessionLimit : 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -922,13 +649,10 @@ public class ApplicationProperties {
|
|||||||
@JsonProperty("calibretimeoutMinutes")
|
@JsonProperty("calibretimeoutMinutes")
|
||||||
private long calibreTimeoutMinutes;
|
private long calibreTimeoutMinutes;
|
||||||
|
|
||||||
private long imageMagickTimeoutMinutes;
|
|
||||||
|
|
||||||
private long tesseractTimeoutMinutes;
|
private long tesseractTimeoutMinutes;
|
||||||
private long qpdfTimeoutMinutes;
|
private long qpdfTimeoutMinutes;
|
||||||
private long ghostscriptTimeoutMinutes;
|
private long ghostscriptTimeoutMinutes;
|
||||||
private long ocrMyPdfTimeoutMinutes;
|
private long ocrMyPdfTimeoutMinutes;
|
||||||
private long ffmpegTimeoutMinutes;
|
|
||||||
|
|
||||||
public long getTesseractTimeoutMinutes() {
|
public long getTesseractTimeoutMinutes() {
|
||||||
return tesseractTimeoutMinutes > 0 ? tesseractTimeoutMinutes : 30;
|
return tesseractTimeoutMinutes > 0 ? tesseractTimeoutMinutes : 30;
|
||||||
@@ -962,10 +686,6 @@ public class ApplicationProperties {
|
|||||||
return calibreTimeoutMinutes > 0 ? calibreTimeoutMinutes : 30;
|
return calibreTimeoutMinutes > 0 ? calibreTimeoutMinutes : 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getImageMagickTimeoutMinutes() {
|
|
||||||
return imageMagickTimeoutMinutes > 0 ? imageMagickTimeoutMinutes : 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getGhostscriptTimeoutMinutes() {
|
public long getGhostscriptTimeoutMinutes() {
|
||||||
return ghostscriptTimeoutMinutes > 0 ? ghostscriptTimeoutMinutes : 30;
|
return ghostscriptTimeoutMinutes > 0 ? ghostscriptTimeoutMinutes : 30;
|
||||||
}
|
}
|
||||||
@@ -973,10 +693,6 @@ public class ApplicationProperties {
|
|||||||
public long getOcrMyPdfTimeoutMinutes() {
|
public long getOcrMyPdfTimeoutMinutes() {
|
||||||
return ocrMyPdfTimeoutMinutes > 0 ? ocrMyPdfTimeoutMinutes : 30;
|
return ocrMyPdfTimeoutMinutes > 0 ? ocrMyPdfTimeoutMinutes : 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getFfmpegTimeoutMinutes() {
|
|
||||||
return ffmpegTimeoutMinutes > 0 ? ffmpegTimeoutMinutes : 30;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Data
|
||||||
public class FileInfo {
|
public class FileInfo {
|
||||||
private static final DateTimeFormatter DATE_FORMATTER =
|
private static final DateTimeFormatter DATE_FORMATTER =
|
||||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
@@ -30,11 +28,11 @@ public class FileInfo {
|
|||||||
// Formats the file size into a human-readable string.
|
// Formats the file size into a human-readable string.
|
||||||
public String getFormattedFileSize() {
|
public String getFormattedFileSize() {
|
||||||
if (fileSize >= 1024 * 1024 * 1024) {
|
if (fileSize >= 1024 * 1024 * 1024) {
|
||||||
return String.format(Locale.ROOT, "%.2f GB", fileSize / (1024.0 * 1024 * 1024));
|
return String.format(Locale.US, "%.2f GB", fileSize / (1024.0 * 1024 * 1024));
|
||||||
} else if (fileSize >= 1024 * 1024) {
|
} else if (fileSize >= 1024 * 1024) {
|
||||||
return String.format(Locale.ROOT, "%.2f MB", fileSize / (1024.0 * 1024));
|
return String.format(Locale.US, "%.2f MB", fileSize / (1024.0 * 1024));
|
||||||
} else if (fileSize >= 1024) {
|
} else if (fileSize >= 1024) {
|
||||||
return String.format(Locale.ROOT, "%.2f KB", fileSize / 1024.0);
|
return String.format(Locale.US, "%.2f KB", fileSize / 1024.0);
|
||||||
} else {
|
} else {
|
||||||
return String.format("%d Bytes", fileSize);
|
return String.format("%d Bytes", fileSize);
|
||||||
}
|
}
|
||||||
|
|||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
package stirling.software.common.model;
|
||||||
|
|
||||||
|
/* Commented out entire InputStreamTemplateResource class - Thymeleaf dependency removed
|
||||||
|
* This class will be removed when frontend migration to React is complete
|
||||||
|
|
||||||
|
|
||||||
|
public class InputStreamTemplateResource implements ITemplateResource {
|
||||||
|
private InputStream inputStream;
|
||||||
|
private String characterEncoding;
|
||||||
|
|
||||||
|
public InputStreamTemplateResource(InputStream inputStream, String characterEncoding) {
|
||||||
|
this.inputStream = inputStream;
|
||||||
|
this.characterEncoding = characterEncoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Reader reader() throws IOException {
|
||||||
|
return new InputStreamReader(inputStream, characterEncoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITemplateResource relative(String relativeLocation) {
|
||||||
|
// Implement logic for relative resources, if needed
|
||||||
|
throw new UnsupportedOperationException("Relative resources not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return "InputStream resource [Stream]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBaseName() {
|
||||||
|
return "streamResource";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean exists() {
|
||||||
|
return inputStream != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
@@ -1,16 +1,12 @@
|
|||||||
package stirling.software.common.model;
|
package stirling.software.common.model;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.util.Calendar;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class PdfMetadata {
|
public class PdfMetadata {
|
||||||
private String author;
|
private String author;
|
||||||
private String producer;
|
private String producer;
|
||||||
@@ -18,6 +14,6 @@ public class PdfMetadata {
|
|||||||
private String creator;
|
private String creator;
|
||||||
private String subject;
|
private String subject;
|
||||||
private String keywords;
|
private String keywords;
|
||||||
private ZonedDateTime creationDate;
|
private Calendar creationDate;
|
||||||
private ZonedDateTime modificationDate;
|
private Calendar modificationDate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package stirling.software.common.model.api;
|
package stirling.software.common.model.api;
|
||||||
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
@@ -16,11 +15,7 @@ import lombok.NoArgsConstructor;
|
|||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@Schema(description = "PDF file input - either upload a file or provide a server-side file ID")
|
@Schema(description = "PDF file input - either upload a file or provide a server-side file ID")
|
||||||
public class PDFFile {
|
public class PDFFile {
|
||||||
|
@Schema(description = "The input PDF file", format = "binary")
|
||||||
@Schema(
|
|
||||||
description = "The input PDF file",
|
|
||||||
contentMediaType = MediaType.APPLICATION_PDF_VALUE,
|
|
||||||
format = "binary")
|
|
||||||
private MultipartFile fileInput;
|
private MultipartFile fileInput;
|
||||||
|
|
||||||
@Schema(
|
@Schema(
|
||||||
|
|||||||
@@ -4,5 +4,4 @@ public enum ReplaceAndInvert {
|
|||||||
HIGH_CONTRAST_COLOR,
|
HIGH_CONTRAST_COLOR,
|
||||||
CUSTOM_COLOR,
|
CUSTOM_COLOR,
|
||||||
FULL_INVERSION,
|
FULL_INVERSION,
|
||||||
COLOR_SPACE_CONVERSION,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,18 @@ public class JobResult {
|
|||||||
/** The actual result object, if not a file */
|
/** The actual result object, if not a file */
|
||||||
private Object result;
|
private Object result;
|
||||||
|
|
||||||
|
/** Whether detailed progress tracking is enabled for this job. */
|
||||||
|
@Builder.Default private boolean trackProgress = true;
|
||||||
|
|
||||||
|
/** Most recent percentage update (0-100) if progress tracking is enabled. */
|
||||||
|
private Integer progressPercent;
|
||||||
|
|
||||||
|
/** Human readable progress message (e.g. current stage) when progress is enabled. */
|
||||||
|
private String progressMessage;
|
||||||
|
|
||||||
|
/** Timestamp of the last progress update. */
|
||||||
|
private LocalDateTime progressUpdatedAt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notes attached to this job for tracking purposes. Uses CopyOnWriteArrayList for thread safety
|
* Notes attached to this job for tracking purposes. Uses CopyOnWriteArrayList for thread safety
|
||||||
* when notes are added concurrently.
|
* when notes are added concurrently.
|
||||||
@@ -54,11 +66,28 @@ public class JobResult {
|
|||||||
* @return A new JobResult
|
* @return A new JobResult
|
||||||
*/
|
*/
|
||||||
public static JobResult createNew(String jobId) {
|
public static JobResult createNew(String jobId) {
|
||||||
return JobResult.builder()
|
return createNew(jobId, true);
|
||||||
.jobId(jobId)
|
}
|
||||||
.complete(false)
|
|
||||||
.createdAt(LocalDateTime.now())
|
/**
|
||||||
.build();
|
* Create a new JobResult with the given job ID and progress tracking preference.
|
||||||
|
*
|
||||||
|
* @param jobId The job ID
|
||||||
|
* @param trackProgress Whether detailed progress should be tracked
|
||||||
|
* @return A new JobResult
|
||||||
|
*/
|
||||||
|
public static JobResult createNew(String jobId, boolean trackProgress) {
|
||||||
|
JobResult result =
|
||||||
|
JobResult.builder()
|
||||||
|
.jobId(jobId)
|
||||||
|
.complete(false)
|
||||||
|
.createdAt(LocalDateTime.now())
|
||||||
|
.trackProgress(trackProgress)
|
||||||
|
.build();
|
||||||
|
if (trackProgress) {
|
||||||
|
result.updateProgressInternal(0, "Pending");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,6 +99,9 @@ public class JobResult {
|
|||||||
this.complete = true;
|
this.complete = true;
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.completedAt = LocalDateTime.now();
|
this.completedAt = LocalDateTime.now();
|
||||||
|
if (trackProgress) {
|
||||||
|
updateProgressInternal(100, "Completed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,6 +113,9 @@ public class JobResult {
|
|||||||
this.complete = true;
|
this.complete = true;
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.completedAt = LocalDateTime.now();
|
this.completedAt = LocalDateTime.now();
|
||||||
|
if (trackProgress) {
|
||||||
|
updateProgressInternal(100, error != null ? error : "Failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,6 +127,9 @@ public class JobResult {
|
|||||||
this.complete = true;
|
this.complete = true;
|
||||||
this.resultFiles = new ArrayList<>(resultFiles);
|
this.resultFiles = new ArrayList<>(resultFiles);
|
||||||
this.completedAt = LocalDateTime.now();
|
this.completedAt = LocalDateTime.now();
|
||||||
|
if (trackProgress) {
|
||||||
|
updateProgressInternal(100, "Completed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,4 +199,26 @@ public class JobResult {
|
|||||||
public List<String> getNotes() {
|
public List<String> getNotes() {
|
||||||
return Collections.unmodifiableList(notes);
|
return Collections.unmodifiableList(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the progress information if tracking is enabled.
|
||||||
|
*
|
||||||
|
* @param percent The percent complete (0-100)
|
||||||
|
* @param message Optional descriptive message
|
||||||
|
*/
|
||||||
|
public void updateProgress(int percent, String message) {
|
||||||
|
if (!trackProgress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateProgressInternal(percent, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateProgressInternal(int percent, String message) {
|
||||||
|
int clamped = Math.min(100, Math.max(0, percent));
|
||||||
|
this.progressPercent = clamped;
|
||||||
|
if (message != null && !message.isBlank()) {
|
||||||
|
this.progressMessage = message;
|
||||||
|
}
|
||||||
|
this.progressUpdatedAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-4
@@ -7,7 +7,6 @@ import java.io.InputStream;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import org.apache.pdfbox.Loader;
|
import org.apache.pdfbox.Loader;
|
||||||
@@ -42,7 +41,7 @@ public class CustomPDFDocumentFactory {
|
|||||||
|
|
||||||
// Memory thresholds and limits
|
// Memory thresholds and limits
|
||||||
|
|
||||||
public static final long SMALL_FILE_THRESHOLD = 10 * 1024 * 1024; // 10 MB
|
private static final long SMALL_FILE_THRESHOLD = 10 * 1024 * 1024; // 10 MB
|
||||||
// Files smaller than this threshold are loaded entirely in memory for better performance.
|
// Files smaller than this threshold are loaded entirely in memory for better performance.
|
||||||
// These files use IOUtils.createMemoryOnlyStreamCache() which keeps all document data in RAM.
|
// These files use IOUtils.createMemoryOnlyStreamCache() which keeps all document data in RAM.
|
||||||
// No temp files are created for document data, reducing I/O operations but consuming more
|
// No temp files are created for document data, reducing I/O operations but consuming more
|
||||||
@@ -250,7 +249,7 @@ public class CustomPDFDocumentFactory {
|
|||||||
log.debug(
|
log.debug(
|
||||||
"Memory status - Free: {}MB ({}%), Used: {}MB, Max: {}MB",
|
"Memory status - Free: {}MB ({}%), Used: {}MB, Max: {}MB",
|
||||||
actualFreeMemory / (1024 * 1024),
|
actualFreeMemory / (1024 * 1024),
|
||||||
String.format(Locale.ROOT, "%.2f", freeMemoryPercent),
|
String.format("%.2f", freeMemoryPercent),
|
||||||
usedMemory / (1024 * 1024),
|
usedMemory / (1024 * 1024),
|
||||||
maxMemory / (1024 * 1024));
|
maxMemory / (1024 * 1024));
|
||||||
|
|
||||||
@@ -259,7 +258,7 @@ public class CustomPDFDocumentFactory {
|
|||||||
|| actualFreeMemory < MIN_FREE_MEMORY_BYTES) {
|
|| actualFreeMemory < MIN_FREE_MEMORY_BYTES) {
|
||||||
log.debug(
|
log.debug(
|
||||||
"Low memory detected ({}%), forcing file-based cache",
|
"Low memory detected ({}%), forcing file-based cache",
|
||||||
String.format(Locale.ROOT, "%.2f", freeMemoryPercent));
|
String.format("%.2f", freeMemoryPercent));
|
||||||
return createScratchFileCacheFunction(MemoryUsageSetting.setupTempFileOnly());
|
return createScratchFileCacheFunction(MemoryUsageSetting.setupTempFileOnly());
|
||||||
} else if (contentSize < SMALL_FILE_THRESHOLD) {
|
} else if (contentSize < SMALL_FILE_THRESHOLD) {
|
||||||
log.debug("Using memory-only cache for small document ({}KB)", contentSize / 1024);
|
log.debug("Using memory-only cache for small document ({}KB)", contentSize / 1024);
|
||||||
@@ -478,6 +477,11 @@ public class CustomPDFDocumentFactory {
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Create a uniquely named temporary directory */
|
||||||
|
private Path createTempDirectory(String prefix) throws IOException {
|
||||||
|
return Files.createTempDirectory(prefix + tempCounter.incrementAndGet() + "-");
|
||||||
|
}
|
||||||
|
|
||||||
/** Create new document bytes based on an existing document */
|
/** Create new document bytes based on an existing document */
|
||||||
public byte[] createNewBytesBasedOnOldDocument(byte[] oldDocument) throws IOException {
|
public byte[] createNewBytesBasedOnOldDocument(byte[] oldDocument) throws IOException {
|
||||||
try (PDDocument document = load(oldDocument)) {
|
try (PDDocument document = load(oldDocument)) {
|
||||||
|
|||||||
+135
-141
@@ -9,7 +9,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -21,9 +20,9 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import stirling.software.common.context.JobContextHolder;
|
||||||
import stirling.software.common.model.job.JobResponse;
|
import stirling.software.common.model.job.JobResponse;
|
||||||
import stirling.software.common.util.ExecutorFactory;
|
import stirling.software.common.util.ExecutorFactory;
|
||||||
import stirling.software.common.util.RegexPatternUtils;
|
|
||||||
|
|
||||||
/** Service for executing jobs asynchronously or synchronously */
|
/** Service for executing jobs asynchronously or synchronously */
|
||||||
@Service
|
@Service
|
||||||
@@ -38,9 +37,6 @@ public class JobExecutorService {
|
|||||||
private final ExecutorService executor = ExecutorFactory.newVirtualOrCachedThreadExecutor();
|
private final ExecutorService executor = ExecutorFactory.newVirtualOrCachedThreadExecutor();
|
||||||
private final long effectiveTimeoutMs;
|
private final long effectiveTimeoutMs;
|
||||||
|
|
||||||
@Autowired(required = false)
|
|
||||||
private JobOwnershipService jobOwnershipService;
|
|
||||||
|
|
||||||
public JobExecutorService(
|
public JobExecutorService(
|
||||||
TaskManager taskManager,
|
TaskManager taskManager,
|
||||||
FileStorage fileStorage,
|
FileStorage fileStorage,
|
||||||
@@ -70,7 +66,7 @@ public class JobExecutorService {
|
|||||||
* @return The response
|
* @return The response
|
||||||
*/
|
*/
|
||||||
public ResponseEntity<?> runJobGeneric(boolean async, Supplier<Object> work) {
|
public ResponseEntity<?> runJobGeneric(boolean async, Supplier<Object> work) {
|
||||||
return runJobGeneric(async, work, -1);
|
return runJobGeneric(async, work, -1, false, 50, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,7 +79,7 @@ public class JobExecutorService {
|
|||||||
*/
|
*/
|
||||||
public ResponseEntity<?> runJobGeneric(
|
public ResponseEntity<?> runJobGeneric(
|
||||||
boolean async, Supplier<Object> work, long customTimeoutMs) {
|
boolean async, Supplier<Object> work, long customTimeoutMs) {
|
||||||
return runJobGeneric(async, work, customTimeoutMs, false, 50);
|
return runJobGeneric(async, work, customTimeoutMs, false, 50, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,18 +97,13 @@ public class JobExecutorService {
|
|||||||
Supplier<Object> work,
|
Supplier<Object> work,
|
||||||
long customTimeoutMs,
|
long customTimeoutMs,
|
||||||
boolean queueable,
|
boolean queueable,
|
||||||
int resourceWeight) {
|
int resourceWeight,
|
||||||
// Generate base UUID
|
boolean trackProgress) {
|
||||||
String baseJobId = UUID.randomUUID().toString();
|
String jobId = UUID.randomUUID().toString();
|
||||||
|
|
||||||
// Scope job to authenticated user if security is enabled
|
// Store the job ID in the request for potential use by other components
|
||||||
String scopedJobKey = getScopedJobKey(baseJobId);
|
|
||||||
|
|
||||||
log.debug("Generated jobId: {} (base: {})", scopedJobKey, baseJobId);
|
|
||||||
|
|
||||||
// Store the scoped job ID in the request for potential use by other components
|
|
||||||
if (request != null) {
|
if (request != null) {
|
||||||
request.setAttribute("jobId", scopedJobKey);
|
request.setAttribute("jobId", jobId);
|
||||||
|
|
||||||
// Also track this job ID in the user's session for authorization purposes
|
// Also track this job ID in the user's session for authorization purposes
|
||||||
// This ensures users can only cancel their own jobs
|
// This ensures users can only cancel their own jobs
|
||||||
@@ -126,13 +117,11 @@ public class JobExecutorService {
|
|||||||
request.getSession().setAttribute("userJobIds", userJobIds);
|
request.getSession().setAttribute("userJobIds", userJobIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
userJobIds.add(scopedJobKey);
|
userJobIds.add(jobId);
|
||||||
log.debug("Added scoped job ID {} to user session", scopedJobKey);
|
log.debug("Added job ID {} to user session", jobId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String jobId = scopedJobKey;
|
|
||||||
|
|
||||||
// Determine which timeout to use
|
// Determine which timeout to use
|
||||||
long timeoutToUse = customTimeoutMs > 0 ? customTimeoutMs : effectiveTimeoutMs;
|
long timeoutToUse = customTimeoutMs > 0 ? customTimeoutMs : effectiveTimeoutMs;
|
||||||
|
|
||||||
@@ -151,6 +140,8 @@ public class JobExecutorService {
|
|||||||
&& // Only async jobs can be queued
|
&& // Only async jobs can be queued
|
||||||
resourceMonitor.shouldQueueJob(resourceWeight);
|
resourceMonitor.shouldQueueJob(resourceWeight);
|
||||||
|
|
||||||
|
boolean enableProgress = async && trackProgress;
|
||||||
|
|
||||||
if (shouldQueue) {
|
if (shouldQueue) {
|
||||||
// Queue the job instead of executing immediately
|
// Queue the job instead of executing immediately
|
||||||
log.debug(
|
log.debug(
|
||||||
@@ -158,34 +149,25 @@ public class JobExecutorService {
|
|||||||
jobId,
|
jobId,
|
||||||
resourceWeight);
|
resourceWeight);
|
||||||
|
|
||||||
taskManager.createTask(jobId);
|
taskManager.createTask(jobId, trackProgress);
|
||||||
|
|
||||||
|
Supplier<Object> contextualWork = withJobContext(jobId, enableProgress, work);
|
||||||
|
|
||||||
// Create a specialized wrapper that updates the TaskManager
|
// Create a specialized wrapper that updates the TaskManager
|
||||||
final String capturedJobIdForQueue = jobId;
|
|
||||||
Supplier<Object> wrappedWork =
|
Supplier<Object> wrappedWork =
|
||||||
() -> {
|
() -> {
|
||||||
try {
|
try {
|
||||||
// Set jobId in ThreadLocal context for the queued job
|
if (enableProgress) {
|
||||||
stirling.software.common.util.JobContext.setJobId(
|
taskManager.updateProgress(jobId, 5, null);
|
||||||
capturedJobIdForQueue);
|
}
|
||||||
log.debug(
|
Object result = contextualWork.get();
|
||||||
"Set jobId {} in JobContext for queued job execution",
|
processJobResult(jobId, result);
|
||||||
capturedJobIdForQueue);
|
|
||||||
|
|
||||||
Object result = work.get();
|
|
||||||
processJobResult(capturedJobIdForQueue, result);
|
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(
|
log.error(
|
||||||
"Error executing queued job {}: {}",
|
"Error executing queued job {}: {}", jobId, e.getMessage(), e);
|
||||||
capturedJobIdForQueue,
|
taskManager.setError(jobId, e.getMessage());
|
||||||
e.getMessage(),
|
|
||||||
e);
|
|
||||||
taskManager.setError(capturedJobIdForQueue, e.getMessage());
|
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
|
||||||
// Clean up ThreadLocal to avoid memory leaks
|
|
||||||
stirling.software.common.util.JobContext.clear();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -196,51 +178,59 @@ public class JobExecutorService {
|
|||||||
// Return immediately with job ID
|
// Return immediately with job ID
|
||||||
return ResponseEntity.ok().body(new JobResponse<>(true, jobId, null));
|
return ResponseEntity.ok().body(new JobResponse<>(true, jobId, null));
|
||||||
} else if (async) {
|
} else if (async) {
|
||||||
taskManager.createTask(jobId);
|
taskManager.createTask(jobId, trackProgress);
|
||||||
|
|
||||||
// Capture the jobId for the async thread
|
|
||||||
final String capturedJobId = jobId;
|
|
||||||
|
|
||||||
executor.execute(
|
executor.execute(
|
||||||
() -> {
|
() ->
|
||||||
try {
|
runWithJobContext(
|
||||||
log.debug(
|
jobId,
|
||||||
"Running async job {} with timeout {} ms",
|
enableProgress,
|
||||||
capturedJobId,
|
() -> {
|
||||||
timeoutToUse);
|
try {
|
||||||
|
log.debug(
|
||||||
|
"Running async job {} with timeout {} ms",
|
||||||
|
jobId,
|
||||||
|
timeoutToUse);
|
||||||
|
|
||||||
// Set jobId in ThreadLocal context for the async thread
|
Supplier<Object> contextualWork =
|
||||||
stirling.software.common.util.JobContext.setJobId(capturedJobId);
|
withJobContext(jobId, enableProgress, work);
|
||||||
log.debug(
|
|
||||||
"Set jobId {} in JobContext for async execution",
|
|
||||||
capturedJobId);
|
|
||||||
|
|
||||||
// Execute with timeout
|
if (enableProgress) {
|
||||||
Object result = executeWithTimeout(() -> work.get(), timeoutToUse);
|
taskManager.updateProgress(jobId, 5, null);
|
||||||
processJobResult(capturedJobId, result);
|
}
|
||||||
} catch (TimeoutException te) {
|
|
||||||
log.error("Job {} timed out after {} ms", jobId, timeoutToUse);
|
// Execute with timeout
|
||||||
taskManager.setError(jobId, "Job timed out");
|
Object result =
|
||||||
} catch (Exception e) {
|
executeWithTimeout(
|
||||||
log.error("Error executing job {}: {}", jobId, e.getMessage(), e);
|
contextualWork,
|
||||||
taskManager.setError(jobId, e.getMessage());
|
timeoutToUse,
|
||||||
} finally {
|
jobId,
|
||||||
// Clean up ThreadLocal to avoid memory leaks
|
enableProgress);
|
||||||
stirling.software.common.util.JobContext.clear();
|
processJobResult(jobId, result);
|
||||||
}
|
} catch (TimeoutException te) {
|
||||||
});
|
log.error(
|
||||||
|
"Job {} timed out after {} ms",
|
||||||
|
jobId,
|
||||||
|
timeoutToUse);
|
||||||
|
taskManager.setError(jobId, "Job timed out");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(
|
||||||
|
"Error executing job {}: {}",
|
||||||
|
jobId,
|
||||||
|
e.getMessage(),
|
||||||
|
e);
|
||||||
|
taskManager.setError(jobId, e.getMessage());
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
return ResponseEntity.ok().body(new JobResponse<>(true, jobId, null));
|
return ResponseEntity.ok().body(new JobResponse<>(true, jobId, null));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
log.debug("Running sync job with timeout {} ms", timeoutToUse);
|
log.debug("Running sync job with timeout {} ms", timeoutToUse);
|
||||||
|
|
||||||
// Make jobId available to downstream components on the worker thread
|
|
||||||
stirling.software.common.util.JobContext.setJobId(jobId);
|
|
||||||
log.debug("Set jobId {} in JobContext for sync execution", jobId);
|
|
||||||
|
|
||||||
// Execute with timeout
|
// Execute with timeout
|
||||||
Object result = executeWithTimeout(() -> work.get(), timeoutToUse);
|
Supplier<Object> contextualWork = withJobContext(jobId, enableProgress, work);
|
||||||
|
Object result =
|
||||||
|
executeWithTimeout(contextualWork, timeoutToUse, jobId, enableProgress);
|
||||||
|
|
||||||
// If the result is already a ResponseEntity, return it directly
|
// If the result is already a ResponseEntity, return it directly
|
||||||
if (result instanceof ResponseEntity) {
|
if (result instanceof ResponseEntity) {
|
||||||
@@ -253,29 +243,11 @@ public class JobExecutorService {
|
|||||||
log.error("Synchronous job timed out after {} ms", timeoutToUse);
|
log.error("Synchronous job timed out after {} ms", timeoutToUse);
|
||||||
return ResponseEntity.internalServerError()
|
return ResponseEntity.internalServerError()
|
||||||
.body(Map.of("error", "Job timed out after " + timeoutToUse + " ms"));
|
.body(Map.of("error", "Job timed out after " + timeoutToUse + " ms"));
|
||||||
} catch (RuntimeException e) {
|
|
||||||
// Check if this is a wrapped typed exception that should be handled by
|
|
||||||
// GlobalExceptionHandler
|
|
||||||
Throwable cause = e.getCause();
|
|
||||||
if (cause instanceof stirling.software.common.util.ExceptionUtils.BaseAppException
|
|
||||||
|| cause
|
|
||||||
instanceof
|
|
||||||
stirling.software.common.util.ExceptionUtils
|
|
||||||
.BaseValidationException) {
|
|
||||||
// Rethrow so GlobalExceptionHandler can handle with proper HTTP status codes
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
// Handle other RuntimeExceptions as generic errors
|
|
||||||
log.error("Error executing synchronous job: {}", e.getMessage(), e);
|
|
||||||
return ResponseEntity.internalServerError()
|
|
||||||
.body(Map.of("error", "Job failed: " + e.getMessage()));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error executing synchronous job: {}", e.getMessage(), e);
|
log.error("Error executing synchronous job: {}", e.getMessage(), e);
|
||||||
// Construct a JSON error response
|
// Construct a JSON error response
|
||||||
return ResponseEntity.internalServerError()
|
return ResponseEntity.internalServerError()
|
||||||
.body(Map.of("error", "Job failed: " + e.getMessage()));
|
.body(Map.of("error", "Job failed: " + e.getMessage()));
|
||||||
} finally {
|
|
||||||
stirling.software.common.util.JobContext.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,8 +263,7 @@ public class JobExecutorService {
|
|||||||
if (result instanceof byte[]) {
|
if (result instanceof byte[]) {
|
||||||
// Store byte array directly to disk to avoid double memory consumption
|
// Store byte array directly to disk to avoid double memory consumption
|
||||||
String fileId = fileStorage.storeBytes((byte[]) result, "result.pdf");
|
String fileId = fileStorage.storeBytes((byte[]) result, "result.pdf");
|
||||||
taskManager.setFileResult(
|
taskManager.setFileResult(jobId, fileId, "result.pdf", "application/pdf");
|
||||||
jobId, fileId, "result.pdf", MediaType.APPLICATION_PDF_VALUE);
|
|
||||||
log.debug("Stored byte[] result with fileId: {}", fileId);
|
log.debug("Stored byte[] result with fileId: {}", fileId);
|
||||||
|
|
||||||
// Let the byte array get collected naturally in the next GC cycle
|
// Let the byte array get collected naturally in the next GC cycle
|
||||||
@@ -304,7 +275,7 @@ public class JobExecutorService {
|
|||||||
if (body instanceof byte[]) {
|
if (body instanceof byte[]) {
|
||||||
// Extract filename from content-disposition header if available
|
// Extract filename from content-disposition header if available
|
||||||
String filename = "result.pdf";
|
String filename = "result.pdf";
|
||||||
String contentType = MediaType.APPLICATION_PDF_VALUE;
|
String contentType = "application/pdf";
|
||||||
|
|
||||||
if (response.getHeaders().getContentDisposition() != null) {
|
if (response.getHeaders().getContentDisposition() != null) {
|
||||||
String disposition =
|
String disposition =
|
||||||
@@ -317,10 +288,8 @@ public class JobExecutorService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaType mediaType = response.getHeaders().getContentType();
|
if (response.getHeaders().getContentType() != null) {
|
||||||
|
contentType = response.getHeaders().getContentType().toString();
|
||||||
if (mediaType != null) {
|
|
||||||
contentType = mediaType.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store byte array directly to disk
|
// Store byte array directly to disk
|
||||||
@@ -341,7 +310,7 @@ public class JobExecutorService {
|
|||||||
if (fileId != null && !fileId.isEmpty()) {
|
if (fileId != null && !fileId.isEmpty()) {
|
||||||
// Try to get filename and content type
|
// Try to get filename and content type
|
||||||
String filename = "result.pdf";
|
String filename = "result.pdf";
|
||||||
String contentType = MediaType.APPLICATION_PDF_VALUE;
|
String contentType = "application/pdf";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
java.lang.reflect.Method getOriginalFileName =
|
java.lang.reflect.Method getOriginalFileName =
|
||||||
@@ -382,7 +351,8 @@ public class JobExecutorService {
|
|||||||
// Store generic result
|
// Store generic result
|
||||||
taskManager.setResult(jobId, body);
|
taskManager.setResult(jobId, body);
|
||||||
}
|
}
|
||||||
} else if (result instanceof MultipartFile file) {
|
} else if (result instanceof MultipartFile) {
|
||||||
|
MultipartFile file = (MultipartFile) result;
|
||||||
String fileId = fileStorage.storeFile(file);
|
String fileId = fileStorage.storeFile(file);
|
||||||
taskManager.setFileResult(
|
taskManager.setFileResult(
|
||||||
jobId, fileId, file.getOriginalFilename(), file.getContentType());
|
jobId, fileId, file.getOriginalFilename(), file.getContentType());
|
||||||
@@ -399,7 +369,7 @@ public class JobExecutorService {
|
|||||||
if (fileId != null && !fileId.isEmpty()) {
|
if (fileId != null && !fileId.isEmpty()) {
|
||||||
// Try to get filename and content type
|
// Try to get filename and content type
|
||||||
String filename = "result.pdf";
|
String filename = "result.pdf";
|
||||||
String contentType = MediaType.APPLICATION_PDF_VALUE;
|
String contentType = "application/pdf";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
java.lang.reflect.Method getOriginalFileName =
|
java.lang.reflect.Method getOriginalFileName =
|
||||||
@@ -462,8 +432,9 @@ public class JobExecutorService {
|
|||||||
HttpHeaders.CONTENT_DISPOSITION,
|
HttpHeaders.CONTENT_DISPOSITION,
|
||||||
"form-data; name=\"attachment\"; filename=\"result.pdf\"")
|
"form-data; name=\"attachment\"; filename=\"result.pdf\"")
|
||||||
.body(result);
|
.body(result);
|
||||||
} else if (result instanceof MultipartFile file) {
|
} else if (result instanceof MultipartFile) {
|
||||||
// Return MultipartFile content
|
// Return MultipartFile content
|
||||||
|
MultipartFile file = (MultipartFile) result;
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
.contentType(MediaType.parseMediaType(file.getContentType()))
|
.contentType(MediaType.parseMediaType(file.getContentType()))
|
||||||
.header(
|
.header(
|
||||||
@@ -490,16 +461,8 @@ public class JobExecutorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String value =
|
String value = timeout.replaceAll("[^\\d.]", "");
|
||||||
RegexPatternUtils.getInstance()
|
String unit = timeout.replaceAll("[\\d.]", "");
|
||||||
.getNonDigitDotPattern()
|
|
||||||
.matcher(timeout)
|
|
||||||
.replaceAll("");
|
|
||||||
String unit =
|
|
||||||
RegexPatternUtils.getInstance()
|
|
||||||
.getDigitDotPattern()
|
|
||||||
.matcher(timeout)
|
|
||||||
.replaceAll("");
|
|
||||||
|
|
||||||
double numericValue = Double.parseDouble(value);
|
double numericValue = Double.parseDouble(value);
|
||||||
|
|
||||||
@@ -525,27 +488,14 @@ public class JobExecutorService {
|
|||||||
* @throws TimeoutException If the execution times out
|
* @throws TimeoutException If the execution times out
|
||||||
* @throws Exception If the supplier throws an exception
|
* @throws Exception If the supplier throws an exception
|
||||||
*/
|
*/
|
||||||
private <T> T executeWithTimeout(Supplier<T> supplier, long timeoutMs)
|
private <T> T executeWithTimeout(
|
||||||
|
Supplier<T> supplier, long timeoutMs, String jobId, boolean progressEnabled)
|
||||||
throws TimeoutException, Exception {
|
throws TimeoutException, Exception {
|
||||||
// Use the same executor as other async jobs for consistency
|
// Use the same executor as other async jobs for consistency
|
||||||
// This ensures all operations run on the same thread pool
|
// This ensures all operations run on the same thread pool
|
||||||
String currentJobId = stirling.software.common.util.JobContext.getJobId();
|
|
||||||
|
|
||||||
java.util.concurrent.CompletableFuture<T> future =
|
java.util.concurrent.CompletableFuture<T> future =
|
||||||
java.util.concurrent.CompletableFuture.supplyAsync(
|
java.util.concurrent.CompletableFuture.supplyAsync(
|
||||||
() -> {
|
withJobContext(jobId, progressEnabled, supplier), executor);
|
||||||
if (currentJobId != null) {
|
|
||||||
stirling.software.common.util.JobContext.setJobId(currentJobId);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return supplier.get();
|
|
||||||
} finally {
|
|
||||||
if (currentJobId != null) {
|
|
||||||
stirling.software.common.util.JobContext.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
executor);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return future.get(timeoutMs, TimeUnit.MILLISECONDS);
|
return future.get(timeoutMs, TimeUnit.MILLISECONDS);
|
||||||
@@ -562,17 +512,61 @@ public class JobExecutorService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Backwards compatible helper used by tests via reflection. */
|
||||||
* Get a scoped job key that includes user ownership when security is enabled.
|
@SuppressWarnings("unused")
|
||||||
*
|
private <T> T executeWithTimeout(Supplier<T> supplier, long timeoutMs)
|
||||||
* @param baseJobId the base job identifier
|
throws TimeoutException, Exception {
|
||||||
* @return scoped job key, or just baseJobId if no ownership service available
|
return executeWithTimeout(
|
||||||
*/
|
supplier,
|
||||||
private String getScopedJobKey(String baseJobId) {
|
timeoutMs,
|
||||||
if (jobOwnershipService != null) {
|
JobContextHolder.getJobId(),
|
||||||
return jobOwnershipService.createScopedJobKey(baseJobId);
|
JobContextHolder.isProgressEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> Supplier<T> withJobContext(
|
||||||
|
String jobId, boolean progressEnabled, Supplier<T> delegate) {
|
||||||
|
if (jobId == null) {
|
||||||
|
return delegate;
|
||||||
}
|
}
|
||||||
// Security disabled, return unsecured job key
|
return () -> {
|
||||||
return baseJobId;
|
String previousJobId = JobContextHolder.getJobId();
|
||||||
|
boolean previousProgress = JobContextHolder.isProgressEnabled();
|
||||||
|
|
||||||
|
JobContextHolder.setContext(jobId, progressEnabled);
|
||||||
|
try {
|
||||||
|
return delegate.get();
|
||||||
|
} finally {
|
||||||
|
if (previousJobId == null) {
|
||||||
|
JobContextHolder.clear();
|
||||||
|
} else {
|
||||||
|
JobContextHolder.setContext(previousJobId, previousProgress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runWithJobContext(String jobId, boolean progressEnabled, Runnable runnable) {
|
||||||
|
if (jobId == null) {
|
||||||
|
runnable.run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Runnable contextualRunnable =
|
||||||
|
() -> {
|
||||||
|
String previousJobId = JobContextHolder.getJobId();
|
||||||
|
boolean previousProgress = JobContextHolder.isProgressEnabled();
|
||||||
|
|
||||||
|
JobContextHolder.setContext(jobId, progressEnabled);
|
||||||
|
try {
|
||||||
|
runnable.run();
|
||||||
|
} finally {
|
||||||
|
if (previousJobId == null) {
|
||||||
|
JobContextHolder.clear();
|
||||||
|
} else {
|
||||||
|
JobContextHolder.setContext(previousJobId, previousProgress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
contextualRunnable.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
package stirling.software.common.service;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Service interface for managing job ownership and access control. Implementations can provide
|
|
||||||
* user-scoped job isolation when security is enabled, or no-op behavior when security is disabled.
|
|
||||||
*/
|
|
||||||
public interface JobOwnershipService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current authenticated user's identifier.
|
|
||||||
*
|
|
||||||
* @return Optional containing user identifier, or empty if not authenticated
|
|
||||||
*/
|
|
||||||
Optional<String> getCurrentUserId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a scoped job key that includes user ownership when security is enabled.
|
|
||||||
*
|
|
||||||
* @param jobId the base job identifier
|
|
||||||
* @return scoped job key in format "userId:jobId", or just jobId if no user authenticated
|
|
||||||
*/
|
|
||||||
String createScopedJobKey(String jobId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate that the current user has access to the given job.
|
|
||||||
*
|
|
||||||
* @param scopedJobKey the scoped job key to validate
|
|
||||||
* @return true if current user owns the job or no authentication is required
|
|
||||||
* @throws SecurityException if current user does not own the job
|
|
||||||
*/
|
|
||||||
boolean validateJobAccess(String scopedJobKey);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract the base job ID from a scoped job key.
|
|
||||||
*
|
|
||||||
* @param scopedJobKey the scoped job key
|
|
||||||
* @return the base job ID without user prefix
|
|
||||||
*/
|
|
||||||
String extractJobId(String scopedJobKey);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package stirling.software.common.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import stirling.software.common.context.JobContextHolder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience service that exposes a simple API for updating progress information from within job
|
||||||
|
* handlers executed through {@link JobExecutorService}. The service automatically ties progress
|
||||||
|
* updates to the current job (if any) and no-ops when progress tracking is disabled.
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class JobProgressService {
|
||||||
|
|
||||||
|
private final TaskManager taskManager;
|
||||||
|
|
||||||
|
/** Update the progress percentage for the current job. */
|
||||||
|
public boolean updateProgress(int percent, String message) {
|
||||||
|
String jobId = JobContextHolder.getJobId();
|
||||||
|
if (jobId == null || !JobContextHolder.isProgressEnabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return taskManager.updateProgress(jobId, percent, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a simple tracker that can be used to report progress across a fixed number of steps.
|
||||||
|
* When progress tracking is disabled for the current job, the returned tracker will be a
|
||||||
|
* lightweight no-op implementation.
|
||||||
|
*/
|
||||||
|
public JobProgressTracker tracker(int totalSteps) {
|
||||||
|
return tracker(totalSteps, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a tracker and optionally publish an initial message. Useful for multi-stage pipelines
|
||||||
|
* where the initial state should be visible to clients.
|
||||||
|
*/
|
||||||
|
public JobProgressTracker tracker(int totalSteps, String initialMessage) {
|
||||||
|
String jobId = JobContextHolder.getJobId();
|
||||||
|
boolean enabled = JobContextHolder.isProgressEnabled();
|
||||||
|
|
||||||
|
if (jobId == null || !enabled || totalSteps <= 0) {
|
||||||
|
return JobProgressTracker.disabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (initialMessage != null && !initialMessage.isBlank()) {
|
||||||
|
taskManager.updateProgress(jobId, 0, initialMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new JobProgressTracker(taskManager, jobId, totalSteps, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package stirling.software.common.service;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility that helps controllers report progress in a structured way by distributing the 0-100%
|
||||||
|
* range across a finite number of logical steps.
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||||
|
public class JobProgressTracker {
|
||||||
|
|
||||||
|
private final TaskManager taskManager;
|
||||||
|
private final String jobId;
|
||||||
|
private final int totalSteps;
|
||||||
|
private final boolean enabled;
|
||||||
|
|
||||||
|
private int completedSteps;
|
||||||
|
|
||||||
|
static JobProgressTracker disabled() {
|
||||||
|
return new JobProgressTracker(null, null, 1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether the tracker will emit updates. */
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Advance the tracker by one step. */
|
||||||
|
public void advance() {
|
||||||
|
advanceBy(1, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Advance the tracker by {@code steps} steps. */
|
||||||
|
public void advanceBy(int steps, String message) {
|
||||||
|
if (!enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int safeSteps = Math.max(0, steps);
|
||||||
|
completedSteps = Math.min(totalSteps, completedSteps + safeSteps);
|
||||||
|
publish(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Advance the tracker by {@code steps} steps without a message. */
|
||||||
|
public void advanceBy(int steps) {
|
||||||
|
advanceBy(steps, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Explicitly set the completed steps count. */
|
||||||
|
public void setStepsCompleted(int stepsCompleted, String message) {
|
||||||
|
if (!enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completedSteps = Math.max(0, Math.min(totalSteps, stepsCompleted));
|
||||||
|
publish(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Explicitly set completed steps without a message. */
|
||||||
|
public void setStepsCompleted(int stepsCompleted) {
|
||||||
|
setStepsCompleted(stepsCompleted, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Mark the tracker as complete and emit a final message. */
|
||||||
|
public void complete(String message) {
|
||||||
|
if (!enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
completedSteps = totalSteps;
|
||||||
|
taskManager.updateProgress(jobId, 100, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Mark the tracker as complete without a message. */
|
||||||
|
public void complete() {
|
||||||
|
complete(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void publish(String message) {
|
||||||
|
int percent = (int) Math.floor(((double) completedSteps / (double) totalSteps) * 100);
|
||||||
|
taskManager.updateProgress(jobId, percent, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package stirling.software.common.service;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
|
|
||||||
|
|
||||||
public interface LineArtConversionService {
|
|
||||||
PDImageXObject convertImageToLineArt(
|
|
||||||
PDDocument doc, PDImageXObject originalImage, double threshold, int edgeLevel)
|
|
||||||
throws IOException;
|
|
||||||
}
|
|
||||||
@@ -1,438 +0,0 @@
|
|||||||
package stirling.software.common.service;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Service for handling mobile scanner file uploads and temporary storage. Files are stored
|
|
||||||
* temporarily and automatically cleaned up after 10 minutes or upon retrieval.
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@Slf4j
|
|
||||||
public class MobileScannerService {
|
|
||||||
|
|
||||||
private static final long SESSION_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes
|
|
||||||
private final Map<String, SessionData> activeSessions = new ConcurrentHashMap<>();
|
|
||||||
private final Path tempDirectory;
|
|
||||||
|
|
||||||
public MobileScannerService() throws IOException {
|
|
||||||
// Create temp directory for mobile scanner uploads
|
|
||||||
this.tempDirectory =
|
|
||||||
Paths.get(System.getProperty("java.io.tmpdir"), "stirling-mobile-scanner");
|
|
||||||
Files.createDirectories(tempDirectory);
|
|
||||||
log.info("Mobile scanner temp directory: {}", tempDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a new session (called by desktop when QR code is generated)
|
|
||||||
*
|
|
||||||
* @param sessionId Unique session identifier
|
|
||||||
* @return SessionInfo with creation time and expiry
|
|
||||||
*/
|
|
||||||
public SessionInfo createSession(String sessionId) {
|
|
||||||
validateSessionId(sessionId);
|
|
||||||
|
|
||||||
SessionData session = new SessionData(sessionId);
|
|
||||||
activeSessions.put(sessionId, session);
|
|
||||||
|
|
||||||
log.info("Created mobile scanner session: {}", sessionId);
|
|
||||||
return new SessionInfo(
|
|
||||||
sessionId,
|
|
||||||
session.createdAt,
|
|
||||||
session.createdAt + SESSION_TIMEOUT_MS,
|
|
||||||
SESSION_TIMEOUT_MS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate if a session exists and is not expired
|
|
||||||
*
|
|
||||||
* @param sessionId Session identifier to validate
|
|
||||||
* @return SessionInfo if valid, null if invalid/expired
|
|
||||||
*/
|
|
||||||
public SessionInfo validateSession(String sessionId) {
|
|
||||||
SessionData session = activeSessions.get(sessionId);
|
|
||||||
if (session == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
|
||||||
long expiryTime = session.getLastAccessTime() + SESSION_TIMEOUT_MS;
|
|
||||||
|
|
||||||
// Check if expired
|
|
||||||
if (now > expiryTime) {
|
|
||||||
deleteSession(sessionId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
session.updateLastAccess();
|
|
||||||
return new SessionInfo(sessionId, session.createdAt, expiryTime, SESSION_TIMEOUT_MS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores uploaded files for a session
|
|
||||||
*
|
|
||||||
* @param sessionId Unique session identifier
|
|
||||||
* @param files Files to upload
|
|
||||||
* @throws IOException If file storage fails
|
|
||||||
*/
|
|
||||||
public void uploadFiles(String sessionId, List<MultipartFile> files) throws IOException {
|
|
||||||
validateSessionId(sessionId);
|
|
||||||
|
|
||||||
SessionData session =
|
|
||||||
activeSessions.computeIfAbsent(sessionId, id -> new SessionData(sessionId));
|
|
||||||
|
|
||||||
// Create session directory
|
|
||||||
Path sessionDir = getSafeSessionDirectory(sessionId);
|
|
||||||
Files.createDirectories(sessionDir);
|
|
||||||
|
|
||||||
// Save each file
|
|
||||||
for (MultipartFile file : files) {
|
|
||||||
if (file.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String originalFilename = file.getOriginalFilename();
|
|
||||||
if (originalFilename == null || originalFilename.isBlank()) {
|
|
||||||
originalFilename = "upload-" + System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sanitize filename
|
|
||||||
String safeFilename = sanitizeFilename(originalFilename);
|
|
||||||
Path filePath = sessionDir.resolve(safeFilename).normalize().toAbsolutePath();
|
|
||||||
|
|
||||||
// Ensure resulting path stays within the session directory
|
|
||||||
if (!filePath.startsWith(sessionDir)) {
|
|
||||||
throw new IOException("Invalid filename");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle duplicate filenames
|
|
||||||
int counter = 1;
|
|
||||||
while (Files.exists(filePath)) {
|
|
||||||
String nameWithoutExt = safeFilename.replaceFirst("[.][^.]+$", "");
|
|
||||||
String ext =
|
|
||||||
safeFilename.contains(".")
|
|
||||||
? safeFilename.substring(safeFilename.lastIndexOf("."))
|
|
||||||
: "";
|
|
||||||
safeFilename = nameWithoutExt + "-" + counter + ext;
|
|
||||||
filePath = sessionDir.resolve(safeFilename).normalize().toAbsolutePath();
|
|
||||||
if (!filePath.startsWith(sessionDir)) {
|
|
||||||
throw new IOException("Invalid filename");
|
|
||||||
}
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.transferTo(filePath);
|
|
||||||
session.addFile(new FileMetadata(safeFilename, file.getSize(), file.getContentType()));
|
|
||||||
log.info(
|
|
||||||
"Uploaded file for session {}: {} ({} bytes)",
|
|
||||||
sessionId,
|
|
||||||
safeFilename,
|
|
||||||
file.getSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
session.updateLastAccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves file metadata for a session
|
|
||||||
*
|
|
||||||
* @param sessionId Session identifier
|
|
||||||
* @return List of file metadata, or empty list if session doesn't exist
|
|
||||||
*/
|
|
||||||
public List<FileMetadata> getSessionFiles(String sessionId) {
|
|
||||||
SessionData session = activeSessions.get(sessionId);
|
|
||||||
if (session == null) {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
session.updateLastAccess();
|
|
||||||
return new ArrayList<>(session.getFiles());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves actual file data for download
|
|
||||||
*
|
|
||||||
* @param sessionId Session identifier
|
|
||||||
* @param filename Filename to retrieve
|
|
||||||
* @return File path
|
|
||||||
* @throws IOException If file not found or session doesn't exist
|
|
||||||
*/
|
|
||||||
public Path getFile(String sessionId, String filename) throws IOException {
|
|
||||||
SessionData session = activeSessions.get(sessionId);
|
|
||||||
if (session == null) {
|
|
||||||
throw new IOException("Session not found: " + sessionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
Path filePath = getSafeFilePath(sessionId, filename);
|
|
||||||
if (!Files.exists(filePath)) {
|
|
||||||
throw new IOException("File not found: " + filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
session.updateLastAccess();
|
|
||||||
session.markFileAsDownloaded(filename);
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a file after it has been served to the client. Should be called after successful
|
|
||||||
* download.
|
|
||||||
*
|
|
||||||
* @param sessionId Session identifier
|
|
||||||
* @param filename Filename to delete
|
|
||||||
*/
|
|
||||||
public void deleteFileAfterDownload(String sessionId, String filename) {
|
|
||||||
try {
|
|
||||||
Path filePath = getSafeFilePath(sessionId, filename);
|
|
||||||
Files.deleteIfExists(filePath);
|
|
||||||
log.info("Deleted file after download: {}/{}", sessionId, filename);
|
|
||||||
|
|
||||||
// Check if all files have been downloaded - if so, delete the entire session
|
|
||||||
SessionData session = activeSessions.get(sessionId);
|
|
||||||
if (session != null && session.allFilesDownloaded()) {
|
|
||||||
deleteSession(sessionId);
|
|
||||||
log.info("All files downloaded - deleted session: {}", sessionId);
|
|
||||||
}
|
|
||||||
} catch (IOException | IllegalArgumentException e) {
|
|
||||||
log.warn("Failed to delete file after download: {}/{}", sessionId, filename, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a session and all its files
|
|
||||||
*
|
|
||||||
* @param sessionId Session to delete
|
|
||||||
*/
|
|
||||||
public void deleteSession(String sessionId) {
|
|
||||||
SessionData session = activeSessions.remove(sessionId);
|
|
||||||
if (session != null) {
|
|
||||||
try {
|
|
||||||
Path sessionDir = getSafeSessionDirectory(sessionId);
|
|
||||||
if (Files.exists(sessionDir)) {
|
|
||||||
// Delete all files in session directory
|
|
||||||
Files.walk(sessionDir)
|
|
||||||
.sorted(
|
|
||||||
(a, b) ->
|
|
||||||
-a.compareTo(b)) // Reverse order to delete files before
|
|
||||||
// directory
|
|
||||||
.forEach(
|
|
||||||
path -> {
|
|
||||||
try {
|
|
||||||
Files.deleteIfExists(path);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Failed to delete file: {}", path, e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
log.info("Deleted session: {}", sessionId);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
log.warn(
|
|
||||||
"Refused to delete session with invalid sessionId '{}': {}",
|
|
||||||
sessionId,
|
|
||||||
e.getMessage());
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("Error deleting session directory: {}", sessionId, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Scheduled cleanup of expired sessions (runs every 5 minutes) */
|
|
||||||
@Scheduled(fixedRate = 5 * 60 * 1000)
|
|
||||||
public void cleanupExpiredSessions() {
|
|
||||||
long now = System.currentTimeMillis();
|
|
||||||
List<String> expiredSessions = new ArrayList<>();
|
|
||||||
|
|
||||||
activeSessions.forEach(
|
|
||||||
(sessionId, session) -> {
|
|
||||||
if (now - session.getLastAccessTime() > SESSION_TIMEOUT_MS) {
|
|
||||||
expiredSessions.add(sessionId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!expiredSessions.isEmpty()) {
|
|
||||||
log.info("Cleaning up {} expired mobile scanner sessions", expiredSessions.size());
|
|
||||||
expiredSessions.forEach(this::deleteSession);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateSessionId(String sessionId) {
|
|
||||||
if (sessionId == null || sessionId.isBlank()) {
|
|
||||||
throw new IllegalArgumentException("Session ID cannot be empty");
|
|
||||||
}
|
|
||||||
// Basic validation: alphanumeric and hyphens only
|
|
||||||
if (!sessionId.matches("[a-zA-Z0-9-]+")) {
|
|
||||||
throw new IllegalArgumentException("Invalid session ID format");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String sanitizeFilename(String filename) {
|
|
||||||
// Remove path traversal attempts and dangerous characters
|
|
||||||
String sanitized = filename.replaceAll("[^a-zA-Z0-9._-]", "_");
|
|
||||||
// Ensure we have a non-empty, safe filename
|
|
||||||
if (sanitized.isBlank()) {
|
|
||||||
sanitized = "upload-" + System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
return sanitized;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Safely resolves and validates a session directory path to prevent directory traversal
|
|
||||||
* attacks.
|
|
||||||
*
|
|
||||||
* @param sessionId Session identifier
|
|
||||||
* @return Normalized absolute path to the session directory
|
|
||||||
* @throws IllegalArgumentException if the resolved path escapes the temp directory
|
|
||||||
*/
|
|
||||||
private Path getSafeSessionDirectory(String sessionId) {
|
|
||||||
validateSessionId(sessionId);
|
|
||||||
|
|
||||||
Path baseDir = tempDirectory.normalize().toAbsolutePath();
|
|
||||||
Path sessionDir = baseDir.resolve(sessionId).normalize().toAbsolutePath();
|
|
||||||
|
|
||||||
// Verify the resolved path is still within the temp directory
|
|
||||||
if (!sessionDir.startsWith(baseDir)) {
|
|
||||||
throw new IllegalArgumentException("Invalid session ID: path traversal detected");
|
|
||||||
}
|
|
||||||
|
|
||||||
return sessionDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Safely resolves and validates a file path within a session directory to prevent directory
|
|
||||||
* traversal attacks.
|
|
||||||
*
|
|
||||||
* @param sessionId Session identifier
|
|
||||||
* @param filename Filename within the session
|
|
||||||
* @return Normalized absolute path to the file
|
|
||||||
* @throws IOException if the resolved path escapes the session directory
|
|
||||||
*/
|
|
||||||
private Path getSafeFilePath(String sessionId, String filename) throws IOException {
|
|
||||||
if (filename == null || filename.isBlank()) {
|
|
||||||
throw new IOException("Filename cannot be empty");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Additional validation: reject filenames with path separators or parent references
|
|
||||||
if (filename.contains("..") || filename.contains("/") || filename.contains("\\")) {
|
|
||||||
throw new IOException(
|
|
||||||
"Invalid filename: contains path separators or parent references");
|
|
||||||
}
|
|
||||||
|
|
||||||
Path sessionDir = getSafeSessionDirectory(sessionId);
|
|
||||||
Path filePath = sessionDir.resolve(filename).normalize().toAbsolutePath();
|
|
||||||
|
|
||||||
// Verify the resolved path is still within the session directory
|
|
||||||
if (!filePath.startsWith(sessionDir)) {
|
|
||||||
throw new IOException("Invalid filename: path traversal detected");
|
|
||||||
}
|
|
||||||
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Session information for client */
|
|
||||||
public static class SessionInfo {
|
|
||||||
private final String sessionId;
|
|
||||||
private final long createdAt;
|
|
||||||
private final long expiresAt;
|
|
||||||
private final long timeoutMs;
|
|
||||||
|
|
||||||
public SessionInfo(String sessionId, long createdAt, long expiresAt, long timeoutMs) {
|
|
||||||
this.sessionId = sessionId;
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
this.expiresAt = expiresAt;
|
|
||||||
this.timeoutMs = timeoutMs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSessionId() {
|
|
||||||
return sessionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCreatedAt() {
|
|
||||||
return createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getExpiresAt() {
|
|
||||||
return expiresAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimeoutMs() {
|
|
||||||
return timeoutMs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** File metadata for client */
|
|
||||||
public static class FileMetadata {
|
|
||||||
private final String filename;
|
|
||||||
private final long size;
|
|
||||||
private final String contentType;
|
|
||||||
|
|
||||||
public FileMetadata(String filename, long size, String contentType) {
|
|
||||||
this.filename = filename;
|
|
||||||
this.size = size;
|
|
||||||
this.contentType = contentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFilename() {
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSize() {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContentType() {
|
|
||||||
return contentType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Session data tracking */
|
|
||||||
private static class SessionData {
|
|
||||||
private final String sessionId;
|
|
||||||
private final List<FileMetadata> files = new ArrayList<>();
|
|
||||||
private final Map<String, Boolean> downloadedFiles = new HashMap<>();
|
|
||||||
private final long createdAt;
|
|
||||||
private long lastAccessTime;
|
|
||||||
|
|
||||||
public SessionData(String sessionId) {
|
|
||||||
this.sessionId = sessionId;
|
|
||||||
this.createdAt = System.currentTimeMillis();
|
|
||||||
this.lastAccessTime = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFile(FileMetadata file) {
|
|
||||||
files.add(file);
|
|
||||||
downloadedFiles.put(file.getFilename(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FileMetadata> getFiles() {
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markFileAsDownloaded(String filename) {
|
|
||||||
downloadedFiles.put(filename, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean allFilesDownloaded() {
|
|
||||||
return !downloadedFiles.isEmpty()
|
|
||||||
&& downloadedFiles.values().stream().allMatch(downloaded -> downloaded);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateLastAccess() {
|
|
||||||
this.lastAccessTime = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLastAccessTime() {
|
|
||||||
return lastAccessTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
package stirling.software.common.service;
|
package stirling.software.common.service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
@@ -33,19 +29,17 @@ public class PdfMetadataService {
|
|||||||
this.runningProOrHigher = runningProOrHigher;
|
this.runningProOrHigher = runningProOrHigher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public PdfMetadata extractMetadataFromPdf(PDDocument pdf) {
|
||||||
* Converts ZonedDateTime to Calendar for PDFBox compatibility.
|
return PdfMetadata.builder()
|
||||||
*
|
.author(pdf.getDocumentInformation().getAuthor())
|
||||||
* @param zonedDateTime the ZonedDateTime to convert
|
.producer(pdf.getDocumentInformation().getProducer())
|
||||||
* @return Calendar instance or null if input is null
|
.title(pdf.getDocumentInformation().getTitle())
|
||||||
*/
|
.creator(pdf.getDocumentInformation().getCreator())
|
||||||
public static Calendar toCalendar(ZonedDateTime zonedDateTime) {
|
.subject(pdf.getDocumentInformation().getSubject())
|
||||||
if (zonedDateTime == null) {
|
.keywords(pdf.getDocumentInformation().getKeywords())
|
||||||
return null;
|
.creationDate(pdf.getDocumentInformation().getCreationDate())
|
||||||
}
|
.modificationDate(pdf.getDocumentInformation().getModificationDate())
|
||||||
Calendar calendar = Calendar.getInstance();
|
.build();
|
||||||
calendar.setTimeInMillis(zonedDateTime.toInstant().toEpochMilli());
|
|
||||||
return calendar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultMetadata(PDDocument pdf) {
|
public void setDefaultMetadata(PDDocument pdf) {
|
||||||
@@ -64,52 +58,6 @@ public class PdfMetadataService {
|
|||||||
setCommonMetadata(pdf, pdfMetadata);
|
setCommonMetadata(pdf, pdfMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses a date string and converts it to Calendar for PDFBox compatibility.
|
|
||||||
*
|
|
||||||
* @param dateString the date string in "yyyy/MM/dd HH:mm:ss" format
|
|
||||||
* @return Calendar instance or null if parsing fails or input is empty
|
|
||||||
*/
|
|
||||||
public static Calendar parseToCalendar(String dateString) {
|
|
||||||
if (dateString == null || dateString.trim().isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
|
||||||
ZonedDateTime zonedDateTime =
|
|
||||||
LocalDateTime.parse(dateString, formatter).atZone(ZoneId.systemDefault());
|
|
||||||
return toCalendar(zonedDateTime);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PdfMetadata extractMetadataFromPdf(PDDocument pdf) {
|
|
||||||
Calendar creationCal = pdf.getDocumentInformation().getCreationDate();
|
|
||||||
Calendar modificationCal = pdf.getDocumentInformation().getModificationDate();
|
|
||||||
|
|
||||||
ZonedDateTime creationDate =
|
|
||||||
creationCal != null
|
|
||||||
? ZonedDateTime.ofInstant(creationCal.toInstant(), ZoneId.systemDefault())
|
|
||||||
: null;
|
|
||||||
ZonedDateTime modificationDate =
|
|
||||||
modificationCal != null
|
|
||||||
? ZonedDateTime.ofInstant(
|
|
||||||
modificationCal.toInstant(), ZoneId.systemDefault())
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return PdfMetadata.builder()
|
|
||||||
.author(pdf.getDocumentInformation().getAuthor())
|
|
||||||
.producer(pdf.getDocumentInformation().getProducer())
|
|
||||||
.title(pdf.getDocumentInformation().getTitle())
|
|
||||||
.creator(pdf.getDocumentInformation().getCreator())
|
|
||||||
.subject(pdf.getDocumentInformation().getSubject())
|
|
||||||
.keywords(pdf.getDocumentInformation().getKeywords())
|
|
||||||
.creationDate(creationDate)
|
|
||||||
.modificationDate(modificationDate)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setNewDocumentMetadata(PDDocument pdf, PdfMetadata pdfMetadata) {
|
private void setNewDocumentMetadata(PDDocument pdf, PdfMetadata pdfMetadata) {
|
||||||
|
|
||||||
String creator = stirlingPDFLabel;
|
String creator = stirlingPDFLabel;
|
||||||
@@ -131,13 +79,7 @@ public class PdfMetadataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pdf.getDocumentInformation().setCreator(creator);
|
pdf.getDocumentInformation().setCreator(creator);
|
||||||
|
pdf.getDocumentInformation().setCreationDate(Calendar.getInstance());
|
||||||
// Use existing creation date if available, otherwise create new one
|
|
||||||
Calendar creationCal =
|
|
||||||
pdfMetadata.getCreationDate() != null
|
|
||||||
? toCalendar(pdfMetadata.getCreationDate())
|
|
||||||
: Calendar.getInstance();
|
|
||||||
pdf.getDocumentInformation().setCreationDate(creationCal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCommonMetadata(PDDocument pdf, PdfMetadata pdfMetadata) {
|
private void setCommonMetadata(PDDocument pdf, PdfMetadata pdfMetadata) {
|
||||||
@@ -146,13 +88,7 @@ public class PdfMetadataService {
|
|||||||
pdf.getDocumentInformation().setProducer(stirlingPDFLabel);
|
pdf.getDocumentInformation().setProducer(stirlingPDFLabel);
|
||||||
pdf.getDocumentInformation().setSubject(pdfMetadata.getSubject());
|
pdf.getDocumentInformation().setSubject(pdfMetadata.getSubject());
|
||||||
pdf.getDocumentInformation().setKeywords(pdfMetadata.getKeywords());
|
pdf.getDocumentInformation().setKeywords(pdfMetadata.getKeywords());
|
||||||
|
pdf.getDocumentInformation().setModificationDate(Calendar.getInstance());
|
||||||
// Convert ZonedDateTime to Calendar for PDFBox compatibility
|
|
||||||
Calendar modificationCal =
|
|
||||||
pdfMetadata.getModificationDate() != null
|
|
||||||
? toCalendar(pdfMetadata.getModificationDate())
|
|
||||||
: Calendar.getInstance();
|
|
||||||
pdf.getDocumentInformation().setModificationDate(modificationCal);
|
|
||||||
|
|
||||||
String author = pdfMetadata.getAuthor();
|
String author = pdfMetadata.getAuthor();
|
||||||
if (applicationProperties
|
if (applicationProperties
|
||||||
|
|||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
package stirling.software.common.service;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for personal signature access (proprietary feature). Implemented only in proprietary
|
|
||||||
* module to provide authenticated users access to their personal signatures.
|
|
||||||
*/
|
|
||||||
public interface PersonalSignatureServiceInterface {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a personal signature from the user's folder. Only checks personal folder, not shared
|
|
||||||
* folder.
|
|
||||||
*
|
|
||||||
* @param username Username of the signature owner
|
|
||||||
* @param fileName Signature filename
|
|
||||||
* @return Personal signature image bytes
|
|
||||||
* @throws IOException If file not found or read error
|
|
||||||
*/
|
|
||||||
byte[] getPersonalSignatureBytes(String username, String fileName) throws IOException;
|
|
||||||
}
|
|
||||||
@@ -56,7 +56,7 @@ public class PostHogService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void captureSystemInfo() {
|
private void captureSystemInfo() {
|
||||||
if (!applicationProperties.getSystem().isPosthogEnabled()) {
|
if (!applicationProperties.getSystem().isAnalyticsEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -67,7 +67,7 @@ public class PostHogService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void captureEvent(String eventName, Map<String, Object> properties) {
|
public void captureEvent(String eventName, Map<String, Object> properties) {
|
||||||
if (!applicationProperties.getSystem().isPosthogEnabled()) {
|
if (!applicationProperties.getSystem().isAnalyticsEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,8 +253,11 @@ public class PostHogService {
|
|||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"security_enableLogin",
|
"security_enableLogin",
|
||||||
applicationProperties.getSecurity().isEnableLogin());
|
applicationProperties.getSecurity().getEnableLogin());
|
||||||
addIfNotEmpty(properties, "security_csrfDisabled", true);
|
addIfNotEmpty(
|
||||||
|
properties,
|
||||||
|
"security_csrfDisabled",
|
||||||
|
applicationProperties.getSecurity().getCsrfDisabled());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"security_loginAttemptCount",
|
"security_loginAttemptCount",
|
||||||
@@ -299,13 +302,13 @@ public class PostHogService {
|
|||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"system_googlevisibility",
|
"system_googlevisibility",
|
||||||
applicationProperties.getSystem().isGooglevisibility());
|
applicationProperties.getSystem().getGooglevisibility());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties, "system_showUpdate", applicationProperties.getSystem().isShowUpdate());
|
properties, "system_showUpdate", applicationProperties.getSystem().isShowUpdate());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"system_showUpdateOnlyAdmin",
|
"system_showUpdateOnlyAdmin",
|
||||||
applicationProperties.getSystem().isShowUpdateOnlyAdmin());
|
applicationProperties.getSystem().getShowUpdateOnlyAdmin());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"system_customHTMLFiles",
|
"system_customHTMLFiles",
|
||||||
@@ -317,27 +320,24 @@ public class PostHogService {
|
|||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"system_enableAlphaFunctionality",
|
"system_enableAlphaFunctionality",
|
||||||
applicationProperties.getSystem().isEnableAlphaFunctionality());
|
applicationProperties.getSystem().getEnableAlphaFunctionality());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"system_enableAnalytics",
|
"system_enableAnalytics",
|
||||||
applicationProperties.getSystem().isAnalyticsEnabled());
|
applicationProperties.getSystem().isAnalyticsEnabled());
|
||||||
addIfNotEmpty(
|
|
||||||
properties,
|
|
||||||
"system_enablePosthog",
|
|
||||||
applicationProperties.getSystem().isPosthogEnabled());
|
|
||||||
addIfNotEmpty(
|
|
||||||
properties,
|
|
||||||
"system_enableScarf",
|
|
||||||
applicationProperties.getSystem().isScarfEnabled());
|
|
||||||
|
|
||||||
// Capture UI properties
|
// Capture UI properties
|
||||||
|
addIfNotEmpty(properties, "ui_appName", applicationProperties.getUi().getAppName());
|
||||||
|
addIfNotEmpty(
|
||||||
|
properties,
|
||||||
|
"ui_homeDescription",
|
||||||
|
applicationProperties.getUi().getHomeDescription());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties, "ui_appNameNavbar", applicationProperties.getUi().getAppNameNavbar());
|
properties, "ui_appNameNavbar", applicationProperties.getUi().getAppNameNavbar());
|
||||||
|
|
||||||
// Capture Metrics properties
|
// Capture Metrics properties
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties, "metrics_enabled", applicationProperties.getMetrics().isEnabled());
|
properties, "metrics_enabled", applicationProperties.getMetrics().getEnabled());
|
||||||
|
|
||||||
// Capture EnterpriseEdition properties
|
// Capture EnterpriseEdition properties
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import java.lang.management.MemoryMXBean;
|
|||||||
import java.lang.management.OperatingSystemMXBean;
|
import java.lang.management.OperatingSystemMXBean;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -174,8 +173,8 @@ public class ResourceMonitor {
|
|||||||
log.info("System resource status changed from {} to {}", oldStatus, newStatus);
|
log.info("System resource status changed from {} to {}", oldStatus, newStatus);
|
||||||
log.info(
|
log.info(
|
||||||
"Current metrics - CPU: {}%, Memory: {}%, Free Memory: {} MB",
|
"Current metrics - CPU: {}%, Memory: {}%, Free Memory: {} MB",
|
||||||
String.format(Locale.ROOT, "%.1f", cpuUsage * 100),
|
String.format("%.1f", cpuUsage * 100),
|
||||||
String.format(Locale.ROOT, "%.1f", memoryUsage * 100),
|
String.format("%.1f", memoryUsage * 100),
|
||||||
freeMemory / (1024 * 1024));
|
freeMemory / (1024 * 1024));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
+27
-91
@@ -1,11 +1,8 @@
|
|||||||
package stirling.software.common.service;
|
package stirling.software.common.service;
|
||||||
|
|
||||||
import java.net.Inet4Address;
|
|
||||||
import java.net.Inet6Address;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -14,7 +11,6 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import stirling.software.common.model.ApplicationProperties;
|
import stirling.software.common.model.ApplicationProperties;
|
||||||
import stirling.software.common.util.RegexPatternUtils;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -24,9 +20,8 @@ public class SsrfProtectionService {
|
|||||||
private final ApplicationProperties applicationProperties;
|
private final ApplicationProperties applicationProperties;
|
||||||
|
|
||||||
private static final Pattern DATA_URL_PATTERN =
|
private static final Pattern DATA_URL_PATTERN =
|
||||||
RegexPatternUtils.getInstance().getPattern("^data:.*", Pattern.CASE_INSENSITIVE);
|
Pattern.compile("^data:.*", Pattern.CASE_INSENSITIVE);
|
||||||
private static final Pattern FRAGMENT_PATTERN =
|
private static final Pattern FRAGMENT_PATTERN = Pattern.compile("^#.*");
|
||||||
RegexPatternUtils.getInstance().getPattern("^#.*");
|
|
||||||
|
|
||||||
public enum SsrfProtectionLevel {
|
public enum SsrfProtectionLevel {
|
||||||
OFF, // No SSRF protection - allows all URLs
|
OFF, // No SSRF protection - allows all URLs
|
||||||
@@ -56,17 +51,21 @@ public class SsrfProtectionService {
|
|||||||
|
|
||||||
SsrfProtectionLevel level = parseProtectionLevel(config.getLevel());
|
SsrfProtectionLevel level = parseProtectionLevel(config.getLevel());
|
||||||
|
|
||||||
return switch (level) {
|
switch (level) {
|
||||||
case OFF -> true;
|
case OFF:
|
||||||
case MAX -> isMaxSecurityAllowed(trimmedUrl, config);
|
return true;
|
||||||
case MEDIUM -> isMediumSecurityAllowed(trimmedUrl, config);
|
case MAX:
|
||||||
default -> false;
|
return isMaxSecurityAllowed(trimmedUrl, config);
|
||||||
};
|
case MEDIUM:
|
||||||
|
return isMediumSecurityAllowed(trimmedUrl, config);
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SsrfProtectionLevel parseProtectionLevel(SsrfProtectionLevel level) {
|
private SsrfProtectionLevel parseProtectionLevel(String level) {
|
||||||
try {
|
try {
|
||||||
return SsrfProtectionLevel.valueOf(level.name());
|
return SsrfProtectionLevel.valueOf(level.toUpperCase());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
log.warn("Invalid SSRF protection level '{}', defaulting to MEDIUM", level);
|
log.warn("Invalid SSRF protection level '{}', defaulting to MEDIUM", level);
|
||||||
return SsrfProtectionLevel.MEDIUM;
|
return SsrfProtectionLevel.MEDIUM;
|
||||||
@@ -84,7 +83,7 @@ public class SsrfProtectionService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return config.getAllowedDomains().contains(host.toLowerCase(Locale.ROOT));
|
return config.getAllowedDomains().contains(host.toLowerCase());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.debug("Failed to parse URL for MAX security check: {}", url, e);
|
log.debug("Failed to parse URL for MAX security check: {}", url, e);
|
||||||
@@ -102,7 +101,7 @@ public class SsrfProtectionService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String hostLower = host.toLowerCase(Locale.ROOT);
|
String hostLower = host.toLowerCase();
|
||||||
|
|
||||||
// Check explicit blocked domains
|
// Check explicit blocked domains
|
||||||
if (config.getBlockedDomains().contains(hostLower)) {
|
if (config.getBlockedDomains().contains(hostLower)) {
|
||||||
@@ -112,7 +111,7 @@ public class SsrfProtectionService {
|
|||||||
|
|
||||||
// Check internal TLD patterns
|
// Check internal TLD patterns
|
||||||
for (String tld : config.getInternalTlds()) {
|
for (String tld : config.getInternalTlds()) {
|
||||||
if (hostLower.endsWith(tld.toLowerCase(Locale.ROOT))) {
|
if (hostLower.endsWith(tld.toLowerCase())) {
|
||||||
log.debug("URL blocked by internal TLD pattern '{}': {}", tld, url);
|
log.debug("URL blocked by internal TLD pattern '{}': {}", tld, url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -124,11 +123,9 @@ public class SsrfProtectionService {
|
|||||||
config.getAllowedDomains().stream()
|
config.getAllowedDomains().stream()
|
||||||
.anyMatch(
|
.anyMatch(
|
||||||
domain ->
|
domain ->
|
||||||
hostLower.equals(domain.toLowerCase(Locale.ROOT))
|
hostLower.equals(domain.toLowerCase())
|
||||||
|| hostLower.endsWith(
|
|| hostLower.endsWith(
|
||||||
"."
|
"." + domain.toLowerCase()));
|
||||||
+ domain.toLowerCase(
|
|
||||||
Locale.ROOT)));
|
|
||||||
|
|
||||||
if (!isAllowed) {
|
if (!isAllowed) {
|
||||||
log.debug("URL not in allowed domains list: {}", url);
|
log.debug("URL not in allowed domains list: {}", url);
|
||||||
@@ -175,62 +172,15 @@ public class SsrfProtectionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPrivateAddress(InetAddress address) {
|
private boolean isPrivateAddress(InetAddress address) {
|
||||||
if (address.isAnyLocalAddress() || address.isLoopbackAddress()) {
|
return address.isSiteLocalAddress()
|
||||||
return true;
|
|| address.isAnyLocalAddress()
|
||||||
}
|
|| isPrivateIPv4Range(address.getHostAddress());
|
||||||
|
|
||||||
if (address instanceof Inet4Address) {
|
|
||||||
return isPrivateIPv4Range(address.getHostAddress());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (address instanceof Inet6Address addr6) {
|
|
||||||
if (addr6.isLinkLocalAddress() || addr6.isSiteLocalAddress()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] bytes = addr6.getAddress();
|
|
||||||
if (isIpv4MappedAddress(bytes)) {
|
|
||||||
String ipv4 =
|
|
||||||
(bytes[12] & 0xff)
|
|
||||||
+ "."
|
|
||||||
+ (bytes[13] & 0xff)
|
|
||||||
+ "."
|
|
||||||
+ (bytes[14] & 0xff)
|
|
||||||
+ "."
|
|
||||||
+ (bytes[15] & 0xff);
|
|
||||||
return isPrivateIPv4Range(ipv4);
|
|
||||||
}
|
|
||||||
|
|
||||||
int firstByte = bytes[0] & 0xff;
|
|
||||||
// Check for IPv6 unique local addresses (fc00::/7)
|
|
||||||
if ((firstByte & 0xfe) == 0xfc) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isIpv4MappedAddress(byte[] addr) {
|
|
||||||
if (addr.length != 16) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
if (addr[i] != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// For IPv4-mapped IPv6 addresses, bytes 10 and 11 must be 0xff (i.e., address is
|
|
||||||
// ::ffff:w.x.y.z)
|
|
||||||
return addr[10] == (byte) 0xff && addr[11] == (byte) 0xff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPrivateIPv4Range(String ip) {
|
private boolean isPrivateIPv4Range(String ip) {
|
||||||
// Includes RFC1918, loopback, link-local, and unspecified addresses
|
|
||||||
return ip.startsWith("10.")
|
return ip.startsWith("10.")
|
||||||
|| ip.startsWith("192.168.")
|
|| ip.startsWith("192.168.")
|
||||||
|| (ip.startsWith("172.") && isInRange172(ip))
|
|| (ip.startsWith("172.") && isInRange172(ip))
|
||||||
|| ip.startsWith("169.254.")
|
|
||||||
|| ip.startsWith("127.")
|
|| ip.startsWith("127.")
|
||||||
|| "0.0.0.0".equals(ip);
|
|| "0.0.0.0".equals(ip);
|
||||||
}
|
}
|
||||||
@@ -242,31 +192,17 @@ public class SsrfProtectionService {
|
|||||||
int secondOctet = Integer.parseInt(parts[1]);
|
int secondOctet = Integer.parseInt(parts[1]);
|
||||||
return secondOctet >= 16 && secondOctet <= 31;
|
return secondOctet >= 16 && secondOctet <= 31;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCloudMetadataAddress(String ip) {
|
private boolean isCloudMetadataAddress(String ip) {
|
||||||
String normalizedIp = normalizeIpv4MappedAddress(ip);
|
|
||||||
// Cloud metadata endpoints for AWS, GCP, Azure, Oracle Cloud, and IBM Cloud
|
// Cloud metadata endpoints for AWS, GCP, Azure, Oracle Cloud, and IBM Cloud
|
||||||
return normalizedIp.startsWith("169.254.169.254") // AWS/GCP/Azure
|
return ip.startsWith("169.254.169.254") // AWS/GCP/Azure
|
||||||
|| normalizedIp.startsWith("fd00:ec2::254") // AWS IPv6
|
|| ip.startsWith("fd00:ec2::254") // AWS IPv6
|
||||||
|| normalizedIp.startsWith("169.254.169.253") // Oracle Cloud
|
|| ip.startsWith("169.254.169.253") // Oracle Cloud
|
||||||
|| normalizedIp.startsWith("169.254.169.250"); // IBM Cloud
|
|| ip.startsWith("169.254.169.250"); // IBM Cloud
|
||||||
}
|
|
||||||
|
|
||||||
private String normalizeIpv4MappedAddress(String ip) {
|
|
||||||
if (ip == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (ip.startsWith("::ffff:")) {
|
|
||||||
return ip.substring(7);
|
|
||||||
}
|
|
||||||
int lastColon = ip.lastIndexOf(':');
|
|
||||||
if (lastColon >= 0 && ip.indexOf('.') > lastColon) {
|
|
||||||
return ip.substring(lastColon + 1);
|
|
||||||
}
|
|
||||||
return ip;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@@ -66,7 +65,17 @@ public class TaskManager {
|
|||||||
* @param jobId The job ID
|
* @param jobId The job ID
|
||||||
*/
|
*/
|
||||||
public void createTask(String jobId) {
|
public void createTask(String jobId) {
|
||||||
jobResults.put(jobId, JobResult.createNew(jobId));
|
createTask(jobId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new task with the given job ID and progress tracking preference
|
||||||
|
*
|
||||||
|
* @param jobId The job ID
|
||||||
|
* @param trackProgress Whether detailed progress updates should be stored
|
||||||
|
*/
|
||||||
|
public void createTask(String jobId, boolean trackProgress) {
|
||||||
|
jobResults.put(jobId, JobResult.createNew(jobId, trackProgress));
|
||||||
log.debug("Created task with job ID: {}", jobId);
|
log.debug("Created task with job ID: {}", jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,16 +111,14 @@ public class TaskManager {
|
|||||||
if (!extractedFiles.isEmpty()) {
|
if (!extractedFiles.isEmpty()) {
|
||||||
jobResult.completeWithFiles(extractedFiles);
|
jobResult.completeWithFiles(extractedFiles);
|
||||||
log.debug(
|
log.debug(
|
||||||
"Set multiple file results for job ID: {} with {} files extracted from"
|
"Set multiple file results for job ID: {} with {} files extracted from ZIP",
|
||||||
+ " ZIP",
|
|
||||||
jobId,
|
jobId,
|
||||||
extractedFiles.size());
|
extractedFiles.size());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn(
|
log.warn(
|
||||||
"Failed to extract ZIP file for job {}: {}. Falling back to single file"
|
"Failed to extract ZIP file for job {}: {}. Falling back to single file result.",
|
||||||
+ " result.",
|
|
||||||
jobId,
|
jobId,
|
||||||
e.getMessage());
|
e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -168,6 +175,11 @@ public class TaskManager {
|
|||||||
&& jobResult.getError() == null) {
|
&& jobResult.getError() == null) {
|
||||||
// If no result or error has been set, mark it as complete with an empty result
|
// If no result or error has been set, mark it as complete with an empty result
|
||||||
jobResult.completeWithResult("Task completed successfully");
|
jobResult.completeWithResult("Task completed successfully");
|
||||||
|
} else {
|
||||||
|
// Ensure progress is set to 100% with "Completed" message
|
||||||
|
if (jobResult.isTrackProgress()) {
|
||||||
|
jobResult.updateProgress(100, "Completed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log.debug("Marked job ID: {} as complete", jobId);
|
log.debug("Marked job ID: {} as complete", jobId);
|
||||||
}
|
}
|
||||||
@@ -212,6 +224,33 @@ public class TaskManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the progress information for a task.
|
||||||
|
*
|
||||||
|
* @param jobId The job ID
|
||||||
|
* @param percent Percentage complete (0-100)
|
||||||
|
* @param message Descriptive message for the current stage
|
||||||
|
* @return true if the progress update was accepted
|
||||||
|
*/
|
||||||
|
public boolean updateProgress(String jobId, int percent, String message) {
|
||||||
|
JobResult jobResult = jobResults.get(jobId);
|
||||||
|
if (jobResult == null) {
|
||||||
|
log.debug("Ignoring progress update for unknown job ID: {}", jobId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!jobResult.isTrackProgress()) {
|
||||||
|
log.trace("Progress tracking disabled for job ID: {}", jobId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
jobResult.updateProgress(percent, message);
|
||||||
|
log.debug(
|
||||||
|
"Updated progress for job {} to {}% with message: {}",
|
||||||
|
jobId, jobResult.getProgressPercent(), message);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get statistics about all jobs in the system
|
* Get statistics about all jobs in the system
|
||||||
*
|
*
|
||||||
@@ -345,12 +384,12 @@ public class TaskManager {
|
|||||||
/** Check if a file is a ZIP file based on content type and filename */
|
/** Check if a file is a ZIP file based on content type and filename */
|
||||||
private boolean isZipFile(String contentType, String fileName) {
|
private boolean isZipFile(String contentType, String fileName) {
|
||||||
if (contentType != null
|
if (contentType != null
|
||||||
&& ("application/zip".equals(contentType)
|
&& (contentType.equals("application/zip")
|
||||||
|| "application/x-zip-compressed".equals(contentType))) {
|
|| contentType.equals("application/x-zip-compressed"))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileName != null && fileName.toLowerCase(Locale.ROOT).endsWith(".zip")) {
|
if (fileName != null && fileName.toLowerCase().endsWith(".zip")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +456,7 @@ public class TaskManager {
|
|||||||
return MediaType.APPLICATION_OCTET_STREAM_VALUE;
|
return MediaType.APPLICATION_OCTET_STREAM_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
String lowerName = fileName.toLowerCase(Locale.ROOT);
|
String lowerName = fileName.toLowerCase();
|
||||||
if (lowerName.endsWith(".pdf")) {
|
if (lowerName.endsWith(".pdf")) {
|
||||||
return MediaType.APPLICATION_PDF_VALUE;
|
return MediaType.APPLICATION_PDF_VALUE;
|
||||||
} else if (lowerName.endsWith(".txt")) {
|
} else if (lowerName.endsWith(".txt")) {
|
||||||
|
|||||||
+2
-9
@@ -23,7 +23,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
|
|
||||||
import stirling.software.common.model.ApplicationProperties;
|
import stirling.software.common.model.ApplicationProperties;
|
||||||
import stirling.software.common.util.GeneralUtils;
|
import stirling.software.common.util.GeneralUtils;
|
||||||
import stirling.software.common.util.RegexPatternUtils;
|
|
||||||
import stirling.software.common.util.TempFileManager;
|
import stirling.software.common.util.TempFileManager;
|
||||||
import stirling.software.common.util.TempFileRegistry;
|
import stirling.software.common.util.TempFileRegistry;
|
||||||
|
|
||||||
@@ -62,14 +61,8 @@ public class TempFileCleanupService {
|
|||||||
// File patterns that identify common system temp files
|
// File patterns that identify common system temp files
|
||||||
private static final Predicate<String> IS_SYSTEM_TEMP_FILE =
|
private static final Predicate<String> IS_SYSTEM_TEMP_FILE =
|
||||||
fileName ->
|
fileName ->
|
||||||
RegexPatternUtils.getInstance()
|
fileName.matches("lu\\d+[a-z0-9]*\\.tmp")
|
||||||
.getSystemTempFile1Pattern()
|
|| fileName.matches("ocr_process\\d+")
|
||||||
.matcher(fileName)
|
|
||||||
.matches()
|
|
||||||
|| RegexPatternUtils.getInstance()
|
|
||||||
.getSystemTempFile2Pattern()
|
|
||||||
.matcher(fileName)
|
|
||||||
.matches()
|
|
||||||
|| (fileName.startsWith("tmp") && !fileName.contains("jetty"))
|
|| (fileName.startsWith("tmp") && !fileName.contains("jetty"))
|
||||||
|| fileName.startsWith("OSL_PIPE_")
|
|| fileName.startsWith("OSL_PIPE_")
|
||||||
|| (fileName.endsWith(".tmp") && !fileName.contains("jetty"));
|
|| (fileName.endsWith(".tmp") && !fileName.contains("jetty"));
|
||||||
|
|||||||
@@ -6,8 +6,4 @@ public interface UserServiceInterface {
|
|||||||
String getCurrentUsername();
|
String getCurrentUsername();
|
||||||
|
|
||||||
long getTotalUsersCount();
|
long getTotalUsersCount();
|
||||||
|
|
||||||
boolean isCurrentUserAdmin();
|
|
||||||
|
|
||||||
boolean isCurrentUserFirstLogin();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
package stirling.software.common.util;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
|
||||||
import org.springframework.boot.ApplicationRunner;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Captures application command-line arguments at startup so they can be reused for restart
|
|
||||||
* operations. This allows the application to restart with the same configuration.
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class AppArgsCapture implements ApplicationRunner {
|
|
||||||
|
|
||||||
public static final AtomicReference<List<String>> APP_ARGS = new AtomicReference<>(List.of());
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(ApplicationArguments args) {
|
|
||||||
APP_ARGS.set(List.of(args.getSourceArgs()));
|
|
||||||
log.debug(
|
|
||||||
"Captured {} application arguments for restart capability",
|
|
||||||
args.getSourceArgs().length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,258 +0,0 @@
|
|||||||
package stirling.software.common.util;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPage;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
|
||||||
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
|
||||||
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import com.github.junrar.Archive;
|
|
||||||
import com.github.junrar.exception.CorruptHeaderException;
|
|
||||||
import com.github.junrar.exception.RarException;
|
|
||||||
import com.github.junrar.rarfile.FileHeader;
|
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import stirling.software.common.service.CustomPDFDocumentFactory;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@UtilityClass
|
|
||||||
public class CbrUtils {
|
|
||||||
|
|
||||||
public byte[] convertCbrToPdf(
|
|
||||||
MultipartFile cbrFile,
|
|
||||||
CustomPDFDocumentFactory pdfDocumentFactory,
|
|
||||||
TempFileManager tempFileManager)
|
|
||||||
throws IOException {
|
|
||||||
return convertCbrToPdf(cbrFile, pdfDocumentFactory, tempFileManager, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] convertCbrToPdf(
|
|
||||||
MultipartFile cbrFile,
|
|
||||||
CustomPDFDocumentFactory pdfDocumentFactory,
|
|
||||||
TempFileManager tempFileManager,
|
|
||||||
boolean optimizeForEbook)
|
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
validateCbrFile(cbrFile);
|
|
||||||
|
|
||||||
try (TempFile tempFile = new TempFile(tempFileManager, ".cbr")) {
|
|
||||||
cbrFile.transferTo(tempFile.getFile());
|
|
||||||
|
|
||||||
try (PDDocument document = pdfDocumentFactory.createNewDocument()) {
|
|
||||||
|
|
||||||
Archive archive;
|
|
||||||
try {
|
|
||||||
archive = new Archive(tempFile.getFile());
|
|
||||||
} catch (CorruptHeaderException e) {
|
|
||||||
log.warn(
|
|
||||||
"Failed to open CBR/RAR archive due to corrupt header: {}",
|
|
||||||
e.getMessage());
|
|
||||||
throw ExceptionUtils.createCbrInvalidFormatException(null);
|
|
||||||
} catch (RarException e) {
|
|
||||||
log.warn("Failed to open CBR/RAR archive: {}", e.getMessage());
|
|
||||||
String exMessage = e.getMessage() != null ? e.getMessage() : "";
|
|
||||||
|
|
||||||
if (exMessage.contains("encrypted")) {
|
|
||||||
throw ExceptionUtils.createCbrEncryptedException();
|
|
||||||
} else if (exMessage.isEmpty()) {
|
|
||||||
throw ExceptionUtils.createCbrInvalidFormatException(
|
|
||||||
"Invalid CBR/RAR archive. The file may be encrypted, corrupted, or"
|
|
||||||
+ " use an unsupported format.");
|
|
||||||
} else {
|
|
||||||
throw ExceptionUtils.createCbrInvalidFormatException(
|
|
||||||
"Invalid CBR/RAR archive: "
|
|
||||||
+ exMessage
|
|
||||||
+ ". The file may be encrypted, corrupted, or use an"
|
|
||||||
+ " unsupported format.");
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("IO error reading CBR/RAR archive: {}", e.getMessage());
|
|
||||||
throw ExceptionUtils.createFileProcessingException("CBR extraction", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ImageEntryData> imageEntries = new ArrayList<>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (FileHeader fileHeader : archive) {
|
|
||||||
if (!fileHeader.isDirectory() && isImageFile(fileHeader.getFileName())) {
|
|
||||||
try (InputStream is = archive.getInputStream(fileHeader)) {
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
is.transferTo(baos);
|
|
||||||
imageEntries.add(
|
|
||||||
new ImageEntryData(
|
|
||||||
fileHeader.getFileName(), baos.toByteArray()));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn(
|
|
||||||
"Error reading image {}: {}",
|
|
||||||
fileHeader.getFileName(),
|
|
||||||
e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
archive.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Error closing CBR/RAR archive: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
imageEntries.sort(
|
|
||||||
Comparator.comparing(ImageEntryData::name, new NaturalOrderComparator()));
|
|
||||||
|
|
||||||
if (imageEntries.isEmpty()) {
|
|
||||||
throw ExceptionUtils.createIllegalArgumentException(
|
|
||||||
"error.fileProcessing",
|
|
||||||
"No valid images found in the CBR file. The archive may be empty or"
|
|
||||||
+ " contain no supported image formats.");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ImageEntryData imageEntry : imageEntries) {
|
|
||||||
try {
|
|
||||||
PDImageXObject pdImage =
|
|
||||||
PDImageXObject.createFromByteArray(
|
|
||||||
document, imageEntry.data(), imageEntry.name());
|
|
||||||
PDPage page =
|
|
||||||
new PDPage(
|
|
||||||
new PDRectangle(pdImage.getWidth(), pdImage.getHeight()));
|
|
||||||
document.addPage(page);
|
|
||||||
try (PDPageContentStream contentStream =
|
|
||||||
new PDPageContentStream(
|
|
||||||
document,
|
|
||||||
page,
|
|
||||||
PDPageContentStream.AppendMode.OVERWRITE,
|
|
||||||
true,
|
|
||||||
true)) {
|
|
||||||
contentStream.drawImage(pdImage, 0, 0);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn(
|
|
||||||
"Error processing image {}: {}", imageEntry.name(), e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.getNumberOfPages() == 0) {
|
|
||||||
throw ExceptionUtils.createIllegalArgumentException(
|
|
||||||
"error.fileProcessing",
|
|
||||||
"No images could be processed from the CBR file. All images may be"
|
|
||||||
+ " corrupted or in unsupported formats.");
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
document.save(baos);
|
|
||||||
byte[] pdfBytes = baos.toByteArray();
|
|
||||||
|
|
||||||
// Apply Ghostscript optimization if requested
|
|
||||||
if (optimizeForEbook) {
|
|
||||||
try {
|
|
||||||
return GeneralUtils.optimizePdfWithGhostscript(pdfBytes);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Ghostscript optimization failed, returning unoptimized PDF", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pdfBytes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateCbrFile(MultipartFile file) {
|
|
||||||
if (file == null || file.isEmpty()) {
|
|
||||||
throw ExceptionUtils.createFileNullOrEmptyException();
|
|
||||||
}
|
|
||||||
|
|
||||||
String filename = file.getOriginalFilename();
|
|
||||||
if (filename == null) {
|
|
||||||
throw ExceptionUtils.createFileNoNameException();
|
|
||||||
}
|
|
||||||
|
|
||||||
String extension = FilenameUtils.getExtension(filename).toLowerCase(Locale.ROOT);
|
|
||||||
if (!"cbr".equals(extension) && !"rar".equals(extension)) {
|
|
||||||
throw ExceptionUtils.createNotCbrFileException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCbrFile(MultipartFile file) {
|
|
||||||
String filename = file.getOriginalFilename();
|
|
||||||
if (filename == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String extension = FilenameUtils.getExtension(filename).toLowerCase(Locale.ROOT);
|
|
||||||
return "cbr".equals(extension) || "rar".equals(extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isImageFile(String filename) {
|
|
||||||
return RegexPatternUtils.getInstance().getImageFilePattern().matcher(filename).matches();
|
|
||||||
}
|
|
||||||
|
|
||||||
private record ImageEntryData(String name, byte[] data) {}
|
|
||||||
|
|
||||||
private class NaturalOrderComparator implements Comparator<String> {
|
|
||||||
private static String getChunk(String s, int length, int marker) {
|
|
||||||
StringBuilder chunk = new StringBuilder();
|
|
||||||
char c = s.charAt(marker);
|
|
||||||
chunk.append(c);
|
|
||||||
marker++;
|
|
||||||
|
|
||||||
if (isDigit(c)) {
|
|
||||||
while (marker < length && isDigit(s.charAt(marker))) {
|
|
||||||
chunk.append(s.charAt(marker));
|
|
||||||
marker++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (marker < length && !isDigit(s.charAt(marker))) {
|
|
||||||
chunk.append(s.charAt(marker));
|
|
||||||
marker++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return chunk.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isDigit(char ch) {
|
|
||||||
return ch >= '0' && ch <= '9';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(String s1, String s2) {
|
|
||||||
int len1 = s1.length();
|
|
||||||
int len2 = s2.length();
|
|
||||||
int marker1 = 0, marker2 = 0;
|
|
||||||
|
|
||||||
while (marker1 < len1 && marker2 < len2) {
|
|
||||||
String chunk1 = getChunk(s1, len1, marker1);
|
|
||||||
marker1 += chunk1.length();
|
|
||||||
|
|
||||||
String chunk2 = getChunk(s2, len2, marker2);
|
|
||||||
marker2 += chunk2.length();
|
|
||||||
|
|
||||||
int result;
|
|
||||||
if (isDigit(chunk1.charAt(0)) && isDigit(chunk2.charAt(0))) {
|
|
||||||
int thisNumericValue = Integer.parseInt(chunk1);
|
|
||||||
int thatNumericValue = Integer.parseInt(chunk2);
|
|
||||||
result = Integer.compare(thisNumericValue, thatNumericValue);
|
|
||||||
} else {
|
|
||||||
result = chunk1.compareTo(chunk2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result != 0) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Integer.compare(len1, len2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
package stirling.software.common.util;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipFile;
|
|
||||||
import java.util.zip.ZipInputStream;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPage;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
|
||||||
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
|
||||||
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import stirling.software.common.service.CustomPDFDocumentFactory;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@UtilityClass
|
|
||||||
public class CbzUtils {
|
|
||||||
|
|
||||||
public byte[] convertCbzToPdf(
|
|
||||||
MultipartFile cbzFile,
|
|
||||||
CustomPDFDocumentFactory pdfDocumentFactory,
|
|
||||||
TempFileManager tempFileManager)
|
|
||||||
throws IOException {
|
|
||||||
return convertCbzToPdf(cbzFile, pdfDocumentFactory, tempFileManager, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] convertCbzToPdf(
|
|
||||||
MultipartFile cbzFile,
|
|
||||||
CustomPDFDocumentFactory pdfDocumentFactory,
|
|
||||||
TempFileManager tempFileManager,
|
|
||||||
boolean optimizeForEbook)
|
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
validateCbzFile(cbzFile);
|
|
||||||
|
|
||||||
try (TempFile tempFile = new TempFile(tempFileManager, ".cbz")) {
|
|
||||||
cbzFile.transferTo(tempFile.getFile());
|
|
||||||
|
|
||||||
// Early ZIP validity check using ZipInputStream (fail fast on non-zip content)
|
|
||||||
try (BufferedInputStream bis =
|
|
||||||
new BufferedInputStream(
|
|
||||||
new java.io.FileInputStream(tempFile.getFile()));
|
|
||||||
ZipInputStream zis = new ZipInputStream(bis)) {
|
|
||||||
if (zis.getNextEntry() == null) {
|
|
||||||
throw ExceptionUtils.createCbzEmptyException();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw ExceptionUtils.createCbzInvalidFormatException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try (PDDocument document = pdfDocumentFactory.createNewDocument();
|
|
||||||
ZipFile zipFile = new ZipFile(tempFile.getFile())) {
|
|
||||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
|
||||||
List<ImageEntryData> imageEntries = new ArrayList<>();
|
|
||||||
while (entries.hasMoreElements()) {
|
|
||||||
ZipEntry entry = entries.nextElement();
|
|
||||||
if (!entry.isDirectory() && isImageFile(entry.getName())) {
|
|
||||||
try (InputStream is = zipFile.getInputStream(entry)) {
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
is.transferTo(baos);
|
|
||||||
imageEntries.add(
|
|
||||||
new ImageEntryData(entry.getName(), baos.toByteArray()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Error reading image {}: {}", entry.getName(), e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
imageEntries.sort(
|
|
||||||
Comparator.comparing(ImageEntryData::name, new NaturalOrderComparator()));
|
|
||||||
|
|
||||||
if (imageEntries.isEmpty()) {
|
|
||||||
throw ExceptionUtils.createCbzNoImagesException();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ImageEntryData imageEntry : imageEntries) {
|
|
||||||
try {
|
|
||||||
PDImageXObject pdImage =
|
|
||||||
PDImageXObject.createFromByteArray(
|
|
||||||
document, imageEntry.data(), imageEntry.name());
|
|
||||||
PDPage page =
|
|
||||||
new PDPage(
|
|
||||||
new PDRectangle(pdImage.getWidth(), pdImage.getHeight()));
|
|
||||||
document.addPage(page);
|
|
||||||
try (PDPageContentStream contentStream =
|
|
||||||
new PDPageContentStream(
|
|
||||||
document,
|
|
||||||
page,
|
|
||||||
PDPageContentStream.AppendMode.OVERWRITE,
|
|
||||||
true,
|
|
||||||
true)) {
|
|
||||||
contentStream.drawImage(pdImage, 0, 0);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn(
|
|
||||||
"Error processing image {}: {}", imageEntry.name(), e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.getNumberOfPages() == 0) {
|
|
||||||
throw ExceptionUtils.createCbzCorruptedImagesException();
|
|
||||||
}
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
document.save(baos);
|
|
||||||
byte[] pdfBytes = baos.toByteArray();
|
|
||||||
|
|
||||||
// Apply Ghostscript optimization if requested
|
|
||||||
if (optimizeForEbook) {
|
|
||||||
try {
|
|
||||||
return GeneralUtils.optimizePdfWithGhostscript(pdfBytes);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Ghostscript optimization failed, returning unoptimized PDF", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pdfBytes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateCbzFile(MultipartFile file) {
|
|
||||||
if (file == null || file.isEmpty()) {
|
|
||||||
throw ExceptionUtils.createFileNullOrEmptyException();
|
|
||||||
}
|
|
||||||
|
|
||||||
String filename = file.getOriginalFilename();
|
|
||||||
if (filename == null) {
|
|
||||||
throw ExceptionUtils.createFileNoNameException();
|
|
||||||
}
|
|
||||||
|
|
||||||
String extension = FilenameUtils.getExtension(filename).toLowerCase(Locale.ROOT);
|
|
||||||
if (!"cbz".equals(extension) && !"zip".equals(extension)) {
|
|
||||||
throw ExceptionUtils.createNotCbzFileException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCbzFile(MultipartFile file) {
|
|
||||||
String filename = file.getOriginalFilename();
|
|
||||||
if (filename == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String extension = FilenameUtils.getExtension(filename).toLowerCase(Locale.ROOT);
|
|
||||||
return "cbz".equals(extension) || "zip".equals(extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isComicBookFile(MultipartFile file) {
|
|
||||||
String filename = file.getOriginalFilename();
|
|
||||||
if (filename == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String extension = FilenameUtils.getExtension(filename).toLowerCase(Locale.ROOT);
|
|
||||||
return "cbz".equals(extension)
|
|
||||||
|| "zip".equals(extension)
|
|
||||||
|| "cbr".equals(extension)
|
|
||||||
|| "rar".equals(extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isImageFile(String filename) {
|
|
||||||
return RegexPatternUtils.getInstance().getImageFilePattern().matcher(filename).matches();
|
|
||||||
}
|
|
||||||
|
|
||||||
private record ImageEntryData(String name, byte[] data) {}
|
|
||||||
|
|
||||||
private class NaturalOrderComparator implements Comparator<String> {
|
|
||||||
@Override
|
|
||||||
public int compare(String s1, String s2) {
|
|
||||||
int len1 = s1.length();
|
|
||||||
int len2 = s2.length();
|
|
||||||
int marker1 = 0, marker2 = 0;
|
|
||||||
|
|
||||||
while (marker1 < len1 && marker2 < len2) {
|
|
||||||
String chunk1 = getChunk(s1, len1, marker1);
|
|
||||||
marker1 += chunk1.length();
|
|
||||||
|
|
||||||
String chunk2 = getChunk(s2, len2, marker2);
|
|
||||||
marker2 += chunk2.length();
|
|
||||||
|
|
||||||
int result;
|
|
||||||
if (isDigit(chunk1.charAt(0)) && isDigit(chunk2.charAt(0))) {
|
|
||||||
int thisNumericValue = Integer.parseInt(chunk1);
|
|
||||||
int thatNumericValue = Integer.parseInt(chunk2);
|
|
||||||
result = Integer.compare(thisNumericValue, thatNumericValue);
|
|
||||||
} else {
|
|
||||||
result = chunk1.compareTo(chunk2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result != 0) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Integer.compare(len1, len2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getChunk(String s, int length, int marker) {
|
|
||||||
StringBuilder chunk = new StringBuilder();
|
|
||||||
char c = s.charAt(marker);
|
|
||||||
chunk.append(c);
|
|
||||||
marker++;
|
|
||||||
|
|
||||||
if (isDigit(c)) {
|
|
||||||
while (marker < length && isDigit(s.charAt(marker))) {
|
|
||||||
chunk.append(s.charAt(marker));
|
|
||||||
marker++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (marker < length && !isDigit(s.charAt(marker))) {
|
|
||||||
chunk.append(s.charAt(marker));
|
|
||||||
marker++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return chunk.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isDigit(char ch) {
|
|
||||||
return ch >= '0' && ch <= '9';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,8 +11,6 @@ public class CheckProgramInstall {
|
|||||||
private static final List<String> PYTHON_COMMANDS = Arrays.asList("python3", "python");
|
private static final List<String> PYTHON_COMMANDS = Arrays.asList("python3", "python");
|
||||||
private static boolean pythonAvailableChecked = false;
|
private static boolean pythonAvailableChecked = false;
|
||||||
private static String availablePythonCommand = null;
|
private static String availablePythonCommand = null;
|
||||||
private static boolean ffmpegAvailableChecked = false;
|
|
||||||
private static boolean ffmpegAvailable = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks which Python command is available and returns it.
|
* Checks which Python command is available and returns it.
|
||||||
@@ -58,25 +56,4 @@ public class CheckProgramInstall {
|
|||||||
public static boolean isPythonAvailable() {
|
public static boolean isPythonAvailable() {
|
||||||
return getAvailablePythonCommand() != null;
|
return getAvailablePythonCommand() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if FFmpeg is available on the system.
|
|
||||||
*
|
|
||||||
* @return true if FFmpeg is installed and accessible, false otherwise.
|
|
||||||
*/
|
|
||||||
public static boolean isFfmpegAvailable() {
|
|
||||||
if (!ffmpegAvailableChecked) {
|
|
||||||
try {
|
|
||||||
ProcessExecutorResult result =
|
|
||||||
ProcessExecutor.getInstance(ProcessExecutor.Processes.FFMPEG)
|
|
||||||
.runCommandWithOutputHandling(Arrays.asList("ffmpeg", "-version"));
|
|
||||||
ffmpegAvailable = true;
|
|
||||||
} catch (IOException | InterruptedException e) {
|
|
||||||
ffmpegAvailable = false;
|
|
||||||
} finally {
|
|
||||||
ffmpegAvailableChecked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ffmpegAvailable;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,297 +0,0 @@
|
|||||||
package stirling.software.common.util;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.zip.Adler32;
|
|
||||||
import java.util.zip.CRC32;
|
|
||||||
import java.util.zip.Checksum;
|
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class ChecksumUtils {
|
|
||||||
|
|
||||||
/** Shared buffer size for streaming I/O. */
|
|
||||||
private static final int BUFFER_SIZE = 8192;
|
|
||||||
|
|
||||||
/** Mask to extract the lower 32 bits of a long value (unsigned int). */
|
|
||||||
private static final long UNSIGNED_32_BIT_MASK = 0xFFFFFFFFL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes a checksum for the given file using the chosen algorithm and returns a lowercase hex
|
|
||||||
* string.
|
|
||||||
*
|
|
||||||
* <p>For digest algorithms (e.g., SHA-256, SHA-1, MD5), this returns the digest as hex. For
|
|
||||||
* 32-bit {@link Checksum} algorithms ("CRC32", "ADLER32"), this returns an 8-character
|
|
||||||
* lowercase hex string of the unsigned 32-bit value.
|
|
||||||
*
|
|
||||||
* @param path file to read
|
|
||||||
* @param algorithm algorithm name (case-insensitive). Special values: "CRC32", "ADLER32".
|
|
||||||
* @return hex string of the checksum
|
|
||||||
* @throws IOException if the file cannot be read
|
|
||||||
*/
|
|
||||||
public static String checksum(Path path, String algorithm) throws IOException {
|
|
||||||
try (InputStream is = Files.newInputStream(path)) {
|
|
||||||
return checksum(is, algorithm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes a checksum for the given stream using the chosen algorithm and returns a lowercase
|
|
||||||
* hex string.
|
|
||||||
*
|
|
||||||
* <p><strong>Note:</strong> This method does <em>not</em> close the provided stream.
|
|
||||||
*
|
|
||||||
* @param is input stream (not closed by this method)
|
|
||||||
* @param algorithm algorithm name (case-insensitive). Special values: "CRC32", "ADLER32".
|
|
||||||
* @return hex string of the checksum
|
|
||||||
* @throws IOException if reading from the stream fails
|
|
||||||
*/
|
|
||||||
public static String checksum(InputStream is, String algorithm) throws IOException {
|
|
||||||
return switch (algorithm.toUpperCase(Locale.ROOT)) {
|
|
||||||
case "CRC32" -> checksumChecksum(is, new CRC32());
|
|
||||||
case "ADLER32" -> checksumChecksum(is, new Adler32());
|
|
||||||
default -> toHex(checksumBytes(is, algorithm));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes a checksum for the given file using the chosen algorithm and returns a Base64
|
|
||||||
* encoded string.
|
|
||||||
*
|
|
||||||
* <p>For digest algorithms this is the Base64 of the raw digest bytes. For 32-bit checksum
|
|
||||||
* algorithms ("CRC32", "ADLER32"), this is the Base64 of the 4-byte big-endian unsigned value.
|
|
||||||
*
|
|
||||||
* @param path file to read
|
|
||||||
* @param algorithm algorithm name (case-insensitive). Special values: "CRC32", "ADLER32".
|
|
||||||
* @return Base64-encoded checksum bytes
|
|
||||||
* @throws IOException if the file cannot be read
|
|
||||||
*/
|
|
||||||
public static String checksumBase64(Path path, String algorithm) throws IOException {
|
|
||||||
try (InputStream is = Files.newInputStream(path)) {
|
|
||||||
return checksumBase64(is, algorithm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes a checksum for the given stream using the chosen algorithm and returns a Base64
|
|
||||||
* encoded string.
|
|
||||||
*
|
|
||||||
* <p><strong>Note:</strong> This method does <em>not</em> close the provided stream.
|
|
||||||
*
|
|
||||||
* @param is input stream (not closed by this method)
|
|
||||||
* @param algorithm algorithm name (case-insensitive). Special values: "CRC32", "ADLER32".
|
|
||||||
* @return Base64-encoded checksum bytes
|
|
||||||
* @throws IOException if reading from the stream fails
|
|
||||||
*/
|
|
||||||
public static String checksumBase64(InputStream is, String algorithm) throws IOException {
|
|
||||||
return switch (algorithm.toUpperCase(Locale.ROOT)) {
|
|
||||||
case "CRC32" ->
|
|
||||||
Base64.getEncoder().encodeToString(checksumChecksumBytes(is, new CRC32()));
|
|
||||||
case "ADLER32" ->
|
|
||||||
Base64.getEncoder().encodeToString(checksumChecksumBytes(is, new Adler32()));
|
|
||||||
default -> Base64.getEncoder().encodeToString(checksumBytes(is, algorithm));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes multiple checksums for the given file in a single pass over the data.
|
|
||||||
*
|
|
||||||
* <p>Returns a map from algorithm name to lowercase hex string. Order of results follows the
|
|
||||||
* order of the provided {@code algorithms}.
|
|
||||||
*
|
|
||||||
* @param path file to read
|
|
||||||
* @param algorithms algorithm names (case-insensitive). Special: "CRC32", "ADLER32".
|
|
||||||
* @return map of algorithm → hex string
|
|
||||||
* @throws IOException if the file cannot be read
|
|
||||||
*/
|
|
||||||
public static Map<String, String> checksums(Path path, String... algorithms)
|
|
||||||
throws IOException {
|
|
||||||
try (InputStream is = Files.newInputStream(path)) {
|
|
||||||
return checksums(is, algorithms);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes multiple checksums for the given stream in a single pass over the data.
|
|
||||||
*
|
|
||||||
* <p><strong>Note:</strong> This method does <em>not</em> close the provided stream.
|
|
||||||
*
|
|
||||||
* @param is input stream (not closed by this method)
|
|
||||||
* @param algorithms algorithm names (case-insensitive). Special: "CRC32", "ADLER32".
|
|
||||||
* @return map of algorithm → hex string
|
|
||||||
* @throws IOException if reading from the stream fails
|
|
||||||
*/
|
|
||||||
public static Map<String, String> checksums(InputStream is, String... algorithms)
|
|
||||||
throws IOException {
|
|
||||||
// Use LinkedHashMap to preserve the order of requested algorithms in the result.
|
|
||||||
Map<String, MessageDigest> digests = new LinkedHashMap<>();
|
|
||||||
Map<String, Checksum> checksums = new LinkedHashMap<>();
|
|
||||||
|
|
||||||
for (String algorithm : algorithms) {
|
|
||||||
String key = algorithm; // keep original key for output
|
|
||||||
switch (algorithm.toUpperCase(Locale.ROOT)) {
|
|
||||||
case "CRC32":
|
|
||||||
checksums.put(key, new CRC32());
|
|
||||||
break;
|
|
||||||
case "ADLER32":
|
|
||||||
checksums.put(key, new Adler32());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
try {
|
|
||||||
// For MessageDigest, pass the original name (case-insensitive per JCA)
|
|
||||||
digests.put(key, MessageDigest.getInstance(algorithm));
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
throw new IllegalStateException("Unsupported algorithm: " + algorithm, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] buffer = new byte[BUFFER_SIZE];
|
|
||||||
int read;
|
|
||||||
while ((read = is.read(buffer)) != -1) {
|
|
||||||
for (MessageDigest digest : digests.values()) {
|
|
||||||
digest.update(buffer, 0, read);
|
|
||||||
}
|
|
||||||
for (Checksum cs : checksums.values()) {
|
|
||||||
cs.update(buffer, 0, read);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, String> results = new LinkedHashMap<>();
|
|
||||||
for (Map.Entry<String, MessageDigest> entry : digests.entrySet()) {
|
|
||||||
results.put(entry.getKey(), toHex(entry.getValue().digest()));
|
|
||||||
}
|
|
||||||
for (Map.Entry<String, Checksum> entry : checksums.entrySet()) {
|
|
||||||
// Keep value as long and mask to ensure unsigned hex formatting.
|
|
||||||
long unsigned32 = entry.getValue().getValue() & UNSIGNED_32_BIT_MASK;
|
|
||||||
results.put(entry.getKey(), String.format(Locale.ROOT, "%08x", unsigned32));
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares the checksum of a file with an expected hex string (case-insensitive).
|
|
||||||
*
|
|
||||||
* @param path file to read
|
|
||||||
* @param algorithm algorithm name (case-insensitive). Special: "CRC32", "ADLER32".
|
|
||||||
* @param expected expected hex string (case-insensitive)
|
|
||||||
* @return {@code true} if they match, otherwise {@code false}
|
|
||||||
* @throws IOException if the file cannot be read
|
|
||||||
*/
|
|
||||||
public static boolean matches(Path path, String algorithm, String expected) throws IOException {
|
|
||||||
try (InputStream is = Files.newInputStream(path)) {
|
|
||||||
return matches(is, algorithm, expected);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares the checksum of a stream with an expected hex string (case-insensitive).
|
|
||||||
*
|
|
||||||
* <p><strong>Note:</strong> This method does <em>not</em> close the provided stream.
|
|
||||||
*
|
|
||||||
* @param is input stream (not closed by this method)
|
|
||||||
* @param algorithm algorithm name (case-insensitive). Special: "CRC32", "ADLER32".
|
|
||||||
* @param expected expected hex string (case-insensitive)
|
|
||||||
* @return {@code true} if they match, otherwise {@code false}
|
|
||||||
* @throws IOException if reading from the stream fails
|
|
||||||
*/
|
|
||||||
public static boolean matches(InputStream is, String algorithm, String expected)
|
|
||||||
throws IOException {
|
|
||||||
return checksum(is, algorithm).equalsIgnoreCase(expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- Internal helpers ----------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes a MessageDigest over a stream and returns the raw digest bytes.
|
|
||||||
*
|
|
||||||
* @param is input stream (not closed)
|
|
||||||
* @param algorithm JCA MessageDigest algorithm (e.g., "SHA-256")
|
|
||||||
* @return raw digest bytes
|
|
||||||
* @throws IOException if reading fails
|
|
||||||
* @throws IllegalStateException if the algorithm is unsupported
|
|
||||||
*/
|
|
||||||
private static byte[] checksumBytes(InputStream is, String algorithm) throws IOException {
|
|
||||||
try {
|
|
||||||
MessageDigest digest = MessageDigest.getInstance(algorithm);
|
|
||||||
byte[] buffer = new byte[BUFFER_SIZE];
|
|
||||||
int read;
|
|
||||||
while ((read = is.read(buffer)) != -1) {
|
|
||||||
digest.update(buffer, 0, read);
|
|
||||||
}
|
|
||||||
return digest.digest();
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
// Keep the message explicit to aid debugging
|
|
||||||
throw new IllegalStateException("Unsupported algorithm: " + algorithm, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes a 32-bit {@link Checksum} over a stream and returns the lowercase 8-char hex of the
|
|
||||||
* unsigned 32-bit value.
|
|
||||||
*
|
|
||||||
* @param is input stream (not closed)
|
|
||||||
* @param checksum checksum implementation (CRC32, Adler32, etc.)
|
|
||||||
* @return 8-character lowercase hex (big-endian representation)
|
|
||||||
* @throws IOException if reading fails
|
|
||||||
*/
|
|
||||||
private static String checksumChecksum(InputStream is, Checksum checksum) throws IOException {
|
|
||||||
byte[] buffer = new byte[BUFFER_SIZE];
|
|
||||||
int read;
|
|
||||||
while ((read = is.read(buffer)) != -1) {
|
|
||||||
checksum.update(buffer, 0, read);
|
|
||||||
}
|
|
||||||
// Keep as long and mask to ensure correct unsigned representation.
|
|
||||||
long unsigned32 = checksum.getValue() & UNSIGNED_32_BIT_MASK;
|
|
||||||
return String.format(Locale.ROOT, "%08x", unsigned32);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computes a 32-bit {@link Checksum} over a stream and returns the raw 4-byte big-endian
|
|
||||||
* representation of the unsigned 32-bit value.
|
|
||||||
*
|
|
||||||
* <p>Cast to int already truncates to the lower 32 bits; the sign is irrelevant because we
|
|
||||||
* serialize the bit pattern directly into 4 bytes.
|
|
||||||
*
|
|
||||||
* @param is input stream (not closed)
|
|
||||||
* @param checksum checksum implementation (CRC32, Adler32, etc.)
|
|
||||||
* @return 4 bytes (big-endian)
|
|
||||||
* @throws IOException if reading fails
|
|
||||||
*/
|
|
||||||
private static byte[] checksumChecksumBytes(InputStream is, Checksum checksum)
|
|
||||||
throws IOException {
|
|
||||||
byte[] buffer = new byte[BUFFER_SIZE];
|
|
||||||
int read;
|
|
||||||
while ((read = is.read(buffer)) != -1) {
|
|
||||||
checksum.update(buffer, 0, read);
|
|
||||||
}
|
|
||||||
// Cast keeps only the lower 32 bits; mask is unnecessary here.
|
|
||||||
int v = (int) checksum.getValue();
|
|
||||||
return ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).putInt(v).array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts bytes to a lowercase hex string.
|
|
||||||
*
|
|
||||||
* @param hash the byte array to convert
|
|
||||||
* @return the lowercase hex string
|
|
||||||
*/
|
|
||||||
private static String toHex(byte[] hash) {
|
|
||||||
StringBuilder sb = new StringBuilder(hash.length * 2);
|
|
||||||
for (byte b : hash) {
|
|
||||||
sb.append(String.format(Locale.ROOT, "%02x", b));
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,7 @@ import org.owasp.html.AttributePolicy;
|
|||||||
import org.owasp.html.HtmlPolicyBuilder;
|
import org.owasp.html.HtmlPolicyBuilder;
|
||||||
import org.owasp.html.PolicyFactory;
|
import org.owasp.html.PolicyFactory;
|
||||||
import org.owasp.html.Sanitizers;
|
import org.owasp.html.Sanitizers;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import stirling.software.common.model.ApplicationProperties;
|
import stirling.software.common.model.ApplicationProperties;
|
||||||
@@ -15,6 +16,7 @@ public class CustomHtmlSanitizer {
|
|||||||
private final SsrfProtectionService ssrfProtectionService;
|
private final SsrfProtectionService ssrfProtectionService;
|
||||||
private final ApplicationProperties applicationProperties;
|
private final ApplicationProperties applicationProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
public CustomHtmlSanitizer(
|
public CustomHtmlSanitizer(
|
||||||
SsrfProtectionService ssrfProtectionService,
|
SsrfProtectionService ssrfProtectionService,
|
||||||
ApplicationProperties applicationProperties) {
|
ApplicationProperties applicationProperties) {
|
||||||
@@ -26,7 +28,7 @@ public class CustomHtmlSanitizer {
|
|||||||
new AttributePolicy() {
|
new AttributePolicy() {
|
||||||
@Override
|
@Override
|
||||||
public String apply(String elementName, String attributeName, String value) {
|
public String apply(String elementName, String attributeName, String value) {
|
||||||
if (value.trim().isEmpty()) {
|
if (value == null || value.trim().isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +64,8 @@ public class CustomHtmlSanitizer {
|
|||||||
.and(new HtmlPolicyBuilder().disallowElements("noscript").toFactory());
|
.and(new HtmlPolicyBuilder().disallowElements("noscript").toFactory());
|
||||||
|
|
||||||
public String sanitize(String html) {
|
public String sanitize(String html) {
|
||||||
boolean disableSanitize = applicationProperties.getSystem().isDisableSanitize();
|
boolean disableSanitize =
|
||||||
|
Boolean.TRUE.equals(applicationProperties.getSystem().getDisableSanitize());
|
||||||
return disableSanitize ? html : POLICY.sanitize(html);
|
return disableSanitize ? html : POLICY.sanitize(html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,445 +1,637 @@
|
|||||||
package stirling.software.common.util;
|
package stirling.software.common.util;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.time.ZoneOffset;
|
import java.lang.reflect.Constructor;
|
||||||
import java.time.ZonedDateTime;
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Properties;
|
||||||
import java.util.Objects;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.simplejavamail.api.email.AttachmentResource;
|
|
||||||
import org.simplejavamail.api.email.Email;
|
|
||||||
import org.simplejavamail.api.email.Recipient;
|
|
||||||
import org.simplejavamail.converter.EmailConverter;
|
|
||||||
|
|
||||||
import jakarta.activation.DataSource;
|
|
||||||
import jakarta.mail.Message.RecipientType;
|
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import stirling.software.common.model.api.converters.EmlToPdfRequest;
|
import stirling.software.common.model.api.converters.EmlToPdfRequest;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class EmlParser {
|
public class EmlParser {
|
||||||
|
|
||||||
// Configuration constants
|
private static volatile Boolean jakartaMailAvailable = null;
|
||||||
private final int DEFAULT_MAX_ATTACHMENT_MB = 10;
|
private static volatile Method mimeUtilityDecodeTextMethod = null;
|
||||||
private final long MAX_SIZE_ESTIMATION_BYTES = 500L * 1024 * 1024; // 500MB
|
private static volatile boolean mimeUtilityChecked = false;
|
||||||
|
|
||||||
// Message constants
|
private static final Pattern MIME_ENCODED_PATTERN =
|
||||||
private final String NO_CONTENT_MESSAGE = "Email content could not be parsed";
|
Pattern.compile("=\\?([^?]+)\\?([BbQq])\\?([^?]*)\\?=");
|
||||||
private final String ATTACHMENT_PREFIX = "attachment-";
|
|
||||||
|
|
||||||
public EmailContent extractEmailContent(
|
private static final String DISPOSITION_ATTACHMENT = "attachment";
|
||||||
|
private static final String TEXT_PLAIN = "text/plain";
|
||||||
|
private static final String TEXT_HTML = "text/html";
|
||||||
|
private static final String MULTIPART_PREFIX = "multipart/";
|
||||||
|
|
||||||
|
private static final String HEADER_CONTENT_TYPE = "content-type:";
|
||||||
|
private static final String HEADER_CONTENT_DISPOSITION = "content-disposition:";
|
||||||
|
private static final String HEADER_CONTENT_TRANSFER_ENCODING = "content-transfer-encoding:";
|
||||||
|
private static final String HEADER_CONTENT_ID = "Content-ID";
|
||||||
|
private static final String HEADER_SUBJECT = "Subject:";
|
||||||
|
private static final String HEADER_FROM = "From:";
|
||||||
|
private static final String HEADER_TO = "To:";
|
||||||
|
private static final String HEADER_CC = "Cc:";
|
||||||
|
private static final String HEADER_BCC = "Bcc:";
|
||||||
|
private static final String HEADER_DATE = "Date:";
|
||||||
|
|
||||||
|
private static synchronized boolean isJakartaMailAvailable() {
|
||||||
|
if (jakartaMailAvailable == null) {
|
||||||
|
try {
|
||||||
|
Class.forName("jakarta.mail.internet.MimeMessage");
|
||||||
|
Class.forName("jakarta.mail.Session");
|
||||||
|
Class.forName("jakarta.mail.internet.MimeUtility");
|
||||||
|
Class.forName("jakarta.mail.internet.MimePart");
|
||||||
|
Class.forName("jakarta.mail.internet.MimeMultipart");
|
||||||
|
Class.forName("jakarta.mail.Multipart");
|
||||||
|
Class.forName("jakarta.mail.Part");
|
||||||
|
jakartaMailAvailable = true;
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
jakartaMailAvailable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jakartaMailAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EmailContent extractEmailContent(
|
||||||
byte[] emlBytes, EmlToPdfRequest request, CustomHtmlSanitizer customHtmlSanitizer)
|
byte[] emlBytes, EmlToPdfRequest request, CustomHtmlSanitizer customHtmlSanitizer)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
EmlProcessingUtils.validateEmlInput(emlBytes);
|
EmlProcessingUtils.validateEmlInput(emlBytes);
|
||||||
|
|
||||||
Email email = parseEmail(emlBytes);
|
if (isJakartaMailAvailable()) {
|
||||||
return buildEmailContent(email, request, customHtmlSanitizer);
|
return extractEmailContentAdvanced(emlBytes, request, customHtmlSanitizer);
|
||||||
}
|
} else {
|
||||||
|
return extractEmailContentBasic(emlBytes, request, customHtmlSanitizer);
|
||||||
private Email parseEmail(byte[] emlBytes) throws IOException {
|
|
||||||
boolean isMsgFile = EmlProcessingUtils.isMsgFile(emlBytes);
|
|
||||||
try (ByteArrayInputStream input = new ByteArrayInputStream(emlBytes)) {
|
|
||||||
Email email;
|
|
||||||
if (isMsgFile) {
|
|
||||||
try {
|
|
||||||
email = EmailConverter.outlookMsgToEmail(input);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// OLE2 magic bytes match but parsing failed - might be DOC/XLS/other OLE2 file
|
|
||||||
throw new IOException(
|
|
||||||
"The file appears to be an OLE2 file (MSG/DOC/XLS) but could not be "
|
|
||||||
+ "parsed as an Outlook email. Ensure it is a valid .msg file: "
|
|
||||||
+ e.getMessage(),
|
|
||||||
e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
email = EmailConverter.emlToEmail(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
return email;
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw e; // Re-throw IOException as-is
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new IOException(
|
|
||||||
String.format(
|
|
||||||
"Failed to parse EML file with Simple Java Mail: %s", e.getMessage()),
|
|
||||||
e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private EmailContent buildEmailContent(
|
private static EmailContent extractEmailContentBasic(
|
||||||
Email email, EmlToPdfRequest request, CustomHtmlSanitizer customHtmlSanitizer)
|
byte[] emlBytes, EmlToPdfRequest request, CustomHtmlSanitizer customHtmlSanitizer) {
|
||||||
throws IOException {
|
String emlContent = new String(emlBytes, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
EmailContent content = new EmailContent();
|
EmailContent content = new EmailContent();
|
||||||
content.setSubject(defaultString(email.getSubject()));
|
|
||||||
content.setFrom(formatRecipient(email.getFromRecipient()));
|
|
||||||
content.setTo(formatRecipients(email.getRecipients(), RecipientType.TO));
|
|
||||||
content.setCc(formatRecipients(email.getRecipients(), RecipientType.CC));
|
|
||||||
content.setBcc(formatRecipients(email.getRecipients(), RecipientType.BCC));
|
|
||||||
|
|
||||||
Date sentDate = email.getSentDate();
|
content.setSubject(extractBasicHeader(emlContent, HEADER_SUBJECT));
|
||||||
if (sentDate != null) {
|
content.setFrom(extractBasicHeader(emlContent, HEADER_FROM));
|
||||||
// Use UTC for consistent timezone handling across deployments
|
content.setTo(extractBasicHeader(emlContent, HEADER_TO));
|
||||||
content.setDate(ZonedDateTime.ofInstant(sentDate.toInstant(), ZoneOffset.UTC));
|
content.setCc(extractBasicHeader(emlContent, HEADER_CC));
|
||||||
|
content.setBcc(extractBasicHeader(emlContent, HEADER_BCC));
|
||||||
|
|
||||||
|
String dateStr = extractBasicHeader(emlContent, HEADER_DATE);
|
||||||
|
if (!dateStr.isEmpty()) {
|
||||||
|
content.setDateString(dateStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
String htmlBody = email.getHTMLText();
|
String htmlBody = extractHtmlBody(emlContent);
|
||||||
if (customHtmlSanitizer != null && htmlBody != null) {
|
if (htmlBody != null) {
|
||||||
htmlBody = customHtmlSanitizer.sanitize(htmlBody);
|
content.setHtmlBody(htmlBody);
|
||||||
}
|
} else {
|
||||||
content.setHtmlBody(htmlBody);
|
String textBody = extractTextBody(emlContent);
|
||||||
|
content.setTextBody(textBody != null ? textBody : "Email content could not be parsed");
|
||||||
String textBody = email.getPlainText();
|
|
||||||
if (customHtmlSanitizer != null && textBody != null) {
|
|
||||||
textBody = customHtmlSanitizer.sanitize(textBody);
|
|
||||||
}
|
|
||||||
content.setTextBody(textBody);
|
|
||||||
|
|
||||||
if (isBlank(content.getHtmlBody()) && isBlank(content.getTextBody())) {
|
|
||||||
content.setTextBody(NO_CONTENT_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<EmailAttachment> attachments = new ArrayList<>();
|
content.getAttachments().addAll(extractAttachmentsBasic(emlContent));
|
||||||
attachments.addAll(mapResources(email.getEmbeddedImages(), request, true));
|
|
||||||
attachments.addAll(mapResources(email.getAttachments(), request, false));
|
|
||||||
content.setAttachments(attachments);
|
|
||||||
content.setAttachmentCount(attachments.size());
|
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EmailAttachment> mapResources(
|
private static EmailContent extractEmailContentAdvanced(
|
||||||
List<AttachmentResource> resources, EmlToPdfRequest request, boolean embedded)
|
byte[] emlBytes, EmlToPdfRequest request, CustomHtmlSanitizer customHtmlSanitizer) {
|
||||||
throws IOException {
|
try {
|
||||||
|
Class<?> sessionClass = Class.forName("jakarta.mail.Session");
|
||||||
|
Class<?> mimeMessageClass = Class.forName("jakarta.mail.internet.MimeMessage");
|
||||||
|
|
||||||
if (resources == null || resources.isEmpty()) {
|
Method getDefaultInstance =
|
||||||
return List.of();
|
sessionClass.getMethod("getDefaultInstance", Properties.class);
|
||||||
|
Object session = getDefaultInstance.invoke(null, new Properties());
|
||||||
|
|
||||||
|
Class<?>[] constructorArgs = new Class<?>[] {sessionClass, InputStream.class};
|
||||||
|
Constructor<?> mimeMessageConstructor =
|
||||||
|
mimeMessageClass.getConstructor(constructorArgs);
|
||||||
|
Object message =
|
||||||
|
mimeMessageConstructor.newInstance(session, new ByteArrayInputStream(emlBytes));
|
||||||
|
|
||||||
|
return extractFromMimeMessage(message, request, customHtmlSanitizer);
|
||||||
|
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
return extractEmailContentBasic(emlBytes, request, customHtmlSanitizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<EmailAttachment> mapped = new ArrayList<>(resources.size());
|
|
||||||
int unnamedCounter = 0; // Start at 0, increment before use
|
|
||||||
|
|
||||||
for (AttachmentResource resource : resources) {
|
|
||||||
if (resource == null) {
|
|
||||||
continue; // Skip null resources early
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pre-determine if this resource needs a generated filename
|
|
||||||
boolean needsGeneratedName = !embedded && needsGeneratedFilename(resource);
|
|
||||||
|
|
||||||
if (needsGeneratedName) {
|
|
||||||
unnamedCounter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
EmailAttachment attachment =
|
|
||||||
toEmailAttachment(resource, request, embedded, unnamedCounter);
|
|
||||||
if (attachment != null) {
|
|
||||||
mapped.add(attachment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mapped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks if a resource needs a generated filename (has no usable name). */
|
private static EmailContent extractFromMimeMessage(
|
||||||
private boolean needsGeneratedFilename(AttachmentResource resource) {
|
Object message, EmlToPdfRequest request, CustomHtmlSanitizer customHtmlSanitizer) {
|
||||||
if (resource == null) {
|
EmailContent content = new EmailContent();
|
||||||
return false;
|
|
||||||
|
try {
|
||||||
|
Class<?> messageClass = message.getClass();
|
||||||
|
|
||||||
|
Method getSubject = messageClass.getMethod("getSubject");
|
||||||
|
String subject = (String) getSubject.invoke(message);
|
||||||
|
content.setSubject(subject != null ? safeMimeDecode(subject) : "No Subject");
|
||||||
|
|
||||||
|
Method getFrom = messageClass.getMethod("getFrom");
|
||||||
|
Object[] fromAddresses = (Object[]) getFrom.invoke(message);
|
||||||
|
content.setFrom(buildAddressString(fromAddresses));
|
||||||
|
|
||||||
|
extractRecipients(message, messageClass, content);
|
||||||
|
|
||||||
|
Method getSentDate = messageClass.getMethod("getSentDate");
|
||||||
|
content.setDate((Date) getSentDate.invoke(message));
|
||||||
|
|
||||||
|
Method getContent = messageClass.getMethod("getContent");
|
||||||
|
Object messageContent = getContent.invoke(message);
|
||||||
|
|
||||||
|
processMessageContent(message, messageContent, content, request, customHtmlSanitizer);
|
||||||
|
|
||||||
|
} catch (ReflectiveOperationException | RuntimeException e) {
|
||||||
|
content.setSubject("Email Conversion");
|
||||||
|
content.setFrom("Unknown");
|
||||||
|
content.setTo("Unknown");
|
||||||
|
content.setCc("");
|
||||||
|
content.setBcc("");
|
||||||
|
content.setTextBody("Email content could not be parsed with advanced processing");
|
||||||
}
|
}
|
||||||
String resourceName = resource.getName();
|
|
||||||
if (!isBlank(resourceName)) {
|
return content;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DataSource dataSource = resource.getDataSource();
|
|
||||||
return isBlank(dataSource.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private EmailAttachment toEmailAttachment(
|
private static void extractRecipients(
|
||||||
AttachmentResource resource, EmlToPdfRequest request, boolean embedded, int counter)
|
Object message, Class<?> messageClass, EmailContent content) {
|
||||||
throws IOException {
|
try {
|
||||||
|
Method getRecipients =
|
||||||
|
messageClass.getMethod(
|
||||||
|
"getRecipients", Class.forName("jakarta.mail.Message$RecipientType"));
|
||||||
|
Class<?> recipientTypeClass = Class.forName("jakarta.mail.Message$RecipientType");
|
||||||
|
|
||||||
if (resource == null) {
|
Object toType = recipientTypeClass.getField("TO").get(null);
|
||||||
return null;
|
Object[] toRecipients = (Object[]) getRecipients.invoke(message, toType);
|
||||||
}
|
content.setTo(buildAddressString(toRecipients));
|
||||||
|
|
||||||
EmailAttachment attachment = new EmailAttachment();
|
Object ccType = recipientTypeClass.getField("CC").get(null);
|
||||||
attachment.setEmbedded(embedded);
|
Object[] ccRecipients = (Object[]) getRecipients.invoke(message, ccType);
|
||||||
|
content.setCc(buildAddressString(ccRecipients));
|
||||||
|
|
||||||
String resourceName = defaultString(resource.getName());
|
Object bccType = recipientTypeClass.getField("BCC").get(null);
|
||||||
String filename = resourceName;
|
Object[] bccRecipients = (Object[]) getRecipients.invoke(message, bccType);
|
||||||
DataSource dataSource = resource.getDataSource();
|
content.setBcc(buildAddressString(bccRecipients));
|
||||||
String contentType = dataSource.getContentType();
|
|
||||||
|
|
||||||
if (!isBlank(dataSource.getName())) {
|
} catch (ReflectiveOperationException e) {
|
||||||
filename = dataSource.getName();
|
try {
|
||||||
}
|
Method getAllRecipients = messageClass.getMethod("getAllRecipients");
|
||||||
filename = safeMimeDecode(filename);
|
Object[] recipients = (Object[]) getAllRecipients.invoke(message);
|
||||||
|
content.setTo(buildAddressString(recipients));
|
||||||
// Generate unique filename for unnamed attachments
|
content.setCc("");
|
||||||
if (isBlank(filename)) {
|
content.setBcc("");
|
||||||
String extension = detectExtensionFromMimeType(contentType);
|
} catch (ReflectiveOperationException ex) {
|
||||||
filename = embedded ? resourceName : (ATTACHMENT_PREFIX + counter + extension);
|
content.setTo("");
|
||||||
}
|
content.setCc("");
|
||||||
attachment.setFilename(filename);
|
content.setBcc("");
|
||||||
|
|
||||||
String contentId = embedded ? stripCid(resourceName) : null;
|
|
||||||
attachment.setContentId(contentId);
|
|
||||||
|
|
||||||
String detectedContentType = EmlProcessingUtils.detectMimeType(filename, contentType);
|
|
||||||
attachment.setContentType(detectedContentType);
|
|
||||||
|
|
||||||
// Read data with size limit to prevent OOM
|
|
||||||
ReadResult readResult = readData(dataSource, embedded, request);
|
|
||||||
if (readResult != null) {
|
|
||||||
attachment.setSizeBytes(readResult.totalSize);
|
|
||||||
if (shouldIncludeAttachmentData(embedded, request, readResult)) {
|
|
||||||
attachment.setData(readResult.data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return attachment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldIncludeAttachmentData(
|
private static String buildAddressString(Object[] addresses) {
|
||||||
boolean embedded, EmlToPdfRequest request, ReadResult readResult) {
|
if (addresses == null || addresses.length == 0) {
|
||||||
// Always include embedded images for proper rendering
|
|
||||||
if (embedded) {
|
|
||||||
return readResult != null && readResult.data() != null;
|
|
||||||
}
|
|
||||||
// Check if attachments are requested and data is available within size limit
|
|
||||||
if (request == null || !request.isIncludeAttachments()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (readResult == null || readResult.data() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return readResult.data().length <= getMaxAttachmentSizeBytes(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String detectExtensionFromMimeType(String mimeType) {
|
|
||||||
if (mimeType == null) {
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String lower = mimeType.toLowerCase(Locale.ROOT);
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (int i = 0; i < addresses.length; i++) {
|
||||||
// Remove any parameters (e.g., "text/plain; charset=utf-8" -> "text/plain")
|
if (i > 0) builder.append(", ");
|
||||||
int semicolon = lower.indexOf(';');
|
builder.append(safeMimeDecode(addresses[i].toString()));
|
||||||
if (semicolon > 0) {
|
|
||||||
lower = lower.substring(0, semicolon).trim();
|
|
||||||
}
|
}
|
||||||
|
return builder.toString();
|
||||||
// Match exact MIME types first, then fall back to contains() for variants
|
|
||||||
return switch (lower) {
|
|
||||||
case "application/pdf" -> ".pdf";
|
|
||||||
case "image/png" -> ".png";
|
|
||||||
case "image/jpeg", "image/jpg" -> ".jpg";
|
|
||||||
case "image/gif" -> ".gif";
|
|
||||||
case "image/webp" -> ".webp";
|
|
||||||
case "image/bmp" -> ".bmp";
|
|
||||||
case "text/plain" -> ".txt";
|
|
||||||
case "text/html" -> ".html";
|
|
||||||
case "text/xml", "application/xml" -> ".xml";
|
|
||||||
case "application/json" -> ".json";
|
|
||||||
case "application/zip" -> ".zip";
|
|
||||||
case "application/octet-stream" -> ".bin";
|
|
||||||
default -> {
|
|
||||||
if (lower.contains("wordprocessingml") || lower.contains("msword")) yield ".docx";
|
|
||||||
if (lower.contains("spreadsheetml") || lower.contains("excel")) yield ".xlsx";
|
|
||||||
if (lower.contains("presentationml") || lower.contains("powerpoint")) yield ".pptx";
|
|
||||||
if (lower.contains("opendocument.text")) yield ".odt";
|
|
||||||
if (lower.contains("opendocument.spreadsheet")) yield ".ods";
|
|
||||||
yield "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReadResult readData(DataSource dataSource, boolean embedded, EmlToPdfRequest request)
|
private static void processMessageContent(
|
||||||
throws IOException {
|
Object message,
|
||||||
if (dataSource == null) {
|
Object messageContent,
|
||||||
return null;
|
EmailContent content,
|
||||||
}
|
EmlToPdfRequest request,
|
||||||
|
CustomHtmlSanitizer customHtmlSanitizer) {
|
||||||
|
try {
|
||||||
|
if (messageContent instanceof String stringContent) {
|
||||||
|
Method getContentType = message.getClass().getMethod("getContentType");
|
||||||
|
String contentType = (String) getContentType.invoke(message);
|
||||||
|
|
||||||
long maxBytes = getMaxAttachmentSizeBytes(request);
|
if (contentType != null && contentType.toLowerCase().contains(TEXT_HTML)) {
|
||||||
|
content.setHtmlBody(stringContent);
|
||||||
try (InputStream input = dataSource.getInputStream()) {
|
} else {
|
||||||
// Embedded images are usually needed for display regardless of size,
|
content.setTextBody(stringContent);
|
||||||
// but regular attachments should be guarded against OOM
|
|
||||||
if (!embedded && request != null) {
|
|
||||||
byte[] buffer = new byte[8192];
|
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
||||||
int bytesRead;
|
|
||||||
long totalBytes = 0;
|
|
||||||
while ((bytesRead = input.read(buffer)) != -1) {
|
|
||||||
totalBytes += bytesRead;
|
|
||||||
if (totalBytes > maxBytes) {
|
|
||||||
// Attachment too large - skip remaining data but estimate total size
|
|
||||||
long remainingBytes = countRemainingBytes(input, totalBytes);
|
|
||||||
log.debug(
|
|
||||||
"Attachment exceeds size limit: {} bytes (max: {} bytes), skipping",
|
|
||||||
remainingBytes,
|
|
||||||
maxBytes);
|
|
||||||
return new ReadResult(null, remainingBytes);
|
|
||||||
}
|
|
||||||
output.write(buffer, 0, bytesRead);
|
|
||||||
}
|
}
|
||||||
byte[] data = output.toByteArray();
|
|
||||||
return new ReadResult(data, data.length);
|
|
||||||
} else {
|
} else {
|
||||||
byte[] data = input.readAllBytes();
|
Class<?> multipartClass = Class.forName("jakarta.mail.Multipart");
|
||||||
return new ReadResult(data, data.length);
|
if (multipartClass.isInstance(messageContent)) {
|
||||||
|
processMultipart(messageContent, content, request, customHtmlSanitizer, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (ReflectiveOperationException | ClassCastException e) {
|
||||||
if (embedded) {
|
content.setTextBody("Email content could not be parsed with advanced processing");
|
||||||
log.debug(
|
|
||||||
"Failed to read embedded image, using empty placeholder: {}",
|
|
||||||
e.getMessage());
|
|
||||||
return new ReadResult(new byte[0], 0);
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countRemainingBytes(InputStream input, long alreadyRead) throws IOException {
|
private static void processMultipart(
|
||||||
long count = alreadyRead;
|
Object multipart,
|
||||||
|
EmailContent content,
|
||||||
|
EmlToPdfRequest request,
|
||||||
|
CustomHtmlSanitizer customHtmlSanitizer,
|
||||||
|
int depth) {
|
||||||
|
|
||||||
long skipped;
|
final int MAX_MULTIPART_DEPTH = 10;
|
||||||
while (count < MAX_SIZE_ESTIMATION_BYTES
|
if (depth > MAX_MULTIPART_DEPTH) {
|
||||||
&& (skipped = input.skip(MAX_SIZE_ESTIMATION_BYTES - count)) > 0) {
|
content.setHtmlBody("<div class=\"error\">Maximum multipart depth exceeded</div>");
|
||||||
count += skipped;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count < MAX_SIZE_ESTIMATION_BYTES && input.available() > 0) {
|
try {
|
||||||
byte[] buffer = new byte[8192];
|
Class<?> multipartClass = multipart.getClass();
|
||||||
int read;
|
Method getCount = multipartClass.getMethod("getCount");
|
||||||
while ((read = input.read(buffer)) != -1 && count < MAX_SIZE_ESTIMATION_BYTES) {
|
int count = (Integer) getCount.invoke(multipart);
|
||||||
count += read;
|
|
||||||
|
Method getBodyPart = multipartClass.getMethod("getBodyPart", int.class);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
Object part = getBodyPart.invoke(multipart, i);
|
||||||
|
processPart(part, content, request, customHtmlSanitizer, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
} catch (ReflectiveOperationException | ClassCastException e) {
|
||||||
|
content.setHtmlBody("<div class=\"error\">Error processing multipart content</div>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatRecipients(List<Recipient> recipients, RecipientType type) {
|
private static void processPart(
|
||||||
if (recipients == null || type == null) {
|
Object part,
|
||||||
|
EmailContent content,
|
||||||
|
EmlToPdfRequest request,
|
||||||
|
CustomHtmlSanitizer customHtmlSanitizer,
|
||||||
|
int depth) {
|
||||||
|
try {
|
||||||
|
Class<?> partClass = part.getClass();
|
||||||
|
|
||||||
|
Method isMimeType = partClass.getMethod("isMimeType", String.class);
|
||||||
|
Method getContent = partClass.getMethod("getContent");
|
||||||
|
Method getDisposition = partClass.getMethod("getDisposition");
|
||||||
|
Method getFileName = partClass.getMethod("getFileName");
|
||||||
|
Method getContentType = partClass.getMethod("getContentType");
|
||||||
|
Method getHeader = partClass.getMethod("getHeader", String.class);
|
||||||
|
|
||||||
|
Object disposition = getDisposition.invoke(part);
|
||||||
|
String filename = (String) getFileName.invoke(part);
|
||||||
|
String contentType = (String) getContentType.invoke(part);
|
||||||
|
|
||||||
|
String normalizedDisposition =
|
||||||
|
disposition != null ? ((String) disposition).toLowerCase() : null;
|
||||||
|
|
||||||
|
if ((Boolean) isMimeType.invoke(part, TEXT_PLAIN) && normalizedDisposition == null) {
|
||||||
|
Object partContent = getContent.invoke(part);
|
||||||
|
if (partContent instanceof String stringContent) {
|
||||||
|
content.setTextBody(stringContent);
|
||||||
|
}
|
||||||
|
} else if ((Boolean) isMimeType.invoke(part, TEXT_HTML)
|
||||||
|
&& normalizedDisposition == null) {
|
||||||
|
Object partContent = getContent.invoke(part);
|
||||||
|
if (partContent instanceof String stringContent) {
|
||||||
|
String htmlBody =
|
||||||
|
customHtmlSanitizer != null
|
||||||
|
? customHtmlSanitizer.sanitize(stringContent)
|
||||||
|
: stringContent;
|
||||||
|
content.setHtmlBody(htmlBody);
|
||||||
|
}
|
||||||
|
} else if ((normalizedDisposition != null
|
||||||
|
&& normalizedDisposition.contains(DISPOSITION_ATTACHMENT))
|
||||||
|
|| (filename != null && !filename.trim().isEmpty())) {
|
||||||
|
|
||||||
|
processAttachment(
|
||||||
|
part, content, request, getHeader, getContent, filename, contentType);
|
||||||
|
} else if ((Boolean) isMimeType.invoke(part, "multipart/*")) {
|
||||||
|
Object multipartContent = getContent.invoke(part);
|
||||||
|
if (multipartContent != null) {
|
||||||
|
Class<?> multipartClass = Class.forName("jakarta.mail.Multipart");
|
||||||
|
if (multipartClass.isInstance(multipartContent)) {
|
||||||
|
processMultipart(
|
||||||
|
multipartContent, content, request, customHtmlSanitizer, depth + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ReflectiveOperationException | RuntimeException e) {
|
||||||
|
// Continue processing other parts if one fails
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void processAttachment(
|
||||||
|
Object part,
|
||||||
|
EmailContent content,
|
||||||
|
EmlToPdfRequest request,
|
||||||
|
Method getHeader,
|
||||||
|
Method getContent,
|
||||||
|
String filename,
|
||||||
|
String contentType) {
|
||||||
|
|
||||||
|
content.setAttachmentCount(content.getAttachmentCount() + 1);
|
||||||
|
|
||||||
|
if (filename != null && !filename.trim().isEmpty()) {
|
||||||
|
EmailAttachment attachment = new EmailAttachment();
|
||||||
|
attachment.setFilename(safeMimeDecode(filename));
|
||||||
|
attachment.setContentType(contentType);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String[] contentIdHeaders = (String[]) getHeader.invoke(part, HEADER_CONTENT_ID);
|
||||||
|
if (contentIdHeaders != null) {
|
||||||
|
for (String contentIdHeader : contentIdHeaders) {
|
||||||
|
if (contentIdHeader != null && !contentIdHeader.trim().isEmpty()) {
|
||||||
|
attachment.setEmbedded(true);
|
||||||
|
String contentId = contentIdHeader.trim().replaceAll("[<>]", "");
|
||||||
|
attachment.setContentId(contentId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((request != null && request.isIncludeAttachments()) || attachment.isEmbedded()) {
|
||||||
|
extractAttachmentData(part, attachment, getContent, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
content.getAttachments().add(attachment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void extractAttachmentData(
|
||||||
|
Object part, EmailAttachment attachment, Method getContent, EmlToPdfRequest request) {
|
||||||
|
try {
|
||||||
|
Object attachmentContent = getContent.invoke(part);
|
||||||
|
byte[] attachmentData = null;
|
||||||
|
|
||||||
|
if (attachmentContent instanceof InputStream inputStream) {
|
||||||
|
try (InputStream stream = inputStream) {
|
||||||
|
attachmentData = stream.readAllBytes();
|
||||||
|
} catch (IOException e) {
|
||||||
|
if (attachment.isEmbedded()) {
|
||||||
|
attachmentData = new byte[0];
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (attachmentContent instanceof byte[] byteArray) {
|
||||||
|
attachmentData = byteArray;
|
||||||
|
} else if (attachmentContent instanceof String stringContent) {
|
||||||
|
attachmentData = stringContent.getBytes(StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attachmentData != null) {
|
||||||
|
long maxSizeMB = request != null ? request.getMaxAttachmentSizeMB() : 10L;
|
||||||
|
long maxSizeBytes = maxSizeMB * 1024 * 1024;
|
||||||
|
|
||||||
|
if (attachmentData.length <= maxSizeBytes || attachment.isEmbedded()) {
|
||||||
|
attachment.setData(attachmentData);
|
||||||
|
attachment.setSizeBytes(attachmentData.length);
|
||||||
|
} else {
|
||||||
|
attachment.setSizeBytes(attachmentData.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ReflectiveOperationException | RuntimeException e) {
|
||||||
|
// Continue without attachment data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String extractBasicHeader(String emlContent, String headerName) {
|
||||||
|
try {
|
||||||
|
String[] lines = emlContent.split("\r?\n");
|
||||||
|
for (int i = 0; i < lines.length; i++) {
|
||||||
|
String line = lines[i];
|
||||||
|
if (line.toLowerCase().startsWith(headerName.toLowerCase())) {
|
||||||
|
StringBuilder value =
|
||||||
|
new StringBuilder(line.substring(headerName.length()).trim());
|
||||||
|
for (int j = i + 1; j < lines.length; j++) {
|
||||||
|
if (lines[j].startsWith(" ") || lines[j].startsWith("\t")) {
|
||||||
|
value.append(" ").append(lines[j].trim());
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return safeMimeDecode(value.toString());
|
||||||
|
}
|
||||||
|
if (line.trim().isEmpty()) break;
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// Ignore errors in header extraction
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String extractHtmlBody(String emlContent) {
|
||||||
|
try {
|
||||||
|
String lowerContent = emlContent.toLowerCase();
|
||||||
|
int htmlStart = lowerContent.indexOf(HEADER_CONTENT_TYPE + " " + TEXT_HTML);
|
||||||
|
if (htmlStart == -1) return null;
|
||||||
|
|
||||||
|
int bodyStart = emlContent.indexOf("\r\n\r\n", htmlStart);
|
||||||
|
if (bodyStart == -1) bodyStart = emlContent.indexOf("\n\n", htmlStart);
|
||||||
|
if (bodyStart == -1) return null;
|
||||||
|
|
||||||
|
bodyStart += (emlContent.charAt(bodyStart + 1) == '\r') ? 4 : 2;
|
||||||
|
int bodyEnd = findPartEnd(emlContent, bodyStart);
|
||||||
|
|
||||||
|
return emlContent.substring(bodyStart, bodyEnd).trim();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String extractTextBody(String emlContent) {
|
||||||
|
try {
|
||||||
|
String lowerContent = emlContent.toLowerCase();
|
||||||
|
int textStart = lowerContent.indexOf(HEADER_CONTENT_TYPE + " " + TEXT_PLAIN);
|
||||||
|
if (textStart == -1) {
|
||||||
|
int bodyStart = emlContent.indexOf("\r\n\r\n");
|
||||||
|
if (bodyStart == -1) bodyStart = emlContent.indexOf("\n\n");
|
||||||
|
if (bodyStart != -1) {
|
||||||
|
bodyStart += (emlContent.charAt(bodyStart + 1) == '\r') ? 4 : 2;
|
||||||
|
int bodyEnd = findPartEnd(emlContent, bodyStart);
|
||||||
|
return emlContent.substring(bodyStart, bodyEnd).trim();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int bodyStart = emlContent.indexOf("\r\n\r\n", textStart);
|
||||||
|
if (bodyStart == -1) bodyStart = emlContent.indexOf("\n\n", textStart);
|
||||||
|
if (bodyStart == -1) return null;
|
||||||
|
|
||||||
|
bodyStart += (emlContent.charAt(bodyStart + 1) == '\r') ? 4 : 2;
|
||||||
|
int bodyEnd = findPartEnd(emlContent, bodyStart);
|
||||||
|
|
||||||
|
return emlContent.substring(bodyStart, bodyEnd).trim();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int findPartEnd(String content, int start) {
|
||||||
|
String[] lines = content.substring(start).split("\r?\n");
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
|
for (String line : lines) {
|
||||||
|
if (line.startsWith("--") && line.length() > 10) break;
|
||||||
|
result.append(line).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return start + result.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<EmailAttachment> extractAttachmentsBasic(String emlContent) {
|
||||||
|
List<EmailAttachment> attachments = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
String[] lines = emlContent.split("\r?\n");
|
||||||
|
boolean inHeaders = true;
|
||||||
|
String currentContentType = "";
|
||||||
|
String currentDisposition = "";
|
||||||
|
String currentFilename = "";
|
||||||
|
String currentEncoding = "";
|
||||||
|
|
||||||
|
for (String line : lines) {
|
||||||
|
String lowerLine = line.toLowerCase().trim();
|
||||||
|
|
||||||
|
if (line.trim().isEmpty()) {
|
||||||
|
inHeaders = false;
|
||||||
|
if (isAttachment(currentDisposition, currentFilename, currentContentType)) {
|
||||||
|
EmailAttachment attachment = new EmailAttachment();
|
||||||
|
attachment.setFilename(currentFilename);
|
||||||
|
attachment.setContentType(currentContentType);
|
||||||
|
attachment.setTransferEncoding(currentEncoding);
|
||||||
|
attachments.add(attachment);
|
||||||
|
}
|
||||||
|
currentContentType = "";
|
||||||
|
currentDisposition = "";
|
||||||
|
currentFilename = "";
|
||||||
|
currentEncoding = "";
|
||||||
|
inHeaders = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inHeaders) continue;
|
||||||
|
|
||||||
|
if (lowerLine.startsWith(HEADER_CONTENT_TYPE)) {
|
||||||
|
currentContentType = line.substring(HEADER_CONTENT_TYPE.length()).trim();
|
||||||
|
} else if (lowerLine.startsWith(HEADER_CONTENT_DISPOSITION)) {
|
||||||
|
currentDisposition = line.substring(HEADER_CONTENT_DISPOSITION.length()).trim();
|
||||||
|
currentFilename = extractFilenameFromDisposition(currentDisposition);
|
||||||
|
} else if (lowerLine.startsWith(HEADER_CONTENT_TRANSFER_ENCODING)) {
|
||||||
|
currentEncoding =
|
||||||
|
line.substring(HEADER_CONTENT_TRANSFER_ENCODING.length()).trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// Continue with empty list
|
||||||
|
}
|
||||||
|
return attachments;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isAttachment(String disposition, String filename, String contentType) {
|
||||||
|
return (disposition.toLowerCase().contains(DISPOSITION_ATTACHMENT) && !filename.isEmpty())
|
||||||
|
|| (!filename.isEmpty() && !contentType.toLowerCase().startsWith("text/"))
|
||||||
|
|| (contentType.toLowerCase().contains("application/") && !filename.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String extractFilenameFromDisposition(String disposition) {
|
||||||
|
if (disposition == null || !disposition.contains("filename=")) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return recipients.stream()
|
// Handle filename*= (RFC 2231 encoded filename)
|
||||||
.filter(Objects::nonNull)
|
if (disposition.toLowerCase().contains("filename*=")) {
|
||||||
// Use type.equals() for null-safe comparison (recipient.getType() may be null)
|
int filenameStarStart = disposition.toLowerCase().indexOf("filename*=") + 10;
|
||||||
.filter(recipient -> type.equals(recipient.getType()))
|
int filenameStarEnd = disposition.indexOf(";", filenameStarStart);
|
||||||
.map(EmlParser::formatRecipient)
|
if (filenameStarEnd == -1) filenameStarEnd = disposition.length();
|
||||||
.filter(string -> !isBlank(string))
|
String extendedFilename =
|
||||||
.collect(Collectors.joining(", "));
|
disposition.substring(filenameStarStart, filenameStarEnd).trim();
|
||||||
|
extendedFilename = extendedFilename.replaceAll("^\"|\"$", "");
|
||||||
|
|
||||||
|
if (extendedFilename.contains("'")) {
|
||||||
|
String[] parts = extendedFilename.split("'", 3);
|
||||||
|
if (parts.length == 3) {
|
||||||
|
return EmlProcessingUtils.decodeUrlEncoded(parts[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle regular filename=
|
||||||
|
int filenameStart = disposition.toLowerCase().indexOf("filename=") + 9;
|
||||||
|
int filenameEnd = disposition.indexOf(";", filenameStart);
|
||||||
|
if (filenameEnd == -1) filenameEnd = disposition.length();
|
||||||
|
String filename = disposition.substring(filenameStart, filenameEnd).trim();
|
||||||
|
filename = filename.replaceAll("^\"|\"$", "");
|
||||||
|
return safeMimeDecode(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatRecipient(Recipient recipient) {
|
public static String safeMimeDecode(String headerValue) {
|
||||||
if (recipient == null) {
|
if (headerValue == null || headerValue.trim().isEmpty()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = safeMimeDecode(recipient.getName());
|
if (!mimeUtilityChecked) {
|
||||||
String address = safeMimeDecode(recipient.getAddress());
|
synchronized (EmlParser.class) {
|
||||||
|
if (!mimeUtilityChecked) {
|
||||||
if (!isBlank(name) && !isBlank(address)) {
|
initializeMimeUtilityDecoding();
|
||||||
return name + " <" + address + ">";
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return !isBlank(name) ? name : address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String safeMimeDecode(String headerValue) {
|
if (mimeUtilityDecodeTextMethod != null) {
|
||||||
if (isBlank(headerValue)) {
|
try {
|
||||||
return "";
|
return (String) mimeUtilityDecodeTextMethod.invoke(null, headerValue.trim());
|
||||||
|
} catch (ReflectiveOperationException | RuntimeException e) {
|
||||||
|
// Fall through to custom implementation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EmlProcessingUtils.decodeMimeHeader(headerValue.trim());
|
return EmlProcessingUtils.decodeMimeHeader(headerValue.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String stripCid(String contentId) {
|
private static void initializeMimeUtilityDecoding() {
|
||||||
if (contentId == null) {
|
try {
|
||||||
return null;
|
Class<?> mimeUtilityClass = Class.forName("jakarta.mail.internet.MimeUtility");
|
||||||
}
|
mimeUtilityDecodeTextMethod = mimeUtilityClass.getMethod("decodeText", String.class);
|
||||||
return RegexPatternUtils.getInstance()
|
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||||
.getAngleBracketsPattern()
|
mimeUtilityDecodeTextMethod = null;
|
||||||
.matcher(contentId)
|
|
||||||
.replaceAll("")
|
|
||||||
.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
private long getMaxAttachmentSizeBytes(EmlToPdfRequest request) {
|
|
||||||
long maxMb = request != null ? request.getMaxAttachmentSizeMB() : DEFAULT_MAX_ATTACHMENT_MB;
|
|
||||||
return maxMb * 1024L * 1024L;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isBlank(String value) {
|
|
||||||
return value == null || value.trim().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String defaultString(String value) {
|
|
||||||
return value != null ? value : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private record ReadResult(byte[] data, long totalSize) {
|
|
||||||
public ReadResult {
|
|
||||||
if (totalSize < 0) {
|
|
||||||
throw new IllegalArgumentException("Size cannot be negative: " + totalSize);
|
|
||||||
}
|
|
||||||
if (data != null && data.length > totalSize) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Data length (" + data.length + ") exceeds total size (" + totalSize + ")");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
mimeUtilityChecked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class EmailContent {
|
public static class EmailContent {
|
||||||
private String subject;
|
private String subject;
|
||||||
private String from;
|
private String from;
|
||||||
private String to;
|
private String to;
|
||||||
private String cc;
|
private String cc;
|
||||||
private String bcc;
|
private String bcc;
|
||||||
private ZonedDateTime date;
|
private Date date;
|
||||||
private String dateString; // Maintained for compatibility
|
private String dateString; // For basic parsing fallback
|
||||||
private String htmlBody;
|
private String htmlBody;
|
||||||
private String textBody;
|
private String textBody;
|
||||||
private int attachmentCount;
|
private int attachmentCount;
|
||||||
private List<EmailAttachment> attachments = new ArrayList<>();
|
private List<EmailAttachment> attachments = new ArrayList<>();
|
||||||
|
|
||||||
public void setHtmlBody(String htmlBody) {
|
public void setHtmlBody(String htmlBody) {
|
||||||
this.htmlBody =
|
this.htmlBody = htmlBody != null ? htmlBody.replaceAll("\r", "") : null;
|
||||||
htmlBody != null
|
|
||||||
? RegexPatternUtils.getInstance()
|
|
||||||
.getCarriageReturnPattern()
|
|
||||||
.matcher(htmlBody)
|
|
||||||
.replaceAll("")
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextBody(String textBody) {
|
public void setTextBody(String textBody) {
|
||||||
this.textBody =
|
this.textBody = textBody != null ? textBody.replaceAll("\r", "") : null;
|
||||||
textBody != null
|
|
||||||
? RegexPatternUtils.getInstance()
|
|
||||||
.getCarriageReturnPattern()
|
|
||||||
.matcher(textBody)
|
|
||||||
.replaceAll("")
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class EmailAttachment {
|
public static class EmailAttachment {
|
||||||
private String filename;
|
private String filename;
|
||||||
private String contentType;
|
private String contentType;
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package stirling.software.common.util;
|
package stirling.software.common.util;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
@@ -10,82 +8,53 @@ import java.util.Map;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
|
|
||||||
import lombok.Synchronized;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import stirling.software.common.model.api.converters.EmlToPdfRequest;
|
import stirling.software.common.model.api.converters.EmlToPdfRequest;
|
||||||
import stirling.software.common.model.api.converters.HTMLToPdfRequest;
|
import stirling.software.common.model.api.converters.HTMLToPdfRequest;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class EmlProcessingUtils {
|
public class EmlProcessingUtils {
|
||||||
|
|
||||||
// Style constants
|
// Style constants
|
||||||
private final int DEFAULT_FONT_SIZE = 12;
|
private static final int DEFAULT_FONT_SIZE = 12;
|
||||||
private final String DEFAULT_FONT_FAMILY = "Helvetica, sans-serif";
|
private static final String DEFAULT_FONT_FAMILY = "Helvetica, sans-serif";
|
||||||
private final float DEFAULT_LINE_HEIGHT = 1.4f;
|
private static final float DEFAULT_LINE_HEIGHT = 1.4f;
|
||||||
private final String DEFAULT_ZOOM = "1.0";
|
private static final String DEFAULT_ZOOM = "1.0";
|
||||||
private final String DEFAULT_TEXT_COLOR = "#202124";
|
private static final String DEFAULT_TEXT_COLOR = "#202124";
|
||||||
private final String DEFAULT_BACKGROUND_COLOR = "#ffffff";
|
private static final String DEFAULT_BACKGROUND_COLOR = "#ffffff";
|
||||||
private final String DEFAULT_BORDER_COLOR = "#e8eaed";
|
private static final String DEFAULT_BORDER_COLOR = "#e8eaed";
|
||||||
private final String ATTACHMENT_BACKGROUND_COLOR = "#f9f9f9";
|
private static final String ATTACHMENT_BACKGROUND_COLOR = "#f9f9f9";
|
||||||
private final String ATTACHMENT_BORDER_COLOR = "#eeeeee";
|
private static final String ATTACHMENT_BORDER_COLOR = "#eeeeee";
|
||||||
|
|
||||||
private final String CSS_RESOURCE_PATH = "templates/email-pdf-styles.css";
|
private static final int EML_CHECK_LENGTH = 8192;
|
||||||
private final int EML_CHECK_LENGTH = 8192;
|
private static final int MIN_HEADER_COUNT_FOR_VALID_EML = 2;
|
||||||
private final int MIN_HEADER_COUNT_FOR_VALID_EML = 2;
|
|
||||||
// MSG file magic bytes (Compound File Binary Format / OLE2)
|
// MIME type detection
|
||||||
// D0 CF 11 E0 A1 B1 1A E1
|
private static final Map<String, String> EXTENSION_TO_MIME_TYPE =
|
||||||
private final byte[] MSG_MAGIC_BYTES = {
|
|
||||||
(byte) 0xD0, (byte) 0xCF, (byte) 0x11, (byte) 0xE0,
|
|
||||||
(byte) 0xA1, (byte) 0xB1, (byte) 0x1A, (byte) 0xE1
|
|
||||||
};
|
|
||||||
private final Map<String, String> EXTENSION_TO_MIME_TYPE =
|
|
||||||
Map.of(
|
Map.of(
|
||||||
".png", MediaType.IMAGE_PNG_VALUE,
|
".png", "image/png",
|
||||||
".jpg", MediaType.IMAGE_JPEG_VALUE,
|
".jpg", "image/jpeg",
|
||||||
".jpeg", MediaType.IMAGE_JPEG_VALUE,
|
".jpeg", "image/jpeg",
|
||||||
".gif", MediaType.IMAGE_GIF_VALUE,
|
".gif", "image/gif",
|
||||||
".bmp", "image/bmp",
|
".bmp", "image/bmp",
|
||||||
".webp", "image/webp",
|
".webp", "image/webp",
|
||||||
".svg", "image/svg+xml",
|
".svg", "image/svg+xml",
|
||||||
".ico", "image/x-icon",
|
".ico", "image/x-icon",
|
||||||
".tiff", "image/tiff",
|
".tiff", "image/tiff",
|
||||||
".tif", "image/tiff");
|
".tif", "image/tiff");
|
||||||
private volatile String cachedCssContent = null;
|
|
||||||
|
|
||||||
public void validateEmlInput(byte[] emlBytes) {
|
public static void validateEmlInput(byte[] emlBytes) {
|
||||||
if (emlBytes == null || emlBytes.length == 0) {
|
if (emlBytes == null || emlBytes.length == 0) {
|
||||||
throw ExceptionUtils.createEmlEmptyException();
|
throw new IllegalArgumentException("EML file is empty or null");
|
||||||
}
|
|
||||||
|
|
||||||
if (isMsgFile(emlBytes)) {
|
|
||||||
return; // Valid MSG file, no further EML validation needed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInvalidEmlFormat(emlBytes)) {
|
if (isInvalidEmlFormat(emlBytes)) {
|
||||||
throw ExceptionUtils.createEmlInvalidFormatException();
|
throw new IllegalArgumentException("Invalid EML file format");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMsgFile(byte[] fileBytes) {
|
private static boolean isInvalidEmlFormat(byte[] emlBytes) {
|
||||||
if (fileBytes == null || fileBytes.length < MSG_MAGIC_BYTES.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < MSG_MAGIC_BYTES.length; i++) {
|
|
||||||
if (fileBytes[i] != MSG_MAGIC_BYTES[i]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isInvalidEmlFormat(byte[] emlBytes) {
|
|
||||||
try {
|
try {
|
||||||
int checkLength = Math.min(emlBytes.length, EML_CHECK_LENGTH);
|
int checkLength = Math.min(emlBytes.length, EML_CHECK_LENGTH);
|
||||||
String content;
|
String content;
|
||||||
@@ -112,8 +81,8 @@ public class EmlProcessingUtils {
|
|||||||
|| lowerContent.contains("bcc:");
|
|| lowerContent.contains("bcc:");
|
||||||
boolean hasMimeStructure =
|
boolean hasMimeStructure =
|
||||||
lowerContent.contains("multipart/")
|
lowerContent.contains("multipart/")
|
||||||
|| lowerContent.contains(MediaType.TEXT_PLAIN_VALUE)
|
|| lowerContent.contains("text/plain")
|
||||||
|| lowerContent.contains(MediaType.TEXT_HTML_VALUE)
|
|| lowerContent.contains("text/html")
|
||||||
|| lowerContent.contains("boundary=");
|
|| lowerContent.contains("boundary=");
|
||||||
|
|
||||||
int headerCount = 0;
|
int headerCount = 0;
|
||||||
@@ -130,7 +99,7 @@ public class EmlProcessingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String generateEnhancedEmailHtml(
|
public static String generateEnhancedEmailHtml(
|
||||||
EmlParser.EmailContent content,
|
EmlParser.EmailContent content,
|
||||||
EmlToPdfRequest request,
|
EmlToPdfRequest request,
|
||||||
CustomHtmlSanitizer customHtmlSanitizer) {
|
CustomHtmlSanitizer customHtmlSanitizer) {
|
||||||
@@ -138,13 +107,12 @@ public class EmlProcessingUtils {
|
|||||||
|
|
||||||
html.append(
|
html.append(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
|
||||||
"""
|
"""
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en"><head><meta charset="UTF-8">
|
<html lang="en"><head><meta charset="UTF-8">
|
||||||
<title>%s</title>
|
<title>%s</title>
|
||||||
<style>
|
<style>
|
||||||
""",
|
""",
|
||||||
sanitizeText(content.getSubject(), customHtmlSanitizer)));
|
sanitizeText(content.getSubject(), customHtmlSanitizer)));
|
||||||
|
|
||||||
appendEnhancedStyles(html);
|
appendEnhancedStyles(html);
|
||||||
@@ -157,15 +125,14 @@ public class EmlProcessingUtils {
|
|||||||
|
|
||||||
html.append(
|
html.append(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
|
||||||
"""
|
"""
|
||||||
<div class="email-container">
|
<div class="email-container">
|
||||||
<div class="email-header">
|
<div class="email-header">
|
||||||
<h1>%s</h1>
|
<h1>%s</h1>
|
||||||
<div class="email-meta">
|
<div class="email-meta">
|
||||||
<div><strong>From:</strong> %s</div>
|
<div><strong>From:</strong> %s</div>
|
||||||
<div><strong>To:</strong> %s</div>
|
<div><strong>To:</strong> %s</div>
|
||||||
""",
|
""",
|
||||||
sanitizeText(content.getSubject(), customHtmlSanitizer),
|
sanitizeText(content.getSubject(), customHtmlSanitizer),
|
||||||
sanitizeText(content.getFrom(), customHtmlSanitizer),
|
sanitizeText(content.getFrom(), customHtmlSanitizer),
|
||||||
sanitizeText(content.getTo(), customHtmlSanitizer)));
|
sanitizeText(content.getTo(), customHtmlSanitizer)));
|
||||||
@@ -173,36 +140,32 @@ public class EmlProcessingUtils {
|
|||||||
if (content.getCc() != null && !content.getCc().trim().isEmpty()) {
|
if (content.getCc() != null && !content.getCc().trim().isEmpty()) {
|
||||||
html.append(
|
html.append(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
"<div><strong>CC:</strong> %s</div>\n",
|
||||||
"<div><strong>CC:</strong> %s</div>%n",
|
|
||||||
sanitizeText(content.getCc(), customHtmlSanitizer)));
|
sanitizeText(content.getCc(), customHtmlSanitizer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.getBcc() != null && !content.getBcc().trim().isEmpty()) {
|
if (content.getBcc() != null && !content.getBcc().trim().isEmpty()) {
|
||||||
html.append(
|
html.append(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
"<div><strong>BCC:</strong> %s</div>\n",
|
||||||
"<div><strong>BCC:</strong> %s</div>%n",
|
|
||||||
sanitizeText(content.getBcc(), customHtmlSanitizer)));
|
sanitizeText(content.getBcc(), customHtmlSanitizer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.getDate() != null) {
|
if (content.getDate() != null) {
|
||||||
html.append(
|
html.append(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
"<div><strong>Date:</strong> %s</div>\n",
|
||||||
"<div><strong>Date:</strong> %s</div>%n",
|
|
||||||
PdfAttachmentHandler.formatEmailDate(content.getDate())));
|
PdfAttachmentHandler.formatEmailDate(content.getDate())));
|
||||||
} else if (content.getDateString() != null && !content.getDateString().trim().isEmpty()) {
|
} else if (content.getDateString() != null && !content.getDateString().trim().isEmpty()) {
|
||||||
html.append(
|
html.append(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
"<div><strong>Date:</strong> %s</div>\n",
|
||||||
"<div><strong>Date:</strong> %s</div>%n",
|
|
||||||
sanitizeText(content.getDateString(), customHtmlSanitizer)));
|
sanitizeText(content.getDateString(), customHtmlSanitizer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
html.append(String.format(Locale.ROOT, "</div></div>%n"));
|
html.append("</div></div>\n");
|
||||||
|
|
||||||
html.append(String.format(Locale.ROOT, "<div class=\"email-body\">%n"));
|
html.append("<div class=\"email-body\">\n");
|
||||||
if (content.getHtmlBody() != null && !content.getHtmlBody().trim().isEmpty()) {
|
if (content.getHtmlBody() != null && !content.getHtmlBody().trim().isEmpty()) {
|
||||||
String processedHtml =
|
String processedHtml =
|
||||||
processEmailHtmlBody(content.getHtmlBody(), content, customHtmlSanitizer);
|
processEmailHtmlBody(content.getHtmlBody(), content, customHtmlSanitizer);
|
||||||
@@ -210,23 +173,22 @@ public class EmlProcessingUtils {
|
|||||||
} else if (content.getTextBody() != null && !content.getTextBody().trim().isEmpty()) {
|
} else if (content.getTextBody() != null && !content.getTextBody().trim().isEmpty()) {
|
||||||
html.append(
|
html.append(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
|
||||||
"<div class=\"text-body\">%s</div>",
|
"<div class=\"text-body\">%s</div>",
|
||||||
convertTextToHtml(content.getTextBody(), customHtmlSanitizer)));
|
convertTextToHtml(content.getTextBody(), customHtmlSanitizer)));
|
||||||
} else {
|
} else {
|
||||||
html.append("<div class=\"no-content\"><p><em>No content available</em></p></div>");
|
html.append("<div class=\"no-content\"><p><em>No content available</em></p></div>");
|
||||||
}
|
}
|
||||||
html.append(String.format(Locale.ROOT, "</div>%n"));
|
html.append("</div>\n");
|
||||||
|
|
||||||
if (content.getAttachmentCount() > 0 || !content.getAttachments().isEmpty()) {
|
if (content.getAttachmentCount() > 0 || !content.getAttachments().isEmpty()) {
|
||||||
appendAttachmentsSection(html, content, request);
|
appendAttachmentsSection(html, content, request, customHtmlSanitizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
html.append(String.format(Locale.ROOT, "</div>%n</body></html>"));
|
html.append("</div>\n</body></html>");
|
||||||
return html.toString();
|
return html.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String processEmailHtmlBody(
|
public static String processEmailHtmlBody(
|
||||||
String htmlBody,
|
String htmlBody,
|
||||||
EmlParser.EmailContent emailContent,
|
EmlParser.EmailContent emailContent,
|
||||||
CustomHtmlSanitizer customHtmlSanitizer) {
|
CustomHtmlSanitizer customHtmlSanitizer) {
|
||||||
@@ -235,16 +197,8 @@ public class EmlProcessingUtils {
|
|||||||
String processed =
|
String processed =
|
||||||
customHtmlSanitizer != null ? customHtmlSanitizer.sanitize(htmlBody) : htmlBody;
|
customHtmlSanitizer != null ? customHtmlSanitizer.sanitize(htmlBody) : htmlBody;
|
||||||
|
|
||||||
processed =
|
processed = processed.replaceAll("(?i)\\s*position\\s*:\\s*fixed[^;]*;?", "");
|
||||||
RegexPatternUtils.getInstance()
|
processed = processed.replaceAll("(?i)\\s*position\\s*:\\s*absolute[^;]*;?", "");
|
||||||
.getFixedPositionCssPattern()
|
|
||||||
.matcher(processed)
|
|
||||||
.replaceAll("");
|
|
||||||
processed =
|
|
||||||
RegexPatternUtils.getInstance()
|
|
||||||
.getAbsolutePositionCssPattern()
|
|
||||||
.matcher(processed)
|
|
||||||
.replaceAll("");
|
|
||||||
|
|
||||||
if (emailContent != null && !emailContent.getAttachments().isEmpty()) {
|
if (emailContent != null && !emailContent.getAttachments().isEmpty()) {
|
||||||
processed = PdfAttachmentHandler.processInlineImages(processed, emailContent);
|
processed = PdfAttachmentHandler.processInlineImages(processed, emailContent);
|
||||||
@@ -253,7 +207,8 @@ public class EmlProcessingUtils {
|
|||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String convertTextToHtml(String textBody, CustomHtmlSanitizer customHtmlSanitizer) {
|
public static String convertTextToHtml(
|
||||||
|
String textBody, CustomHtmlSanitizer customHtmlSanitizer) {
|
||||||
if (textBody == null) return "";
|
if (textBody == null) return "";
|
||||||
|
|
||||||
String html =
|
String html =
|
||||||
@@ -265,115 +220,171 @@ public class EmlProcessingUtils {
|
|||||||
html = html.replace("\n", "<br>\n");
|
html = html.replace("\n", "<br>\n");
|
||||||
|
|
||||||
html =
|
html =
|
||||||
RegexPatternUtils.getInstance()
|
html.replaceAll(
|
||||||
.getUrlLinkPattern()
|
"(https?://[\\w\\-._~:/?#\\[\\]@!$&'()*+,;=%]+)",
|
||||||
.matcher(html)
|
"<a href=\"$1\" style=\"color: #1a73e8; text-decoration: underline;\">$1</a>");
|
||||||
.replaceAll(
|
|
||||||
"<a href=\"$1\" style=\"color: #1a73e8; text-decoration:"
|
|
||||||
+ " underline;\">$1</a>");
|
|
||||||
|
|
||||||
html =
|
html =
|
||||||
RegexPatternUtils.getInstance()
|
html.replaceAll(
|
||||||
.getEmailLinkPattern()
|
"([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,63})",
|
||||||
.matcher(html)
|
"<a href=\"mailto:$1\" style=\"color: #1a73e8; text-decoration: underline;\">$1</a>");
|
||||||
.replaceAll(
|
|
||||||
"<a href=\"mailto:$1\" style=\"color: #1a73e8; text-decoration:"
|
|
||||||
+ " underline;\">$1</a>");
|
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendEnhancedStyles(StringBuilder html) {
|
private static void appendEnhancedStyles(StringBuilder html) {
|
||||||
html.append(
|
String css =
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
|
||||||
"""
|
"""
|
||||||
:root {
|
body {
|
||||||
--font-family: %s;
|
font-family: %s;
|
||||||
--font-size: %dpx;
|
font-size: %dpx;
|
||||||
--line-height: %s;
|
line-height: %s;
|
||||||
--text-color: %s;
|
color: %s;
|
||||||
--bg-color: %s;
|
margin: 0;
|
||||||
--border-color: %s;
|
padding: 16px;
|
||||||
--header-font-size: %dpx;
|
background-color: %s;
|
||||||
--meta-font-size: %dpx;
|
}
|
||||||
--attachment-bg: %s;
|
|
||||||
--attachment-border: %s;
|
.email-container {
|
||||||
--attachment-header-size: %dpx;
|
width: 100%%;
|
||||||
--attachment-detail-size: %dpx;
|
max-width: 100%%;
|
||||||
--note-font-size: %dpx;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
""",
|
|
||||||
|
.email-header {
|
||||||
|
padding-bottom: 10px;
|
||||||
|
border-bottom: 1px solid %s;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.email-header h1 {
|
||||||
|
margin: 0 0 10px 0;
|
||||||
|
font-size: %dpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.email-meta div {
|
||||||
|
margin-bottom: 2px;
|
||||||
|
font-size: %dpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.email-body {
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-section {
|
||||||
|
margin-top: 15px;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: %s;
|
||||||
|
border: 1px solid %s;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-section h3 {
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
font-size: %dpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-item {
|
||||||
|
padding: 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-icon {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-details, .attachment-type {
|
||||||
|
font-size: %dpx;
|
||||||
|
color: #555555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-inclusion-note, .attachment-info-note {
|
||||||
|
margin-top: 8px;
|
||||||
|
padding: 6px;
|
||||||
|
font-size: %dpx;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-inclusion-note {
|
||||||
|
background-color: #e6ffed;
|
||||||
|
border: 1px solid #d4f7dc;
|
||||||
|
color: #006420;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-info-note {
|
||||||
|
background-color: #fff9e6;
|
||||||
|
border: 1px solid #fff0c2;
|
||||||
|
color: #664d00;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-link-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 8px;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border: 1px solid #dee2e6;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-link-container:hover {
|
||||||
|
background-color: #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachment-note {
|
||||||
|
font-size: %dpx;
|
||||||
|
color: #6c757d;
|
||||||
|
font-style: italic;
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-content {
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
color: #666;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-body {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 100%%;
|
||||||
|
height: auto;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
""",
|
||||||
DEFAULT_FONT_FAMILY,
|
DEFAULT_FONT_FAMILY,
|
||||||
DEFAULT_FONT_SIZE,
|
DEFAULT_FONT_SIZE,
|
||||||
DEFAULT_LINE_HEIGHT,
|
DEFAULT_LINE_HEIGHT,
|
||||||
DEFAULT_TEXT_COLOR,
|
DEFAULT_TEXT_COLOR,
|
||||||
DEFAULT_BACKGROUND_COLOR,
|
DEFAULT_BACKGROUND_COLOR,
|
||||||
DEFAULT_BORDER_COLOR,
|
DEFAULT_BORDER_COLOR,
|
||||||
DEFAULT_FONT_SIZE + 6,
|
DEFAULT_FONT_SIZE + 4,
|
||||||
DEFAULT_FONT_SIZE,
|
DEFAULT_FONT_SIZE - 1,
|
||||||
ATTACHMENT_BACKGROUND_COLOR,
|
ATTACHMENT_BACKGROUND_COLOR,
|
||||||
ATTACHMENT_BORDER_COLOR,
|
ATTACHMENT_BORDER_COLOR,
|
||||||
DEFAULT_FONT_SIZE + 2,
|
DEFAULT_FONT_SIZE + 1,
|
||||||
DEFAULT_FONT_SIZE - 1,
|
DEFAULT_FONT_SIZE - 2,
|
||||||
DEFAULT_FONT_SIZE - 1));
|
DEFAULT_FONT_SIZE - 2,
|
||||||
|
DEFAULT_FONT_SIZE - 3);
|
||||||
|
|
||||||
html.append(loadEmailStyles());
|
html.append(css);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
private static void appendAttachmentsSection(
|
||||||
private String loadEmailStyles() {
|
StringBuilder html,
|
||||||
if (cachedCssContent != null) {
|
EmlParser.EmailContent content,
|
||||||
return cachedCssContent;
|
EmlToPdfRequest request,
|
||||||
}
|
CustomHtmlSanitizer customHtmlSanitizer) {
|
||||||
|
html.append("<div class=\"attachment-section\">\n");
|
||||||
try {
|
|
||||||
ClassPathResource resource = new ClassPathResource(CSS_RESOURCE_PATH);
|
|
||||||
try (InputStream inputStream = resource.getInputStream()) {
|
|
||||||
cachedCssContent = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
|
|
||||||
return cachedCssContent;
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Failed to load email CSS from resource, using fallback: {}", e.getMessage());
|
|
||||||
cachedCssContent = getFallbackStyles(); // Cache fallback to avoid repeated attempts
|
|
||||||
return cachedCssContent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getFallbackStyles() {
|
|
||||||
return """
|
|
||||||
/* Minimal fallback - main CSS resource failed to load */
|
|
||||||
body {
|
|
||||||
font-family: var(--font-family, Helvetica, sans-serif);
|
|
||||||
font-size: var(--font-size, 12px);
|
|
||||||
line-height: var(--line-height, 1.4);
|
|
||||||
color: var(--text-color, #202124);
|
|
||||||
margin: 0;
|
|
||||||
padding: 20px;
|
|
||||||
word-wrap: break-word;
|
|
||||||
}
|
|
||||||
.email-container { max-width: 100%; }
|
|
||||||
.email-header { border-bottom: 1px solid #ccc; margin-bottom: 16px; padding-bottom: 12px; }
|
|
||||||
.email-header h1 { margin: 0 0 8px 0; font-size: 18px; }
|
|
||||||
.email-meta { font-size: 12px; color: #666; }
|
|
||||||
.email-body { line-height: 1.6; }
|
|
||||||
.attachment-section { margin-top: 20px; padding: 12px; background: #f5f5f5; border-radius: 4px; }
|
|
||||||
.attachment-item { padding: 6px 0; border-bottom: 1px solid #ddd; }
|
|
||||||
.no-content { padding: 20px; text-align: center; color: #888; font-style: italic; }
|
|
||||||
img { max-width: 100%; height: auto; }
|
|
||||||
""";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendAttachmentsSection(
|
|
||||||
StringBuilder html, EmlParser.EmailContent content, EmlToPdfRequest request) {
|
|
||||||
html.append(String.format(Locale.ROOT, "<div class=\"attachment-section\">%n"));
|
|
||||||
int displayedAttachmentCount =
|
int displayedAttachmentCount =
|
||||||
content.getAttachmentCount() > 0
|
content.getAttachmentCount() > 0
|
||||||
? content.getAttachmentCount()
|
? content.getAttachmentCount()
|
||||||
: content.getAttachments().size();
|
: content.getAttachments().size();
|
||||||
html.append(
|
html.append("<h3>Attachments (").append(displayedAttachmentCount).append(")</h3>\n");
|
||||||
String.format(
|
|
||||||
Locale.ROOT, "<h3>Attachments (%d)</h3>%n", displayedAttachmentCount));
|
|
||||||
|
|
||||||
if (!content.getAttachments().isEmpty()) {
|
if (!content.getAttachments().isEmpty()) {
|
||||||
for (int i = 0; i < content.getAttachments().size(); i++) {
|
for (int i = 0; i < content.getAttachments().size(); i++) {
|
||||||
@@ -395,14 +406,13 @@ public class EmlProcessingUtils {
|
|||||||
String attachmentId = "attachment_" + i;
|
String attachmentId = "attachment_" + i;
|
||||||
html.append(
|
html.append(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
|
||||||
"""
|
"""
|
||||||
<div class="attachment-item" id="%s">
|
<div class="attachment-item" id="%s">
|
||||||
<span class="attachment-icon" data-filename="%s">@</span>
|
<span class="attachment-icon" data-filename="%s">@</span>
|
||||||
<span class="attachment-name">%s</span>
|
<span class="attachment-name">%s</span>
|
||||||
<span class="attachment-details">(%s%s)</span>
|
<span class="attachment-details">(%s%s)</span>
|
||||||
</div>
|
</div>
|
||||||
""",
|
""",
|
||||||
attachmentId,
|
attachmentId,
|
||||||
escapeHtml(embeddedFilename),
|
escapeHtml(embeddedFilename),
|
||||||
escapeHtml(EmlParser.safeMimeDecode(attachment.getFilename())),
|
escapeHtml(EmlParser.safeMimeDecode(attachment.getFilename())),
|
||||||
@@ -426,10 +436,10 @@ public class EmlProcessingUtils {
|
|||||||
</div>
|
</div>
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
html.append(String.format(Locale.ROOT, "</div>%n"));
|
html.append("</div>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public HTMLToPdfRequest createHtmlRequest(EmlToPdfRequest request) {
|
public static HTMLToPdfRequest createHtmlRequest(EmlToPdfRequest request) {
|
||||||
HTMLToPdfRequest htmlRequest = new HTMLToPdfRequest();
|
HTMLToPdfRequest htmlRequest = new HTMLToPdfRequest();
|
||||||
|
|
||||||
if (request != null) {
|
if (request != null) {
|
||||||
@@ -440,13 +450,13 @@ public class EmlProcessingUtils {
|
|||||||
return htmlRequest;
|
return htmlRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String detectMimeType(String filename, String existingMimeType) {
|
public static String detectMimeType(String filename, String existingMimeType) {
|
||||||
if (existingMimeType != null && !existingMimeType.isEmpty()) {
|
if (existingMimeType != null && !existingMimeType.isEmpty()) {
|
||||||
return existingMimeType;
|
return existingMimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename != null) {
|
if (filename != null) {
|
||||||
String lowerFilename = filename.toLowerCase(Locale.ROOT);
|
String lowerFilename = filename.toLowerCase();
|
||||||
for (Map.Entry<String, String> entry : EXTENSION_TO_MIME_TYPE.entrySet()) {
|
for (Map.Entry<String, String> entry : EXTENSION_TO_MIME_TYPE.entrySet()) {
|
||||||
if (lowerFilename.endsWith(entry.getKey())) {
|
if (lowerFilename.endsWith(entry.getKey())) {
|
||||||
return entry.getValue();
|
return entry.getValue();
|
||||||
@@ -454,10 +464,10 @@ public class EmlProcessingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MediaType.IMAGE_PNG_VALUE; // Default MIME type
|
return "image/png";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String decodeUrlEncoded(String encoded) {
|
public static String decodeUrlEncoded(String encoded) {
|
||||||
try {
|
try {
|
||||||
return java.net.URLDecoder.decode(encoded, StandardCharsets.UTF_8);
|
return java.net.URLDecoder.decode(encoded, StandardCharsets.UTF_8);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -465,7 +475,7 @@ public class EmlProcessingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String decodeMimeHeader(String encodedText) {
|
public static String decodeMimeHeader(String encodedText) {
|
||||||
if (encodedText == null || encodedText.trim().isEmpty()) {
|
if (encodedText == null || encodedText.trim().isEmpty()) {
|
||||||
return encodedText;
|
return encodedText;
|
||||||
}
|
}
|
||||||
@@ -478,13 +488,9 @@ public class EmlProcessingUtils {
|
|||||||
Matcher concatenatedMatcher = concatenatedPattern.matcher(encodedText);
|
Matcher concatenatedMatcher = concatenatedPattern.matcher(encodedText);
|
||||||
String processedText =
|
String processedText =
|
||||||
concatenatedMatcher.replaceAll(
|
concatenatedMatcher.replaceAll(
|
||||||
match ->
|
match -> match.group().replaceAll("\\s+(?==\\?)", ""));
|
||||||
RegexPatternUtils.getInstance()
|
|
||||||
.getMimeHeaderWhitespacePattern()
|
|
||||||
.matcher(match.group())
|
|
||||||
.replaceAll(""));
|
|
||||||
|
|
||||||
Pattern mimePattern = RegexPatternUtils.getInstance().getMimeEncodedWordPattern();
|
Pattern mimePattern = Pattern.compile("=\\?([^?]+)\\?([BbQq])\\?([^?]*)\\?=");
|
||||||
Matcher matcher = mimePattern.matcher(processedText);
|
Matcher matcher = mimePattern.matcher(processedText);
|
||||||
int lastEnd = 0;
|
int lastEnd = 0;
|
||||||
|
|
||||||
@@ -492,18 +498,14 @@ public class EmlProcessingUtils {
|
|||||||
result.append(processedText, lastEnd, matcher.start());
|
result.append(processedText, lastEnd, matcher.start());
|
||||||
|
|
||||||
String charset = matcher.group(1);
|
String charset = matcher.group(1);
|
||||||
String encoding = matcher.group(2).toUpperCase(Locale.ROOT);
|
String encoding = matcher.group(2).toUpperCase();
|
||||||
String encodedValue = matcher.group(3);
|
String encodedValue = matcher.group(3);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String decodedValue =
|
String decodedValue =
|
||||||
switch (encoding) {
|
switch (encoding) {
|
||||||
case "B" -> {
|
case "B" -> {
|
||||||
String cleanBase64 =
|
String cleanBase64 = encodedValue.replaceAll("\\s", "");
|
||||||
RegexPatternUtils.getInstance()
|
|
||||||
.getWhitespacePattern()
|
|
||||||
.matcher(encodedValue)
|
|
||||||
.replaceAll("");
|
|
||||||
byte[] decodedBytes = Base64.getDecoder().decode(cleanBase64);
|
byte[] decodedBytes = Base64.getDecoder().decode(cleanBase64);
|
||||||
Charset targetCharset;
|
Charset targetCharset;
|
||||||
try {
|
try {
|
||||||
@@ -531,7 +533,7 @@ public class EmlProcessingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String decodeQuotedPrintable(String encodedText, String charset) {
|
private static String decodeQuotedPrintable(String encodedText, String charset) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
for (int i = 0; i < encodedText.length(); i++) {
|
for (int i = 0; i < encodedText.length(); i++) {
|
||||||
char c = encodedText.charAt(i);
|
char c = encodedText.charAt(i);
|
||||||
@@ -574,7 +576,7 @@ public class EmlProcessingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String escapeHtml(String text) {
|
public static String escapeHtml(String text) {
|
||||||
if (text == null) return "";
|
if (text == null) return "";
|
||||||
return text.replace("&", "&")
|
return text.replace("&", "&")
|
||||||
.replace("<", "<")
|
.replace("<", "<")
|
||||||
@@ -583,7 +585,7 @@ public class EmlProcessingUtils {
|
|||||||
.replace("'", "'");
|
.replace("'", "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String sanitizeText(String text, CustomHtmlSanitizer customHtmlSanitizer) {
|
public static String sanitizeText(String text, CustomHtmlSanitizer customHtmlSanitizer) {
|
||||||
if (customHtmlSanitizer != null) {
|
if (customHtmlSanitizer != null) {
|
||||||
return customHtmlSanitizer.sanitize(text);
|
return customHtmlSanitizer.sanitize(text);
|
||||||
} else {
|
} else {
|
||||||
@@ -591,17 +593,9 @@ public class EmlProcessingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String simplifyHtmlContent(String htmlContent) {
|
public static String simplifyHtmlContent(String htmlContent) {
|
||||||
String simplified =
|
String simplified = htmlContent.replaceAll("(?i)<script[^>]*>.*?</script>", "");
|
||||||
RegexPatternUtils.getInstance()
|
simplified = simplified.replaceAll("(?i)<style[^>]*>.*?</style>", "");
|
||||||
.getScriptTagPattern()
|
|
||||||
.matcher(htmlContent)
|
|
||||||
.replaceAll("");
|
|
||||||
simplified =
|
|
||||||
RegexPatternUtils.getInstance()
|
|
||||||
.getStyleTagPattern()
|
|
||||||
.matcher(simplified)
|
|
||||||
.replaceAll("");
|
|
||||||
return simplified;
|
return simplified;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user