summaryrefslogtreecommitdiffstats
path: root/266.patch
diff options
context:
space:
mode:
Diffstat (limited to '266.patch')
-rw-r--r--266.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/266.patch b/266.patch
new file mode 100644
index 0000000..3271e39
--- /dev/null
+++ b/266.patch
@@ -0,0 +1,69 @@
+From 1e152059e17a50f95d739cdcf22dc499bb3ec7ad Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Thu, 13 Dec 2018 08:08:55 +0100
+Subject: [PATCH] use php script, get rid of python for test suite
+
+---
+ scripts/upload_validation.php | 45 +++++++++++++++++++++
+ src/tests/config/upload_validation_real.ini | 2 +-
+ 2 files changed, 46 insertions(+), 1 deletion(-)
+ create mode 100755 scripts/upload_validation.php
+
+diff --git a/scripts/upload_validation.php b/scripts/upload_validation.php
+new file mode 100755
+index 0000000..71f83e6
+--- /dev/null
++++ b/scripts/upload_validation.php
+@@ -0,0 +1,45 @@
++#!/usr/bin/env php
++<?php
++
++function check($filename) {
++
++ $whitelist = ['ECHO', 'RETURN', 'PHP', 'NOP'];
++
++ $out = [];
++ $ret = 0;
++ $cmd = [
++ PHP_BINARY,
++ "-d", "vld.active=1",
++ "-d", "vld.execute=0",
++ "-d", "extension=vld.so",
++ "-d", "vld.format=1",
++ "-d", "vld.col_sep=@",
++ "-d", "log_errors=0",
++ "-d", "error_log=/dev/null",
++ $filename,
++ '2>&1',
++ ];
++ exec(implode(' ', $cmd), $out, $ret);
++ if ($ret) {
++ printf("Error: %d\n", $ret);
++ return 2;
++ }
++ foreach($out as $line) {
++ $sp = explode('@', $line);
++ if (count($sp) < 5) {
++ continue;
++ }
++ $opcode = $sp[4]; // # ,line, #, EIO, op, fetch, ext, return, operands
++ if ($opcode && !in_array($opcode, $whitelist)) {
++ printf("Upload_validation: Found an opcode: %s\n", $opcode);
++ return 1;
++ }
++ }
++ return 0;
++}
++
++if ($_SERVER['argc'] != 2) {
++ die("Usage: {$_SERVER['argv']['0']} file_to_test.php\n");
++}
++exit(check($_SERVER['argv']['1']));
++
+diff --git a/src/tests/config/upload_validation_real.ini b/src/tests/config/upload_validation_real.ini
+index 6463466..690e9bf 100644
+--- a/src/tests/config/upload_validation_real.ini
++++ b/src/tests/config/upload_validation_real.ini
+@@ -1 +1 @@
+-sp.upload_validation.script("../scripts/upload_validation.py").enable();
++sp.upload_validation.script("../scripts/upload_validation.php").enable();