Skip to content

Commit

Permalink
disable opcache+#
Browse files Browse the repository at this point in the history
  • Loading branch information
ata-no-one committed Aug 12, 2024
1 parent 8060977 commit 9952bfa
Show file tree
Hide file tree
Showing 8 changed files with 429 additions and 13 deletions.
8 changes: 8 additions & 0 deletions Dockerfile.Nextcloud
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ FROM nextcloud:${NEXTCLOUD_VERSION}
RUN apt update && apt install -y less vim telnet iputils-ping
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN install-php-extensions gd xdebug
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
RUN sed -i 's/max_execution_time = 30/max_execution_time = -1/g' "$PHP_INI_DIR/php.ini"
RUN sed -i 's/max_input_time = 60/max_input_time = -1/g' "$PHP_INI_DIR/php.ini"
RUN sed -i 's/memory_limit = 128M/memory_limit = -1/g' "$PHP_INI_DIR/php.ini"
RUN echo "error_log = /var/www/html/data/php.log" >> "$PHP_INI_DIR/php.ini"

COPY opcache-disabled.ini /usr/local/etc/php/conf.d/opcache-recommended.ini
COPY opcache-blacklist.txt /usr/local/etc/php/conf.d/opcache-blacklist.txt
COPY xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ appstore: build
tar czf $(appstore_package_name).tar.gz \
--transform s/$(app_directory_name)/$(app_real_name)/ \
--exclude-vcs \
--exclude="../$(app_directory_name)/opcache-disabled.ini" \
--exclude="../$(app_directory_name)/opcache-blacklist.txt" \
--exclude="../$(app_directory_name)/artifacts" \
--exclude="../$(app_directory_name)/tmp*" \
--exclude="../$(app_directory_name)/Dockerfile*" \
Expand Down
2 changes: 1 addition & 1 deletion compose-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
args:
- NEXTCLOUD_VERSION=${NEXTCLOUD_VERSION:-29.0.3}
environment:
- XDEBUG_MODE=${XDEBUG_MODE:-develop}
XDEBUG_MODE: ${XDEBUG_MODE:-develop}
ports:
- "80:80"
container_name: nextcloud-container
Expand Down
17 changes: 8 additions & 9 deletions lib/Service/VerdictService.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public static function isFileTooLargeToScan(string $path): bool {
return ($size === false) || $size > self::MAX_FILE_SIZE;
}


/**
* Scans a file for malicious content with G DATA Verdict-as-a-Service and returns the verdict.
* @param string $filePath The local path to the file to scan.
Expand Down Expand Up @@ -229,12 +228,12 @@ public function removeWhitespacesAroundComma(string $s): string {
return trim(preg_replace('/\s*,\s*/', ',', $s));
}

/**
* @param string $authMethod
* @return ClientCredentialsGrantAuthenticator|ResourceOwnerPasswordGrantAuthenticator
* @throws VaasAuthenticationException
*/
public function getAuthenticator(string $authMethod): ClientCredentialsGrantAuthenticator|ResourceOwnerPasswordGrantAuthenticator {
/**
* @param string $authMethod
* @return ClientCredentialsGrantAuthenticator|ResourceOwnerPasswordGrantAuthenticator
* @throws VaasAuthenticationException
*/
public function getAuthenticator(string $authMethod): ClientCredentialsGrantAuthenticator|ResourceOwnerPasswordGrantAuthenticator {
if ($authMethod === 'ResourceOwnerPassword') {
return new ResourceOwnerPasswordGrantAuthenticator(
"nextcloud-customer",
Expand All @@ -249,8 +248,8 @@ public function getAuthenticator(string $authMethod): ClientCredentialsGrantAuth
$this->tokenEndpoint
);
} else {
throw new VaasAuthenticationException("Invalid auth method: " . $authMethod);
}
throw new VaasAuthenticationException("Invalid auth method: " . $authMethod);
}
}

/**
Expand Down
367 changes: 367 additions & 0 deletions opcache-blacklist.txt

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions opcache-disabled.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
opcache.enable=1
opcache.interned_strings_buffer=32
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=60
opcache.jit=1255
opcache.jit_buffer_size=128M
opcache.blacklist_filename=/usr/local/etc/php/conf.d/opcache-blacklist.txt
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "AGPL-3.0-or-later",
"private": true,
"scripts": {
"build": "webpack --node-env production --progress",
"build": "webpack --node-env production",
"dev": "webpack --node-env development --progress",
"watch": "webpack --node-env development --progress --watch",
"serve": "webpack --node-env development serve --progress",
Expand Down
35 changes: 33 additions & 2 deletions tests/bats/functionality-parallel.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,45 @@ setup_file() {
}

@test "test admin eicar Upload" {
RESULT=$(echo $EICAR_STRING | curl --silent -w "%{http_code}" -u admin:admin -T - http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.eicar.com.txt)
EICAR_LENGTH=$(echo $EICAR_STRING | wc -c)
RESULT=$(echo $EICAR_STRING | curl -v -X PUT -d"$EICAR_STRING" -w "%{http_code}" -u admin:admin -T - http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.eicar.com.txt || echo "curl failed")

if [[ "$RESULT" =~ "curl failed" ]]; then
$DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data
$DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data/admin
$DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data/admin/files
$DOCKER_EXEC_WITH_USER -i nextcloud-container cat .htaccess
df -h
free
mpstat
docker stats --no-stream --no-trunc
$DOCKER_EXEC_WITH_USER -i nextcloud-container cat data/nextcloud.log
$DOCKER_EXEC_WITH_USER -i nextcloud-container cat /var/www/html/data/php.log
docker logs nextcloud-container
fi

echo "Actual: $RESULT"
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.eicar.com.txt || echo "file not found"
[[ "$RESULT" =~ "Upload cannot be completed." ]]
}

@test "test admin clean upload" {
RESULT=$(echo $CLEAN_STRING | curl -w "%{http_code}" -u admin:admin -T - http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.clean.txt)
RESULT=$(echo $CLEAN_STRING | curl -w "%{http_code}" -u admin:admin -T - http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.clean.txt || echo "curl failed")

if [[ "$RESULT" =~ "curl failed" ]]; then
$DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data
$DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data/admin
$DOCKER_EXEC_WITH_USER -i nextcloud-container ls -lha data/admin/files
$DOCKER_EXEC_WITH_USER -i nextcloud-container cat .htaccess
df -h
free
mpstat
docker stats --no-stream --no-trunc
$DOCKER_EXEC_WITH_USER -i nextcloud-container cat data/nextcloud.log
$DOCKER_EXEC_WITH_USER -i nextcloud-container cat /var/www/html/data/php.log
docker logs nextcloud-container
fi

echo "Actual: $RESULT"
curl --silent -q -u admin:admin -X DELETE http://127.0.0.1/remote.php/dav/files/admin/functionality-parallel.clean.txt || echo "file not found"
[[ $RESULT -ge 200 && $RESULT -lt 300 ]]
Expand Down

0 comments on commit 9952bfa

Please sign in to comment.