Skip to content

Commit 6bcac0a

Browse files
committed
Merge branch 'master' of https://github.com/boxwise/dropapp into production
2 parents 87591dc + 3d0c0ea commit 6bcac0a

32 files changed

Lines changed: 572 additions & 263 deletions

.codeql/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: "CodeQL configuration for boxwise/dropapp"
2+
paths-ignore:
3+
- assets/**

.github/workflows/codeql.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: "CodeQL Advanced"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ "master", "production" ]
7+
pull_request:
8+
branches: [ "master", "production" ]
9+
schedule:
10+
- cron: '0 8 * * 1'
11+
12+
jobs:
13+
analyze:
14+
name: Analyze (${{ matrix.language }})
15+
# Runner size impacts CodeQL analysis time. To learn more, please see:
16+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
17+
# - https://gh.io/supported-runners-and-hardware-resources
18+
# - https://gh.io/using-larger-runners (GitHub.com only)
19+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
20+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
21+
permissions:
22+
# required for all workflows
23+
security-events: write
24+
25+
# required to fetch internal or private CodeQL packs
26+
packages: read
27+
28+
# only required for workflows in private repositories
29+
actions: read
30+
contents: read
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
include:
36+
- language: actions
37+
build-mode: none
38+
- language: javascript-typescript
39+
build-mode: none
40+
- language: python
41+
build-mode: none
42+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
43+
# Use `c-cpp` to analyze code written in C, C++ or both
44+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
45+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
46+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
47+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
48+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
49+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@v4
53+
54+
# Add any setup steps before running the `github/codeql-action/init` action.
55+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
56+
# or others). This is typically only required for manual builds.
57+
# - name: Setup runtime (example)
58+
# uses: actions/setup-example@v1
59+
60+
# Initializes the CodeQL tools for scanning.
61+
- name: Initialize CodeQL
62+
uses: github/codeql-action/init@v4
63+
with:
64+
languages: ${{ matrix.language }}
65+
build-mode: ${{ matrix.build-mode }}
66+
config-file: ./.codeql/config.yml
67+
68+
# If the analyze step fails for one of the languages you are analyzing with
69+
# "We were unable to automatically build your code", modify the matrix above
70+
# to set the build mode to "manual" for that language. Then modify this step
71+
# to build your code.
72+
# ℹ️ Command-line programs to run using the OS shell.
73+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
74+
- name: Run manual build steps
75+
if: matrix.build-mode == 'manual'
76+
shell: bash
77+
run: |
78+
echo 'If you are using a "manual" build mode for one or more of the' \
79+
'languages you are analyzing, replace this with the commands to build' \
80+
'your code, for example:'
81+
echo ' make bootstrap'
82+
echo ' make release'
83+
exit 1
84+
85+
- name: Perform CodeQL Analysis
86+
uses: github/codeql-action/analyze@v4
87+
with:
88+
category: "/language:${{matrix.language}}"

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ phpmyadmin/*
1414
node_modules
1515
cypress.env.json
1616
db/queries/*.csv
17-
.php-cs-fixer.cache
17+
.php-cs-fixer.cache
18+
# Cypress test artifacts
19+
cypress/screenshots/
20+
cypress/videos/

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
[![CircleCI](https://circleci.com/gh/boxwise/dropapp.svg?style=svg)](https://circleci.com/gh/boxwise/dropapp)
2-
<a width="105" height="35" href="https://auth0.com/?utm_source=oss&utm_medium=gp&utm_campaign=oss" target="_blank" alt="Single Sign On & Token Based Authentication - Auth0">
3-
<img width="105" height="35" alt="JWT Auth for open source projects" src="https://cdn.auth0.com/oss/badges/a0-badge-dark.png"></a>
1+
[![DPG Badge](https://img.shields.io/badge/Verified-DPG%20(Since%20%202022)-3333AB?logo=data:image/svg%2bxml;base64,PHN2ZyB3aWR0aD0iMzEiIGhlaWdodD0iMzMiIHZpZXdCb3g9IjAgMCAzMSAzMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE0LjIwMDggMjEuMzY3OEwxMC4xNzM2IDE4LjAxMjRMMTEuNTIxOSAxNi40MDAzTDEzLjk5MjggMTguNDU5TDE5LjYyNjkgMTIuMjExMUwyMS4xOTA5IDEzLjYxNkwxNC4yMDA4IDIxLjM2NzhaTTI0LjYyNDEgOS4zNTEyN0wyNC44MDcxIDMuMDcyOTdMMTguODgxIDUuMTg2NjJMMTUuMzMxNCAtMi4zMzA4MmUtMDVMMTEuNzgyMSA1LjE4NjYyTDUuODU2MDEgMy4wNzI5N0w2LjAzOTA2IDkuMzUxMjdMMCAxMS4xMTc3TDMuODQ1MjEgMTYuMDg5NUwwIDIxLjA2MTJMNi4wMzkwNiAyMi44Mjc3TDUuODU2MDEgMjkuMTA2TDExLjc4MjEgMjYuOTkyM0wxNS4zMzE0IDMyLjE3OUwxOC44ODEgMjYuOTkyM0wyNC44MDcxIDI5LjEwNkwyNC42MjQxIDIyLjgyNzdMMzAuNjYzMSAyMS4wNjEyTDI2LjgxNzYgMTYuMDg5NUwzMC42NjMxIDExLjExNzdMMjQuNjI0MSA5LjM1MTI3WiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+Cg==)](https://www.digitalpublicgoods.net/r/boxtribute)
2+
3+
<p><a width="105" height="35" href="https://auth0.com/?utm_source=oss&utm_medium=gp&utm_campaign=oss" target="_blank" alt="Single Sign On & Token Based Authentication - Auth0">
4+
<img width="105" height="35" alt="JWT Auth for open source projects" src="https://cdn.auth0.com/oss/badges/a0-badge-dark.png"></a></p>
5+
6+
Build: [![CircleCI](https://circleci.com/gh/boxwise/dropapp.svg?style=svg)](https://circleci.com/gh/boxwise/dropapp)
47

58
# Readme
69

build/compile-smarty.php

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
// in the templates and on the file system so they will match
1515
// the paths of the target deployment system
1616

17-
// The hash was reverse engineered from smarty_internal_resource_file.php
17+
// v4: The hash was reverse engineered from smarty_internal_resource_file.php
18+
// v5: The hash was reverse engineered from
19+
// v5: vendor/smarty/smarty/src/Resource/FilePlugin.php
20+
// v5: $source->uid = sha1($source->name . $smarty->_joined_template_dir);
1821
$smarty = new Zmarty();
1922
precompileTemplates($smarty);
2023
rewriteAllTemplateHashes($smarty, $deploymentRootFolder);
@@ -28,46 +31,57 @@ function precompileTemplates($smarty)
2831
function rewriteAllTemplateHashes($smarty, $deploymentRootFolder)
2932
{
3033
$rootDir = realpath(__DIR__.'/../');
31-
$originalTemplateDir = $smarty->getTemplateDir()[0];
34+
echo "Original root dir: {$rootDir}\n";
3235
// swap out the root of originalTemplateDir for the new deployment path
33-
$deployedTemplateDir = $deploymentRootFolder.str_replace($rootDir, '', $originalTemplateDir);
34-
echo "Re-mapping templates from '{$originalTemplateDir}' to '{$deployedTemplateDir}'\n";
36+
// v5: _joined_template_dir is all template dirs joined with #
37+
$originalJoinedDir = join('#', $smarty->getTemplateDir());
38+
$deployedJoinedDir = $deploymentRootFolder.str_replace($rootDir, '', $originalJoinedDir);
39+
40+
echo "Re-mapping templates from '{$originalJoinedDir}' to '{$deployedJoinedDir}'\n";
3541

36-
$it = new FilesystemIterator($smarty->getCompileDir());
3742
foreach (glob($smarty->getCompileDir().'*.tpl.php') as $fileName) {
38-
rewriteTemplateHash($smarty, $fileName, $originalTemplateDir, $deployedTemplateDir);
43+
rewriteTemplateHash($fileName, $originalJoinedDir, $deployedJoinedDir);
3944
}
4045
}
4146

42-
function rewriteTemplateHash($smarty, $templateFileName, $originalTemplateDir, $deployedTemplateDir)
47+
function rewriteTemplateHash($templateFileName, $originalJoinedDir, $deployedJoinedDir)
4348
{
4449
// example file name format:
45-
// 5ad5ecef0cb555f346e97a65e3cc109456de7a1a_1.file.mobile_scan.tpl.php
50+
// Smarty 4: 5ad5ecef0cb555f346e97a65e3cc109456de7a1a_1.file.mobile_scan.tpl.php
51+
// Smarty 5: {sha1}_{0|2}.file_{basename}.tpl.php
4652
echo "Processing compiled template {$templateFileName}\n";
47-
$fileNameParts = explode('.', basename($templateFileName));
48-
$originalTemplateHash = $fileNameParts[0];
49-
$originalTemplateName = $fileNameParts[2].'.'.$fileNameParts[3];
50-
$originalTemplatePath = $originalTemplateDir.$originalTemplateName;
53+
$baseName = basename($templateFileName);
54+
55+
// Extract parts: hash_suffix.file_templatename.tpl.php
56+
if (!preg_match('/^([a-f0-9]+)_(\d+)\.file_(.+\.tpl)\.php$/', $baseName, $matches)) {
57+
echo " Skipping - doesn't match expected pattern\n";
58+
return;
59+
}
60+
61+
$originalHash = $matches[1];
62+
$suffix = $matches[2];
63+
$templateName = $matches[3];
64+
5165
// work out what we expect the current hash to be, to ensure it matches
5266
// if not, the algorithm has somehow changed, so we'll abort
53-
$computedHashInput = $originalTemplatePath.$originalTemplateDir;
54-
$computedHash = sha1($computedHashInput);
55-
// the _0/_1/_3 suffix on the first component of the file name appears to
56-
// vary based on Smarty configuration. We just extract it from the existing
57-
// file name to save us working that bit out
58-
$computedHashWithSuffix = $computedHash.'_'.explode('_', $originalTemplateHash)[1];
59-
if ($computedHashWithSuffix != $originalTemplateHash) {
60-
throw new Exception("Failed to anticipate current hash for {$templateFileName}\nHashed input: {$computedHashInput}\nCalculated hash: {$computedHashWithSuffix}\nActual hash: {$originalTemplateHash}");
67+
// Smarty 4 hash: sha1($templatePath . $templateDir)
68+
// Smarty 5 hash: sha1(templateName . joinedTemplateDirs)
69+
$computedHash = sha1($templateName . $originalJoinedDir);
70+
if ($computedHash !== $originalHash) {
71+
throw new Exception("Failed to anticipate current hash for {$templateFileName}\nTemplate: {$templateName}\nJoined dirs: {$originalJoinedDir}\nCalculated hash: {$computedHash}\nActual hash: {$originalHash}");
6172
}
62-
$newTemplatePath = $deployedTemplateDir.$originalTemplateName;
73+
74+
// Calculate new hash for deployment
75+
$newHash = sha1($templateName . $deployedJoinedDir);
6376
// we want to
6477
// (a) replace the old file name and hash within the contents of the file
6578
// with the new hash
66-
// (b) rename the template so it uses the new hash
67-
$newHash = sha1($newTemplatePath.$deployedTemplateDir);
6879
$currentTemplate = file_get_contents($templateFileName);
6980
$newTemplate = str_replace($computedHash, $newHash, $currentTemplate);
70-
$newTemplate = str_replace($originalTemplatePath, $newTemplatePath, $newTemplate);
81+
$rootDir = realpath(__DIR__.'/../');
82+
$deploymentRootFolder = dirname($deployedJoinedDir);
83+
$newTemplate = str_replace($rootDir, $deploymentRootFolder, $newTemplate);
84+
// (b) rename the template so it uses the new hash
7185
$newTemplateCompiledPath = str_replace($computedHash, $newHash, $templateFileName);
7286
echo "Saving new template to {$newTemplateCompiledPath} and deleting the original\n";
7387
file_put_contents($newTemplateCompiledPath, $newTemplate);

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88
"robmorgan/phinx": "^0.14",
99
"google/cloud-storage": "^1.48",
1010
"opencensus/opencensus-exporter-stackdriver": "^0.1.0",
11-
"smarty/smarty": "^4.5.3",
11+
"smarty/smarty": "^5.6.0",
1212
"sendgrid/sendgrid": "^8.1",
1313
"google/cloud-logging": "1.28.*",
1414
"auth0/auth0-php": "^8.0.5",
1515
"opencensus/opencensus": "^0.7.0",
1616
"kriswallsmith/buzz": "^1.2",
1717
"nyholm/psr7": "^1.4",
18-
"endroid/qr-code": "^4.4",
18+
"steampixel/simple-php-router": "^0.7.0",
19+
"guzzlehttp/guzzle": "^7.3",
20+
"endroid/qr-code": "^6.0",
1921
"sentry/sentry": "^4.15",
22+
"php-http/curl-client": "^2.2",
2023
"google/cloud-error-reporting": "^0.22",
2124
"google/cloud-datastore": "^1.32",
2225
"open-telemetry/exporter-otlp": "^1.0",

0 commit comments

Comments
 (0)