Skip to content

Commit 24bae5d

Browse files
committed
Should address issue of security preventions to allow features to work again
1 parent 7ab046e commit 24bae5d

File tree

19 files changed

+249
-654
lines changed

19 files changed

+249
-654
lines changed

.githooks/pre-commit

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
# exit with non-zero status after issuing an appropriate message if
66
# it wants to stop the commit.
77
#
8-
# To enable this hook, rename this file to "pre-commit" within .git\hooks
9-
# or run git config core.hooksPath .githooks
8+
# To enable this hook, rename this file to "pre-commit".
109
#
1110
# Exit on error
12-
#set -e
11+
# set -e
1312

1413
project_dir=$(git rev-parse --show-toplevel)
1514

15+
psrfix() {
16+
command -v php-cs-fixer >/dev/null || return
17+
$(command -v php-cs-fixer) fix $project_dir/packages/web --rules=@PSR2
18+
git add $project_dir/packages/web
19+
}
20+
1621
updateLanguage() {
1722
command -v xgettext >/dev/null || return
1823
command -v msgcat >/dev/null || return
@@ -23,10 +28,10 @@ updateLanguage() {
2328
msgmerge --update --backup=none $PO_FILE $project_dir/packages/web/management/languages/messages.pot 2>/dev/null >/dev/null
2429
msgcat --sort-output -o $PO_FILE $PO_FILE
2530
done
26-
git add "$project_dir/packages/web/management/languages"
2731
}
2832

2933
updateLanguage
34+
#psrfix
3035

3136
# Get the current branch name
3237
gitbranch=$(git branch --show-current)
@@ -44,7 +49,7 @@ branchon=$(echo ${gitbranch} | awk -F'-' '{print $1}')
4449
branchend=$(echo ${gitbranch} | awk -F'-' '{print $2}')
4550

4651
# Define the path to the system file
47-
system_file="$(git rev-parse --show-toplevel)/packages/web/lib/fog/system.class.php"
52+
system_file="$project_dir/packages/web/lib/fog/system.class.php"
4853

4954
current_version=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/")
5055

@@ -61,12 +66,12 @@ case $branchon in
6166
channel="Patches"
6267
;;
6368
stable)
64-
# For stable, don't increment version, use what is being pulled from dev-branch
69+
# Describe the tag and append the commit count correctly
6570
tagversion=$(git describe --tags ${gitcom})
6671
baseversion=${tagversion%.*} # Retain everything before the last segment
6772
lastrevision=${tagversion##*.} # Extracts the last segment
68-
gitcount=$(git rev-list master..dev-branch --count) #get the gitcount from dev-branch instead
6973
trunkversion="${baseversion}.${gitcount}"
74+
gitcount=$(git rev-list master..dev-branch --count) # Get the gitcount from dev-branch instead
7075
channel="Patches"
7176
;;
7277
working)
@@ -78,7 +83,7 @@ case $branchon in
7883
rc)
7984
channel="Release Candidate"
8085
version_prefix="${branchend}.0-RC"
81-
if [[ $current_version =~ $version_prefix-([0-9]+) ]]; then
86+
if [[ $current_version =~ "${version_prefix}-([0-9]+)" ]]; then
8287
last_rc_version=${BASH_REMATCH[1]}
8388
next_rc_version=$((last_rc_version + 1))
8489
else

packages/web/commons/base.inc.php

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
<?php
2-
/**
3-
* Base that commonizes the requirements of FOG.
4-
*
5-
* PHP version 5
6-
*
7-
* @category Base
8-
* @package FOGProject
9-
* @author Tom Elliott <[email protected]>
10-
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
11-
* @link https://fogproject.org
12-
*/
2+
declare(strict_types=1);
3+
134
/**
145
* Base that commonizes the requirements of FOG.
156
*
@@ -19,30 +10,29 @@
1910
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
2011
* @link https://fogproject.org
2112
*/
22-
/**
23-
* Setup our more secure friendly header information.
24-
*/
13+
14+
if (!function_exists('str_contains')) {
15+
function str_contains($haystack, $needle)
16+
{
17+
return $needle !== '' && strpos($haystack, $needle) !== false;
18+
}
19+
}
20+
21+
// Set security-related headers.
2522
header('X-Frame-Options: sameorigin');
2623
header('X-XSS-Protection: 1; mode=block');
2724
header('X-Content-Type-Options: nosniff');
2825
header('Strict-Transport-Security: max-age=31536000');
29-
header(
30-
"Content-Security-Policy: default-src 'none';"
31-
. "script-src 'self' 'unsafe-eval';"
32-
. "connect-src 'self';"
33-
. "img-src 'self' data:;"
34-
. "style-src 'self' 'unsafe-inline';"
35-
. "font-src 'self';"
36-
);
37-
/**
38-
* Our required files, text for language and init to initialize system.
39-
*/
26+
header("Content-Security-Policy: default-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; connect-src 'self' https://fogproject.org; img-src 'self' data:; style-src 'self' 'unsafe-inline'; font-src 'self' data:;");
27+
28+
// Include required initialization script.
4029
require 'init.php';
41-
/**
42-
* All output should be sanitized for faster browser experience.
43-
*/
44-
ob_start(array('Initiator', 'sanitizeOutput'));
30+
31+
// Output buffering with custom output sanitization for performance and security.
32+
ob_start(['Initiator', 'sanitizeOutput']);
4533
Initiator::sanitizeItems();
4634
Initiator::startInit();
35+
36+
// Load global constants and functions.
4737
require BASEPATH . "commons/text.php";
4838
new LoadGlobals();

0 commit comments

Comments
 (0)