Skip to content

Commit 9841265

Browse files
Merge remote-tracking branch 'origin/develop' into pr-54
# Conflicts: # .github/workflows/plugin-ci-workflow.yml # .gitignore # audit.php # audit_functions.php # setup.php
2 parents 853bc20 + 1d7be4f commit 9841265

51 files changed

Lines changed: 7734 additions & 333 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.php]
10+
indent_style = tab
11+
indent_size = 4
12+
13+
[*.{js,sh}]
14+
indent_style = tab
15+
indent_size = 4
16+
17+
[*.{po,pot,mo}]
18+
binary = true
19+
20+
[*.md]
21+
trim_trailing_whitespace = false

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
target-branch: develop
6+
schedule: {interval: weekly, day: friday}
7+
open-pull-requests-limit: 5
8+
cooldown: {default-days: 7}
9+
groups:
10+
github-actions: {patterns: ["*"]}
11+
labels: [dependencies, github-actions]
12+
commit-message: {prefix: ci, include: scope}

.github/workflows/code-quality.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# +-------------------------------------------------------------------------+
2+
# | Copyright (C) 2004-2026 The Cacti Group |
3+
# | |
4+
# | This program is free software; you can redistribute it and/or |
5+
# | modify it under the terms of the GNU General Public License |
6+
# | as published by the Free Software Foundation; either version 2 |
7+
# | of the License, or (at your option) any later version. |
8+
# | |
9+
# | This program is distributed in the hope that it will be useful, |
10+
# | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11+
# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12+
# | GNU General Public License for more details. |
13+
# +-------------------------------------------------------------------------+
14+
# | Cacti: The Complete RRDtool-based Graphing Solution |
15+
# +-------------------------------------------------------------------------+
16+
# | This code is designed, written, and maintained by the Cacti Group. See |
17+
# | about.php and/or the AUTHORS file for specific developer information. |
18+
# +-------------------------------------------------------------------------+
19+
# | http://www.cacti.net/ |
20+
# +-------------------------------------------------------------------------+
21+
22+
name: Code Quality
23+
24+
on:
25+
push:
26+
branches:
27+
- main
28+
- develop
29+
pull_request:
30+
branches:
31+
- main
32+
- develop
33+
34+
jobs:
35+
code-quality:
36+
runs-on: ubuntu-latest
37+
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
php: ['8.1', '8.2', '8.3', '8.4']
42+
43+
name: PHP ${{ matrix.php }} Code Quality
44+
45+
steps:
46+
- name: Checkout Cacti
47+
uses: actions/checkout@v4
48+
with:
49+
repository: Cacti/cacti
50+
ref: develop
51+
path: cacti
52+
53+
- name: Checkout audit Plugin
54+
uses: actions/checkout@v4
55+
with:
56+
path: cacti/plugins/audit
57+
58+
- name: Install PHP ${{ matrix.php }}
59+
uses: shivammathur/setup-php@v2
60+
with:
61+
php-version: ${{ matrix.php }}
62+
extensions: intl, mysql, gd, ldap, gmp, mbstring, dom, xml, json, sockets
63+
coverage: none
64+
ini-values: "memory_limit=512M"
65+
66+
- name: Check PHP version
67+
run: php -v
68+
69+
- name: Validate Cacti Composer files
70+
run: composer validate --strict
71+
working-directory: cacti
72+
73+
- name: Install Cacti development dependencies
74+
run: composer install --prefer-dist --no-progress
75+
working-directory: cacti
76+
77+
- name: Lint audit Plugin
78+
run: include/vendor/bin/phplint --no-cache --exclude=locales plugins/audit
79+
working-directory: cacti
80+
81+
- name: Run PHP-CS-Fixer (dry-run)
82+
run: include/vendor/bin/php-cs-fixer fix --dry-run --diff --config=plugins/audit/.php-cs-fixer.php --allow-unsupported-php-version=yes
83+
working-directory: cacti
84+
85+
- name: Run PHPStan
86+
run: include/vendor/bin/phpstan analyse --configuration=plugins/audit/.phpstan.neon --memory-limit=512M --no-progress
87+
working-directory: cacti
88+
89+
- name: Run Pest Tests
90+
if: ${{ matrix.php != '8.1' }}
91+
run: include/vendor/bin/pest plugins/audit/tests/Security --display-warnings
92+
working-directory: cacti
93+
94+
- name: Run Audit Security Helper Tests
95+
run: |
96+
php tests/security_functions_test.php
97+
php tests/controller_security_test.php
98+
php tests/syslog_queue_test.php
99+
timeout 60 php tests/syslog_functions_test.php
100+
working-directory: cacti/plugins/audit

