Skip to content

Commit 5c54bb8

Browse files
authored
Merge pull request CactuseSecurity#3610 from CactuseSecurity/develop
merge develop --> main - 3 fixes
2 parents cb81520 + 64a33c6 commit 5c54bb8

File tree

7 files changed

+88
-95
lines changed

7 files changed

+88
-95
lines changed

.github/workflows/auto-sync-develop-to-importer-rework.yml.yml

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,74 @@ name: Sync develop to importer-rework
22

33
on:
44
push:
5-
branches:
6-
- develop
5+
branches: [develop]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
710

811
jobs:
912
sync-branches:
1013
runs-on: ubuntu-latest
1114

1215
steps:
13-
- name: Checkout repo
14-
uses: actions/checkout@v4
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
1519

1620
- name: Set up Git
1721
run: |
1822
git config --global user.name "github-actions[bot]"
1923
git config --global user.email "github-actions[bot]@users.noreply.github.com"
2024
21-
- name: Ensure "automation" label exists (create or update)
25+
- name: Ensure "automation" label exists
2226
run: |
23-
gh label create automation \
27+
gh label create automation \
2428
--color "0e8a16" \
2529
--description "Automatically created for syncing branches" \
2630
--force
2731
env:
28-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2933

30-
- name: Fetch all branches
31-
run: git fetch origin importer-rework
34+
- name: Compute ahead/behind
35+
id: ab
36+
run: |
37+
git fetch origin develop importer-rework
38+
read behind ahead < <(git rev-list --left-right --count origin/importer-rework...origin/develop)
39+
echo "ahead=$ahead" >> $GITHUB_OUTPUT
40+
echo "behind=$behind" >> $GITHUB_OUTPUT
41+
# rev-list separates counts with a TAB. :contentReference[oaicite:2]{index=2}
3242

33-
- name: Check if develop is ahead of importer-rework
34-
id: ahead_check
43+
- name: Push sync branch (mirror develop)
44+
if: steps.ab.outputs.ahead != '0'
3545
run: |
36-
git fetch origin
37-
git rev-list --left-right --count origin/importer-rework...origin/develop > counts.txt
38-
ahead=$(cut -f2 counts.txt)
39-
echo "ahead_count=$ahead" >> $GITHUB_OUTPUT
46+
BR=bot/sync-develop-into-importer-rework
47+
git checkout -B "$BR" origin/develop
48+
git push -f origin "HEAD:$BR"
4049
41-
- name: Check for existing PR
50+
- name: Check for existing PR (sync branch → importer-rework)
4251
id: pr_check
52+
if: steps.ab.outputs.ahead != '0'
4353
run: |
4454
existing_pr=$(gh pr list \
4555
--base importer-rework \
46-
--head develop \
56+
--head bot/sync-develop-into-importer-rework \
4757
--state open \
4858
--json number \
49-
--jq '.[0].number')
50-
59+
--jq '.[0].number // empty')
5160
echo "existing_pr=$existing_pr" >> $GITHUB_OUTPUT
5261
env:
5362
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5463

55-
- name: Create PR from develop to importer-rework
56-
if: steps.ahead_check.outputs.ahead_count != '0' && steps.pr_check.outputs.existing_pr == ''
64+
- name: Create PR from sync branch to importer-rework
65+
if: steps.ab.outputs.ahead != '0' && steps.pr_check.outputs.existing_pr == ''
5766
run: |
5867
gh pr create \
5968
--base importer-rework \
60-
--head develop \
69+
--head bot/sync-develop-into-importer-rework \
6170
--title "Sync develop → importer-rework" \
62-
--body "This PR was auto-created to sync changes from \`develop\` into \`importer-rework\`." \
63-
--label automation \
64-
--repo ${{ github.repository }}
71+
--body "Auto-sync from \`develop\` via sync branch." \
72+
--label automation
6573
env:
6674
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6775

inventory/group_vars/all.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ fworch_db_port: 5432
6868
fworch_db_name: fworchdb
6969
fworch_dbadmin_name: dbadmin
7070
dbadmin_password_file: "{{ fworch_secrets_dir }}/dbadmin_pwd"
71-
fwo_db_ro_user_password_file: "{{ fworch_secrets_dir }}/fwo_db_ro_pwd"
7271
fworch_db_password_file: "{{ fworch_secrets_dir }}/fworch_db_pwd"
7372

7473
###############################################################

roles/database/files/upgrade/8.8.8.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
DO $$
2+
BEGIN
3+
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'fwo_ro') THEN
4+
CREATE ROLE fwo_ro WITH LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE;
5+
END IF;
6+
END
7+
$$;
8+
9+
110
GRANT CONNECT ON DATABASE fworchdb TO fwo_ro;
211

312
GRANT USAGE ON SCHEMA compliance TO fwo_ro;

roles/database/tasks/create-ro-pwd-file.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

roles/database/tasks/create-ro-user.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
# add db ro user and assign privileges
22

