Skip to content

Commit fc822d0

Browse files
committed
fix: CWE-116 and CWE-79
closes #15
1 parent 8844ac2 commit fc822d0

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ jobs:
4242
with:
4343
dry_run: false
4444
branch: main
45-
tag_format: ${version}
45+
tag_format: v${version}
4646
env:
4747
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
FROM python:3.12.4-slim
1+
ARG PYTHON_VERSION=3.12.4-slim
2+
3+
FROM python:${PYTHON_VERSION}
24

3-
# LABELS
45
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"
77

8-
# APPLICATION
98
COPY app /app
109
COPY requirements.txt /requirements.txt
1110

12-
# INSTALL REQUIREMENTS
1311
RUN pip install -r /requirements.txt
1412

1513
WORKDIR /app
1614

17-
# RUN APP
1815
ENTRYPOINT ["gunicorn", "run:app"]

app/app.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import html
12
import json
23
import os
34
import requests
5+
46
from flask import Flask, request
57

68

@@ -188,12 +190,12 @@ def main():
188190
token = os.environ.get('TOKEN')
189191

190192
if request.args['token']!= token:
191-
exit(1)
193+
return "Invalid token", 403
192194

193195
event = request.get_json()
194196

195197
if not event:
196-
return "event empty"
198+
return "event empty", 400
197199

198200
message = Message(url, event)
199201
if (event['eventKey'] == 'pr:opened' or event['eventKey'] == 'pr:merged' or event['eventKey'] == 'pr:declined'):
@@ -208,7 +210,8 @@ def main():
208210
comment = message.pr_approved(event)
209211
r = message.send_message(comment)
210212

211-
return r
213+
# Mitigate XSS
214+
return html.escape(r)
212215

213216

214217
if __name__ == "__main__":

package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}

0 commit comments

Comments
 (0)