Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.data
.idea
11 changes: 11 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Block direct web access to sensitive files that must remain on disk.
# Returns 404 to avoid revealing file existence.
Redirect 404 /config.php
Redirect 404 /config-dist.php
Redirect 404 /install.php
Redirect 404 /brokenfile.php
Redirect 404 /register-redis-cache-store.php
Redirect 404 /version.php

# Block db/install.xml across all plugin paths.
RedirectMatch 404 /install\.xml$
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ RUN set -eux; \
# lockstep with whatever lands on ubc/moodle:ltic-v4.5.11 without having to
# enumerate which files changed.
ARG MOODLE_LTIC_REF=ltic-v4.5.11
COPY delete-dev-files.sh /tmp/delete-dev-files.sh
RUN set -eux; \
curl -fL "https://github.com/ubc/moodle/archive/${MOODLE_LTIC_REF}.tar.gz" \
| tar xz --strip=1 -C /var/www/html; \
chown -R www-data:www-data /var/www/html
bash /tmp/delete-dev-files.sh; \
Comment thread
gondek marked this conversation as resolved.
rm /tmp/delete-dev-files.sh; \
chown -R www-data:www-data /var/www/html; \
chmod 444 /var/www/html/config.php # Addresses "Writable config.php" moodle warning

# Fetching and unzipping all plugins
COPY plugins/ /plugins/
Expand Down Expand Up @@ -121,6 +125,8 @@ RUN set -eux; \
done; \
rm -rf /plugins

COPY --chown=www-data:www-data .htaccess /var/www/html/.htaccess

COPY kalturapatch.sh /tmp/
RUN sh /tmp/kalturapatch.sh && rm /tmp/kalturapatch.sh

Expand Down
67 changes: 67 additions & 0 deletions delete-dev-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# Remove paths from the Moodle release after extraction.
# Paths are relative to /var/www/html. Both files and directories are accepted.
set -euo pipefail

BASE=/var/www/html

# Exact paths (relative to $BASE) to remove.
REMOVE=(
"check_lang_sort.sh"
"admin/environment.xml"
"composer.json"
"composer.lock"
"package.json"
"npm-shrinkwrap.json"
"Gruntfile.js"
"behat.yml.dist"
"phpcs.xml.dist"
"phpunit.xml.dist"
"CONTRIBUTING.md"
"COPYING.txt"
"INSTALL.txt"
"PATCH_UPGRADE_NOTES.md"
"TRADEMARK.txt"
"UPGRADING.md"
"security.txt"
".eslintrc"
".gherkin-lintrc"
".gitattributes"
".github"
".gitignore"
".grunt"
".jshintignore"
".jshintrc"
".nvmrc"
".phpstorm.meta.php"
".shifter.json"
".stylelintrc"
".upgradenotes"
)

# Case-insensitive exact filenames matched recursively across the entire tree.
PATTERNS=(
"readme"
"readme.md"
"readme.txt"
"readme_moodle.txt"
"readme.rst"
"readme.html"
"upgrade.txt"
"upgrading.md"
"upgrading-current.md"
)

for entry in "${REMOVE[@]}"; do
target="${BASE}/${entry}"
if [[ -e "$target" || -L "$target" ]]; then
echo "Removing: $target"
rm -rf "$target"
else
echo "Not found (skipping): $target"
fi
done

for pattern in "${PATTERNS[@]}"; do
find "$BASE" -depth -iname "$pattern" -printf "Removing: %p\n" -exec rm -rf {} +
done
Loading