3-
- name: create ro db user {{ fwo_db_ro_user }} pwd file
4-
import_tasks: create-ro-pwd-file.yml
5-
when: installation_mode == "new"
6-
73
- block:
84

95
- name: create {{ fwo_db_ro_user }}
106
postgresql_user:
117
name: "{{ fwo_db_ro_user }}"
12-
password: "{{ fwo_db_ro_pwd }}"
138
role_attr_flags: LOGIN,NOSUPERUSER,INHERIT,NOCREATEDB,NOCREATEROLE
149

1510
- name: GRANT ro user

roles/database/tasks/upgrade-database.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,6 @@
3434
- "current_version: {{ current_version }}"
3535
- "all_upgrades_available: {{ all_upgrades_available }}"
3636

37-
- block:
38-
- name: create ro db user {{ fwo_db_ro_user }} pwd file
39-
import_tasks: create-ro-pwd-file.yml
40-
41-
- name: Read fwo_db_ro user password from file
42-
slurp:
43-
src: "{{ fwo_db_ro_user_password_file }}"
44-
register: fwo_db_ro_pwd_base64
45-
become: true
46-
become_user: "{{ fworch_user }}"
47-
48-
- name: decode fwo db ro pwd
49-
set_fact:
50-
fwo_db_ro_pwd: "{{ fwo_db_ro_pwd_base64['content'] | b64decode | trim }}"
51-
52-
- name: Create read-only role safely
53-
shell: |
54-
psql -d "{{ fworch_db_name }}" -c "
55-
DO \$\$
56-
BEGIN
57-
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '{{ fwo_db_ro_user }}') THEN
58-
CREATE ROLE {{ fwo_db_ro_user }} WITH LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE PASSWORD '{{ fwo_db_ro_pwd }}';
59-
END IF;
60-
END
61-
\$\$;"
62-
become: true
63-
become_user: postgres
64-
65-
when: installed_version is version('8.8.8', '<=') and current_version is version ('8.8.8', '>=')
66-
6737
- name: Copy relevant upgrade files
6838
copy:
6939
src: "upgrade/{{ item }}.sql"
@@ -79,5 +49,3 @@
7949
become: true
8050
ignore_errors: false
8151
become_user: postgres
82-
environment:
83-
fwo_db_ro_user_pwd: "{{ fwo_db_ro_pwd }}"

roles/lib/tasks/install_puppeteer.yml

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,56 @@
8383

8484
become: true
8585
environment: "{{ proxy_env }}"
86-
86+
8787
# get google chrome for pdf generation
88-
- name: get last known good versions of chrome to download
89-
uri:
90-
url: https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json
91-
register: chrome_versions
92-
become: false
88+
- block:
89+
- name: get last known good versions (primary)
90+
uri:
91+
url: https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json
92+
return_content: true
93+
register: chrome_versions
94+
become: false
95+
96+
rescue:
97+
- name: fallback - get last known good versions (raw.githubusercontent.com)
98+
uri:
99+
url: https://raw.githubusercontent.com/GoogleChromeLabs/chrome-for-testing/main/data/last-known-good-versions-with-downloads.json
100+
return_content: true
101+
headers:
102+
Accept: application/json
103+
register: chrome_versions
104+
become: false
105+
106+
# Parse once, regardless of Content-Type
107+
- name: normalize/parse JSON response
108+
set_fact:
109+
chrome_versions_parsed: >-
110+
{{
111+
chrome_versions.json
112+
if (chrome_versions.json is defined)
113+
else (chrome_versions.content | trim | from_json)
114+
}}
115+
116+
# Pick the Stable channel (some users accidentally use 'stable', so be flexible)
117+
- name: select Stable channel
118+
set_fact:
119+
cft_stable: "{{ chrome_versions_parsed.channels.Stable | default(chrome_versions_parsed.channels.stable) }}"
93120

121+
# Extract downloads + version from Stable
94122
- name: parse latest stable versions for chrome #and headless shell
95123
set_fact:
96-
stable_chrome_versions: "{{ chrome_versions['json']['channels']['Stable']['downloads'] }}"
97-
chrome_dest: "/usr/local/fworch/bin/Chrome/Linux-{{ chrome_versions['json']['channels']['Stable']['version'] }}"
124+
stable_chrome_versions: "{{ cft_stable.downloads }}"
125+
chrome_dest: "/usr/local/fworch/bin/Chrome/Linux-{{ cft_stable.version }}"
126+
127+
# (Optional) sanity checks to fail early with a clear message
128+
- name: validate parsed data
129+
assert:
130+
that:
131+
- chrome_versions_parsed is mapping
132+
- cft_stable is mapping
133+
- cft_stable.version is defined
134+
- cft_stable.downloads is defined
135+
fail_msg: "Failed to parse Chrome for Testing JSON or locate the Stable channel."
98136

99137
- block:
100138
- name: install unzip

0 commit comments

Comments
 (0)