File tree 3 files changed +26
-9
lines changed 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change 1
- FROM python:3.12.4-slim
1
+ ARG PYTHON_VERSION=3.12.4-slim
2
+
3
+ FROM python:${PYTHON_VERSION}
2
4
3
- # LABELS
4
5
LABEL maintainer="Iván Alejandro Marugán <hello@ialejandro.rocks>" \
5
- description="Bitbucket Bot for Google Chat" \
6
- version="1.0.0"
6
+ description="Bitbucket Bot for Google Chat"
7
7
8
- # APPLICATION
9
8
COPY app /app
10
9
COPY requirements.txt /requirements.txt
11
10
12
- # INSTALL REQUIREMENTS
13
11
RUN pip install -r /requirements.txt
14
12
15
13
WORKDIR /app
16
14
17
- # RUN APP
18
15
ENTRYPOINT ["gunicorn" , "run:app" ]
Original file line number Diff line number Diff line change
1
+ import html
1
2
import json
2
3
import os
3
4
import requests
5
+
4
6
from flask import Flask , request
5
7
6
8
@@ -188,12 +190,12 @@ def main():
188
190
token = os .environ .get ('TOKEN' )
189
191
190
192
if request .args ['token' ]!= token :
191
- exit ( 1 )
193
+ return "Invalid token" , 403
192
194
193
195
event = request .get_json ()
194
196
195
197
if not event :
196
- return "event empty"
198
+ return "event empty" , 400
197
199
198
200
message = Message (url , event )
199
201
if (event ['eventKey' ] == 'pr:opened' or event ['eventKey' ] == 'pr:merged' or event ['eventKey' ] == 'pr:declined' ):
@@ -208,6 +210,10 @@ def main():
208
210
comment = message .pr_approved (event )
209
211
r = message .send_message (comment )
210
212
213
+ # Mitigate XSS
214
+ if isinstance (r , str ):
215
+ r = html .escape (r )
216
+
211
217
return r
212
218
213
219
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " bitbucket-bot" ,
3
+ "version" : " v1.0.0" ,
4
+ "release" : {
5
+ "branches" : [
6
+ " main"
7
+ ],
8
+ "repositoryUrl" : " https://github.com/devops-ia/bitbucket-bot.git" ,
9
+ "plugins" : [
10
+ " @semantic-release/release-notes-generator" ,
11
+ " @semantic-release/github"
12
+ ]
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments