Skip to content
This repository was archived by the owner on Jan 14, 2023. It is now read-only.

Commit f855707

Browse files
committed
Add PHP8 Compatibility
Fix compiler error for compile_ast Make the extension compatible with newer versions of php Convert final steps of docker build into a script Change `whitelist` to `allowed ` Make unit tests compatible with latest version of phpunit Add configuration for app engine project id Update CircleCI configuration Maintain backwards compat. for zval str dtor Make warning/notify tests backwards compatible Prevent seg fault when iterating logpoints in `ast_process` Install gcloud tools for Dockerfile using apt Remove memory leaks when creating debugger ast Update string assertions in phpunit tests Refactor Dockerfile to handle env vars needed for test build Add substitutions to cloudbuild Update php image versions used by cloudbuild Set cloud build timeout to 2100 seconds
1 parent bfc88af commit f855707

32 files changed

+738
-460
lines changed

.circleci/config.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# PHP CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-php/ for more details
4+
#
5+
version: 2.1
6+
jobs:
7+
build:
8+
docker:
9+
- image: google/cloud-sdk
10+
auth:
11+
username: $DOCKERHUB_USER
12+
password: $DOCKERHUB_PASSWORD
13+
14+
steps:
15+
- checkout
16+
- run:
17+
name: "Setup Environment"
18+
command: |
19+
echo 'export APPENGINE_PROJECT_ID="${APPENGINE_PROJECT_ID}"' >> $BASH_ENV
20+
echo 'export GOOGLE_PROJECT_ID="${GOOGLE_PROJECT_ID}"' >> $BASH_ENV
21+
echo 'export GOOGLE_COMPUTE_REGION="${GOOGLE_COMPUTE_REGION}"' >> $BASH_ENV
22+
echo 'export GOOGLE_APPLICATION_CREDENTIALS=`echo ${GOOGLE_CREDENTIALS_BASE64} | base64 -di`' >> $BASH_ENV
23+
apt-get update -y
24+
apt-get -y --only-upgrade install google-cloud-sdk-kubectl-oidc google-cloud-sdk google-cloud-sdk-kpt google-cloud-sdk-cloud-build-local
25+
gcloud --quiet config configurations create ${CLOUDSDK_ACTIVE_CONFIG_NAME}
26+
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
27+
echo $GOOGLE_CREDENTIALS_BASE64 | base64 -di | gcloud auth activate-service-account --key-file=-
28+
gcloud --quiet config set compute/region ${GOOGLE_COMPUTE_REGION}
29+
- run:
30+
name: "Run Tests"
31+
command: ./scripts/run_test_suite.sh

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ tests/**/*.diff
2929
tests/**/*.sh
3030
vendor/
3131
composer.lock
32+
.vscode/c_cpp_properties.json
33+
.vscode/tasks.json
34+
.vscode/settings.json

Dockerfile

+21-8
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,45 @@
1414

1515
ARG BASE_IMAGE
1616
FROM $BASE_IMAGE
17+
ARG GOOGLE_CREDENTIALS_BASE64
18+
ARG CLOUDSDK_ACTIVE_CONFIG_NAME
19+
ARG GOOGLE_PROJECT_ID
20+
ARG PHP_DOCKER_GOOGLE_CREDENTIALS
1721

1822
RUN mkdir -p /build && \
1923
apt-get update -y && \
2024
apt-get install -y -q --no-install-recommends \
25+
apt-transport-https \
2126
build-essential \
27+
ca-certificates \
2228
g++ \
2329
gcc \
30+
gnupg \
2431
libc-dev \
2532
make \
2633
autoconf \
2734
curl \
2835
git-core \
36+
nano \
37+
valgrind \
2938
unzip
3039

40+
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && apt-get update -y && apt-get install google-cloud-sdk -y
41+
3142
COPY . /build/
3243

