5 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ FROM php:7.4.19-fpm-alpine AS base
2
2
3
3
LABEL maintainer="dkl@mozilla.com"
4
4
5
+ # From https://github.com/marco-c/risk-analysis-addon/releases
6
+ ENV RISK_ANALYSIS_VERSION v0.6.0
7
+
5
8
# These are unlikely to change from version to version of the container
6
9
EXPOSE 9000
7
10
EXPOSE 9003
@@ -125,6 +128,15 @@ COPY --chown=app nginx/ nginx/
125
128
RUN chmod +x /app/update_version_json.py /app/entrypoint.sh /app/wait-for-mysql.php \
126
129
&& /app/update_version_json.py
127
130
131
+ RUN { \
132
+ echo '/**' ; \
133
+ echo '* @provides moz-risk-analysis-js' ; \
134
+ echo '* @do-not-minify' ; \
135
+ echo '*/' ; \
136
+ } | tee /app/phabricator/webroot/rsrc/js/MozillaRiskAnalysis.js
137
+ RUN curl -fsSL https://raw.githubusercontent.com/marco-c/risk-analysis-addon/${RISK_ANALYSIS_VERSION}/risk_analysis.js \
138
+ >> /app/phabricator/webroot/rsrc/js/MozillaRiskAnalysis.js
139
+
128
140
FROM base AS production
129
141
130
142
USER root
Original file line number Diff line number Diff line change 7
7
'events.listeners ' => array (
8
8
'LandoLinkEventListener ' ,
9
9
'NewChangesLinkEventListener ' ,
10
+ 'RiskAnalyzerEventListener ' ,
10
11
)
11
12
);
Original file line number Diff line number Diff line change 57
57
'FeedQueryIDConduitAPIMethod ' => 'conduit/FeedQueryIDConduitAPIMethod.php ' ,
58
58
'GroupPhabricatorReviewer ' => 'email/adapter/GroupPhabricatorReviewer.php ' ,
59
59
'LandoLinkEventListener ' => 'lando/events/LandoLinkEventListener.php ' ,
60
+ 'RiskAnalyzerEventListener ' => 'differential/events/RiskAnalyzerEventListener.php ' ,
60
61
'MinimalEmailContext ' => 'email/model/MinimalEmailContext.php ' ,
61
62
'MinimalEmailRevision ' => 'email/model/MinimalEmailRevision.php ' ,
62
63
'MozLogger ' => 'logging/MozLogger.php ' ,
146
147
'FeedQueryIDConduitAPIMethod ' => 'FeedQueryConduitAPIMethod ' ,
147
148
'GroupPhabricatorReviewer ' => 'PhabricatorReviewer ' ,
148
149
'LandoLinkEventListener ' => 'PhabricatorEventListener ' ,
150
+ 'RiskAnalyzerEventListener ' => 'PhabricatorEventListener ' ,
149
151
'MozLogger ' => 'Phobject ' ,
150
152
'MozillaExtraReviewerDataSearchEngineAttachment ' => 'PhabricatorSearchEngineAttachment ' ,
151
153
'MozillaMOTD ' => 'Phobject ' ,
Original file line number Diff line number Diff line change
1
+ <?php
2
+ // This Source Code Form is subject to the terms of the Mozilla Public
3
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+
6
+ /**
7
+ * Adds the "risk analyzer plugin" JS to the differential view
8
+ */
9
+
10
+ final class RiskAnalyzerEventListener extends PhabricatorEventListener {
11
+
12
+ public function register () {
13
+ if (PhabricatorEnv::getEnvConfig ('bugzilla.url ' ) != "http://bmo.test " ) {
14
+ // Only enable this event listener if we're not running in the local development environment
15
+ $ this ->listen (PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES );
16
+ }
17
+ }
18
+
19
+ public function handleEvent (PhutilEvent $ event ) {
20
+ if ($ event ->getType () == PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES ) {
21
+ $ response = CelerityAPI::getStaticResourceResponse ();
22
+ $ response ->requireResource ('moz-risk-analysis-js ' , 'phabricator ' );
23
+ $ response ->addContentSecurityPolicyURI ('connect-src ' , 'https://community-tc.services.mozilla.com ' );
24
+ }
25
+ }
26
+ }
Original file line number Diff line number Diff line change 6
6
server {
7
7
server_name phabricator.test;
8
8
root /app/phabricator/webroot;
9
-
9
+
10
10
location = /contribute.json {
11
11
root /app;
12
12
default_type application/json;
@@ -30,14 +30,14 @@ server {
30
30
31
31
location / {
32
32
add_header X-XSS-Protection "1; mode=block";
33
- add_header Content-Security-Policy "default-src 'self' https://*.cloudfront.net data: 'unsafe-inline'; script-src 'self' https://*.cloudfront.net 'unsafe-inline'; object-src 'self'";
33
+ add_header Content-Security-Policy "default-src 'self' https://*.cloudfront.net data: 'unsafe-inline'; script-src 'self' https://*.cloudfront.net 'unsafe-inline'; object-src 'self'; connect-src 'self' https://community-tc.services.mozilla.com ";
34
34
index index.php;
35
35
rewrite ^/(.*)$ /index.php?__path__=/$1 last;
36
36
}
37
37
38
38
location ~ \.php$ {
39
39
add_header X-XSS-Protection "1; mode=block";
40
- add_header Content-Security-Policy "default-src 'self' https://*.cloudfront.net data: 'unsafe-inline'; script-src 'self' https://*.cloudfront.net 'unsafe-inline'; object-src 'self'";
40
+ add_header Content-Security-Policy "default-src 'self' https://*.cloudfront.net data: 'unsafe-inline'; script-src 'self' https://*.cloudfront.net 'unsafe-inline'; object-src 'self'; connect-src 'self' https://community-tc.services.mozilla.com ";
41
41
include fastcgi_params;
42
42
fastcgi_pass phabricator:9000;
43
43
fastcgi_index index.php;
0 commit comments