.github/workflows/plugin-ci-workflow.yml

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
strategy:
3939
fail-fast: false
4040
matrix:
41-
php: ['8.1', '8.2', '8.3']
41+
php: ['8.4']
4242
os: [ubuntu-latest]
4343

4444
services:
@@ -61,13 +61,14 @@ jobs:
6161

6262
steps:
6363
- name: Checkout Cacti
64-
uses: actions/checkout@v4
64+
uses: actions/checkout@v7
6565
with:
6666
repository: Cacti/cacti
67+
ref: 1.2.x
6768
path: cacti
6869

6970
- name: Checkout audit Plugin
70-
uses: actions/checkout@v4
71+
uses: actions/checkout@v7
7172
with:
7273
path: cacti/plugins/audit
7374

@@ -81,7 +82,6 @@ jobs:
8182
- name: Check PHP version
8283
run: php -v
8384

84-
8585
- name: Run apt-get update
8686
run: sudo apt-get update
8787

@@ -141,8 +141,6 @@ jobs:
141141
sed -r "s/'cactiuser'/'cactiuser'/g" > ${{ github.workspace }}/cacti/include/config.php
142142
sudo chmod 664 ${{ github.workspace }}/cacti/include/config.php
143143
144-
145-
146144
- name: Configure Apache
147145
run: |
148146
cat << 'EOF' | sed 's#GITHUB_WORKSPACE#${{ github.workspace }}#g' > /tmp/cacti.conf
@@ -172,6 +170,31 @@ jobs:
172170
run: |
173171
cd ${{ github.workspace }}/cacti
174172
sudo php cli/plugin_manage.php --plugin=audit --install --enable
173+
174+
- name: Verify Audit Schema
175+
run: |
176+
COLUMN_COUNT=$(mysql -u cactiuser -p'cactiuser' -h 127.0.0.1 cacti -se "
177+
SELECT COUNT(*)
178+
FROM information_schema.columns
179+
WHERE table_schema = 'cacti'
180+
AND table_name = 'audit_log'
181+
AND column_name IN ('request_status', 'external_status', 'external_error');
182+
")
183+
if [ "$COLUMN_COUNT" -ne 3 ]; then
184+
echo "Audit schema security columns are missing"
185+
exit 1
186+
fi
187+
188+
SYSLOG_TABLE_COUNT=$(mysql -u cactiuser -p'cactiuser' -h 127.0.0.1 cacti -se "
189+
SELECT COUNT(*)
190+
FROM information_schema.tables
191+
WHERE table_schema = 'cacti'
192+
AND table_name = 'audit_syslog_delivery';
193+
")
194+
if [ "$SYSLOG_TABLE_COUNT" -ne 1 ]; then
195+
echo "Audit Syslog delivery queue table is missing"
196+
exit 1
197+
fi
175198
176199
- name: Check PHP Syntax for Plugin
177200
run: |
@@ -180,7 +203,14 @@ jobs:
180203
echo "Syntax errors found!"
181204
exit 1
182205
fi
183-
206+
207+
- name: Run Audit Security Helper Tests
208+
run: |
209+
cd ${{ github.workspace }}/cacti/plugins/audit
210+
php tests/security_functions_test.php
211+
php tests/controller_security_test.php
212+
php tests/syslog_functions_test.php
213+
php tests/syslog_queue_test.php
184214
185215
- name: Run Cacti Poller
186216
run: |
@@ -192,7 +222,6 @@ jobs:
192222
exit 1
193223
fi
194224
195-
196225
- name: View Cacti Logs
197226
if: always()
198227
run: |
@@ -222,3 +251,8 @@ jobs:
222251
exit 1
223252
fi
224253
254+
CLI_STATUS=$(mysql -u cactiuser -p'cactiuser' -h 127.0.0.1 cacti -se "select request_status from audit_log where action = 'cli' order by id desc limit 1;")
255+
if [ "$CLI_STATUS" != "completed" ]; then
256+
echo "Unexpected CLI request status: $CLI_STATUS"
257+
exit 1
258+
fi

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,13 @@
2222

2323

2424
locales/po/*.mo
25-
.omc/
25+
26+
# PHPStan
27+
phpstan.cache/
28+
.phpstan-baseline.neon.local
29+
30+
# PHP-CS-Fixer
31+
.php-cs-fixer.cache
32+
33+
# Pest / PHPUnit
34+
.phpunit.result.cache

0 commit comments

Comments
 (0)