3344
WORKDIR /build
45+
RUN chmod 0755 /build/build.sh
46+
47+
ENV GOOGLE_CREDENTIALS_BASE64=${GOOGLE_CREDENTIALS_BASE64:-}
48+
ENV CLOUDSDK_ACTIVE_CONFIG_NAME=${CLOUDSDK_ACTIVE_CONFIG_NAME:-default}
49+
ENV GOOGLE_PROJECT_ID=${GOOGLE_PROJECT_ID:-google-cloud}
50+
ENV PHP_DOCKER_GOOGLE_CREDENTIALS=${PHP_DOCKER_GOOGLE_CREDENTIALS:-/build/gcp-creds.json}
51+
ENV GOOGLE_APPLICATION_CREDENTIALS=${PHP_DOCKER_GOOGLE_CREDENTIALS}
52+
RUN /build/scripts/install_test_dependencies.sh
3453

3554
ENV TEST_PHP_ARGS="-q" \
3655
REPORT_EXIT_STATUS=1
3756

38-
RUN phpize && \
39-
./configure --enable-stackdriver-debugger && \
40-
make clean && \
41-
make && \
42-
make test || ((find . -name '*.diff' | xargs cat) && false) && \
43-
make install && \
44-
(composer -V || scripts/install_composer.sh) && \
45-
scripts/run_functional_tests.sh
57+
RUN /build/build.sh
58+
#ENTRYPOINT [ "/bin/bash" ]

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,22 @@ or
183183
ini_set('stackdriver_debugger.max_time', '50');
184184
```
185185

186-
### Whitelisting Function Calls in Conditions and Evaluated Expressions
186+
### Allowing Function Calls in Conditions and Evaluated Expressions
187187

188188
Setting a snapshot or logpoint should not affect the state of any application.
189189
By default, we disallow any unknown function calls that could potentially
190190
modify the state of your application.
191191

192192
You can add additional function calls to this list by setting the ini config
193-
`stackdriver_debugger.function_whitelist`:
193+
`stackdriver_debugger.functions_allowed`:
194194

195195
```
196196
# in php.ini
197-
stackdriver_debugger.function_whitelist="foo,bar,MyClass::function"
197+
stackdriver_debugger.functions_allowed="foo,bar,MyClass::function"
198198
```
199199

200200
```php
201-
ini_set('stackdriver_debugger.function_whitelist', 'foo,bar,MyClass::function');
201+
ini_set('stackdriver_debugger.functions_allowed', 'foo,bar,MyClass::function');
202202
```
203203

204204
Note that all function names specified here must be declared with their full

build.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
if [ -z "${BUILD_DIR}" ]; then
5+
BUILD_DIR='/build'
6+
fi
7+
8+
export BUILD_DIR
9+
export BUILD_LOG_DIR='/build/log'
10+
mkdir -p ${BUILD_DIR} ${BUILD_LOG_DIR}
11+
12+
phpize && \
13+
./configure --enable-stackdriver-debugger && \
14+
make clean && \
15+
make && \
16+
make test || ((find . -name '*.diff' | xargs cat) && false) && \
17+
make install && \
18+
(composer -V || scripts/install_composer.sh) && \
19+
scripts/run_functional_tests.sh

circle.yml

-19
This file was deleted.

cloudbuild.yaml

+156-37
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,157 @@
1-
# This cloudbuild.yaml is used to test the php extension against multiple versions of php
21
steps:
3-
- name: gcr.io/cloud-builders/docker
4-
args: ['build', '--build-arg', 'BASE_IMAGE=php:7.1', '.']
5-
id: php71-nts
6-
- name: gcr.io/cloud-builders/docker
7-
args: ['build', '--build-arg', 'BASE_IMAGE=php:7.1-zts', '.']
8-
id: php71-zts
9-
- name: gcr.io/cloud-builders/docker
10-
args: ['build', '--build-arg', 'BASE_IMAGE=php:7.0', '.']
11-
id: php70-nts
12-
- name: gcr.io/cloud-builders/docker
13-
args: ['build', '--build-arg', 'BASE_IMAGE=php:7.0-zts', '.']
14-
id: php70-zts
15-
- name: gcr.io/cloud-builders/docker
16-
args: ['build', '--build-arg', 'BASE_IMAGE=php:7.2', '.']
17-
id: php72-nts
18-
- name: gcr.io/cloud-builders/docker
19-
args: ['build', '--build-arg', 'BASE_IMAGE=php:7.2-zts', '.']
20-
id: php72-zts
21-
- name: gcr.io/cloud-builders/docker
22-
args: ['build', '--build-arg', 'BASE_IMAGE=gcr.io/google-appengine/php72', '.']
23-
id: php72-gae
24-
- name: gcr.io/cloud-builders/docker
25-
args: ['build', '--build-arg', 'BASE_IMAGE=gcr.io/google-appengine/php71', '.']
26-
id: php71-gae
27-
- name: gcr.io/cloud-builders/docker
28-
args: ['build', '--build-arg', 'BASE_IMAGE=gcr.io/google-appengine/php70', '.']
29-
id: php70-gae
30-
- name: gcr.io/cloud-builders/docker
31-
args: ['build', '--build-arg', 'BASE_IMAGE=gcr.io/php-stackdriver/php71-debug', '.']
32-
id: php71-debug
33-
- name: gcr.io/cloud-builders/docker
34-
args: ['build', '--build-arg', 'BASE_IMAGE=gcr.io/php-stackdriver/php71-32bit', '.']
35-
id: php71-32bit
36-
- name: gcr.io/cloud-builders/docker
37-
args: ['build', '--build-arg', 'BASE_IMAGE=gcr.io/php-stackdriver/php70-32bit', '.']
38-
id: php70-32bit
2+
- name: gcr.io/cloud-builders/docker
3+
args:
4+
- 'build'
5+
- '--build-arg'
6+
- 'BASE_IMAGE=gcr.io/${_APPENGINE_PROJECT_ID}/php80'
7+
- '--build-arg'
8+
- 'GOOGLE_CREDENTIALS_BASE64=${_GOOGLE_CREDENTIALS_BASE64}'
9+
- '--build-arg'
10+
- 'CLOUDSDK_ACTIVE_CONFIG_NAME=${_CLOUDSDK_ACTIVE_CONFIG_NAME}'
11+
- '--build-arg'
12+
- 'GOOGLE_PROJECT_ID=${_GOOGLE_PROJECT_ID}'
13+
- '--build-arg'
14+
- 'PHP_DOCKER_GOOGLE_CREDENTIALS=${_PHP_DOCKER_GOOGLE_CREDENTIALS}'
15+
- '.'
16+
id: php80-gae
17+
- name: gcr.io/cloud-builders/docker
18+
args:
19+
- 'build'
20+
- '--build-arg'
21+
- 'BASE_IMAGE=gcr.io/${_APPENGINE_PROJECT_ID}/php74'
22+
- '--build-arg'
23+
- 'GOOGLE_CREDENTIALS_BASE64=${_GOOGLE_CREDENTIALS_BASE64}'
24+
- '--build-arg'
25+
- 'CLOUDSDK_ACTIVE_CONFIG_NAME=${_CLOUDSDK_ACTIVE_CONFIG_NAME}'
26+
- '--build-arg'
27+
- 'GOOGLE_PROJECT_ID=${_GOOGLE_PROJECT_ID}'
28+
- '--build-arg'
29+
- 'PHP_DOCKER_GOOGLE_CREDENTIALS=${_PHP_DOCKER_GOOGLE_CREDENTIALS}'
30+
- '.'
31+
id: php74-gae
32+
- name: gcr.io/cloud-builders/docker
33+
args:
34+
- 'build'
35+
- '--build-arg'
36+
- 'BASE_IMAGE=gcr.io/${_APPENGINE_PROJECT_ID}/php73'
37+
- '--build-arg'
38+
- 'GOOGLE_CREDENTIALS_BASE64=${_GOOGLE_CREDENTIALS_BASE64}'
39+
- '--build-arg'
40+
- 'CLOUDSDK_ACTIVE_CONFIG_NAME=${_CLOUDSDK_ACTIVE_CONFIG_NAME}'
41+
- '--build-arg'
42+
- 'GOOGLE_PROJECT_ID=${_GOOGLE_PROJECT_ID}'
43+
- '--build-arg'
44+
- 'PHP_DOCKER_GOOGLE_CREDENTIALS=${_PHP_DOCKER_GOOGLE_CREDENTIALS}'
45+
- '.'
46+
id: php73-gae
47+
- name: gcr.io/cloud-builders/docker
48+
args:
49+
- 'build'
50+
- '--build-arg'
51+
- 'BASE_IMAGE=php:8.0'
52+
- '--build-arg'
53+
- 'GOOGLE_CREDENTIALS_BASE64=${_GOOGLE_CREDENTIALS_BASE64}'
54+
- '--build-arg'
55+
- 'CLOUDSDK_ACTIVE_CONFIG_NAME=${_CLOUDSDK_ACTIVE_CONFIG_NAME}'
56+
- '--build-arg'
57+
- 'GOOGLE_PROJECT_ID=${_GOOGLE_PROJECT_ID}'
58+
- '--build-arg'
59+
- 'PHP_DOCKER_GOOGLE_CREDENTIALS=${_PHP_DOCKER_GOOGLE_CREDENTIALS}'
60+
- '.'
61+
id: php80-nts
62+
- name: gcr.io/cloud-builders/docker
63+
args:
64+
- 'build'
65+
- '--build-arg'
66+
- 'BASE_IMAGE=php:8.0-zts'
67+
- '--build-arg'
68+
- 'GOOGLE_CREDENTIALS_BASE64=${_GOOGLE_CREDENTIALS_BASE64}'
69+
- '--build-arg'
70+
- 'CLOUDSDK_ACTIVE_CONFIG_NAME=${_CLOUDSDK_ACTIVE_CONFIG_NAME}'
71+
- '--build-arg'
72+
- 'GOOGLE_PROJECT_ID=${_GOOGLE_PROJECT_ID}'
73+
- '--build-arg'
74+
- 'PHP_DOCKER_GOOGLE_CREDENTIALS=${_PHP_DOCKER_GOOGLE_CREDENTIALS}'
75+
- '.'
76+
id: php80-zts
77+
- name: gcr.io/cloud-builders/docker
78+
args:
79+
- 'build'
80+
- '--build-arg'
81+
- 'BASE_IMAGE=php:7.4'
82+
- '--build-arg'
83+
- 'GOOGLE_CREDENTIALS_BASE64=${_GOOGLE_CREDENTIALS_BASE64}'
84+
- '--build-arg'
85+
- 'CLOUDSDK_ACTIVE_CONFIG_NAME=${_CLOUDSDK_ACTIVE_CONFIG_NAME}'
86+
- '--build-arg'
87+
- 'GOOGLE_PROJECT_ID=${_GOOGLE_PROJECT_ID}'
88+
- '--build-arg'
89+
- 'PHP_DOCKER_GOOGLE_CREDENTIALS=${_PHP_DOCKER_GOOGLE_CREDENTIALS}'
90+
- '.'
91+
id: php74-nts
92+
- name: gcr.io/cloud-builders/docker
93+
args:
94+
- 'build'
95+
- '--build-arg'
96+
- 'BASE_IMAGE=php:7.4-zts'
97+
- '--build-arg'
98+
- 'GOOGLE_CREDENTIALS_BASE64=${_GOOGLE_CREDENTIALS_BASE64}'
99+
- '--build-arg'
100+
- 'CLOUDSDK_ACTIVE_CONFIG_NAME=${_CLOUDSDK_ACTIVE_CONFIG_NAME}'
101+
- '--build-arg'
102+
- 'GOOGLE_PROJECT_ID=${_GOOGLE_PROJECT_ID}'
103+
- '--build-arg'
104+
- 'PHP_DOCKER_GOOGLE_CREDENTIALS=${_PHP_DOCKER_GOOGLE_CREDENTIALS}'
105+
- '.'
106+
id: php74-zts
107+
- name: gcr.io/cloud-builders/docker
108+
args:
109+
- 'build'
110+
- '--build-arg'
111+
- 'BASE_IMAGE=php:7.3'
112+
- '--build-arg'
113+
- 'GOOGLE_CREDENTIALS_BASE64=${_GOOGLE_CREDENTIALS_BASE64}'
114+
- '--build-arg'
115+
- 'CLOUDSDK_ACTIVE_CONFIG_NAME=${_CLOUDSDK_ACTIVE_CONFIG_NAME}'
116+
- '--build-arg'
117+
- 'GOOGLE_PROJECT_ID=${_GOOGLE_PROJECT_ID}'
118+
- '--build-arg'
119+
- 'PHP_DOCKER_GOOGLE_CREDENTIALS=${_PHP_DOCKER_GOOGLE_CREDENTIALS}'
120+
- '.'
121+
id: php73-nts
122+
- name: gcr.io/cloud-builders/docker
123+
args:
124+
- 'build'
125+
- '--build-arg'
126+
- 'BASE_IMAGE=php:7.3-zts'
127+
- '--build-arg'
128+
- 'GOOGLE_CREDENTIALS_BASE64=${_GOOGLE_CREDENTIALS_BASE64}'
129+
- '--build-arg'
130+
- 'CLOUDSDK_ACTIVE_CONFIG_NAME=${_CLOUDSDK_ACTIVE_CONFIG_NAME}'
131+
- '--build-arg'
132+
- 'GOOGLE_PROJECT_ID=${_GOOGLE_PROJECT_ID}'
133+
- '--build-arg'
134+
- 'PHP_DOCKER_GOOGLE_CREDENTIALS=${_PHP_DOCKER_GOOGLE_CREDENTIALS}'
135+
- '.'
136+
id: php73-zts
137+
- name: gcr.io/cloud-builders/docker
138+
args:
139+
- 'build'
140+
- '--build-arg'
141+
- 'BASE_IMAGE=gcr.io/php-stackdriver/php71-debug'
142+
- '--build-arg'
143+
- 'GOOGLE_CREDENTIALS_BASE64=${_GOOGLE_CREDENTIALS_BASE64}'
144+
- '--build-arg'
145+
- 'CLOUDSDK_ACTIVE_CONFIG_NAME=${_CLOUDSDK_ACTIVE_CONFIG_NAME}'
146+
- '--build-arg'
147+
- 'GOOGLE_PROJECT_ID=${_GOOGLE_PROJECT_ID}'
148+
- '--build-arg'
149+
- 'PHP_DOCKER_GOOGLE_CREDENTIALS=${_PHP_DOCKER_GOOGLE_CREDENTIALS}'
150+
- '.'
151+
id: php71-debug
152+
timeout: 2100s
153+
substitutions:
154+
_PHP_DOCKER_GOOGLE_CREDENTIALS: /build/gcp-creds.json
155+
_APPENGINE_PROJECT_ID: google-appengine
156+
_CLOUDSDK_ACTIVE_CONFIG_NAME: default
157+
_GOOGLE_PROJECT_ID: $PROJECT_ID

docs/design.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Validation will happen in 2 places.
240240
#### Disallowing Function Calls in Conditions and Expressions
241241

242242
We will disallow all function calls except those that are explicitly marked as
243-
safe. We maintain a list of build-in functions that are whitelisted. We also
243+
safe. We maintain a list of build-in functions that are allowed. We also
244244
provide a `php.ini` setting that allows you to specify your own list of allowed
245245
function calls.
246246

php_stackdriver_debugger.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
#include "php.h"
2525
#include "stackdriver_debugger.h"
2626

27-
#define PHP_STACKDRIVER_DEBUGGER_VERSION "0.2.0"
27+
#define PHP_STACKDRIVER_DEBUGGER_VERSION "0.3.0"
2828
#define PHP_STACKDRIVER_DEBUGGER_EXTNAME "stackdriver_debugger"
29-
#define PHP_STACKDRIVER_DEBUGGER_INI_WHITELISTED_FUNCTIONS "stackdriver_debugger.function_whitelist"
29+
#define PHP_STACKDRIVER_DEBUGGER_INI_ALLOWED_FUNCTIONS "stackdriver_debugger.functions_allowed"
3030
#define PHP_STACKDRIVER_DEBUGGER_INI_MAX_TIME "stackdriver_debugger.max_time"
3131
#define PHP_STACKDRIVER_DEBUGGER_INI_MAX_TIME_PERCENTAGE "stackdriver_debugger.max_time_percentage"
3232
#define PHP_STACKDRIVER_DEBUGGER_INI_MAX_MEMORY "stackdriver_debugger.max_memory"
@@ -43,7 +43,7 @@ PHP_RSHUTDOWN_FUNCTION(stackdriver_debugger);
4343

4444
ZEND_BEGIN_MODULE_GLOBALS(stackdriver_debugger)
4545
/* map of function name -> empty null zval */
46-
HashTable *user_whitelisted_functions;
46+
HashTable *user_allowed_functions;
4747

4848
/* map of filename -> stackdriver_debugger_snapshot[] */
4949
HashTable *snapshots_by_file;

0 commit comments

Comments
 (0)