Skip to content

Commit ac5666a

Browse files
committed
slimmed docker image, fixed some LGTM alerts
1 parent e91a2bc commit ac5666a

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__pycache__/
2+
venv/
3+
*.pyc
4+
.vscode/
5+
*.db
6+
.idea/

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ RUN export DATABASE_URL="postgres://${DB_USER}:${DB_PASSWORD}@postgres:${DB_PORT
77
&& export REDIS_URL="redis://redis:6379/0"
88

99
# update and install packages
10-
RUN apk update \
11-
&& apk add libpq postgresql-dev \
12-
&& apk add build-base \
13-
&& apk add --no-cache git libssl1.1 g++ make libffi-dev
10+
RUN apk update --no-cache \
11+
&& apk add --no-cache postgresql-dev build-base g++ libffi-dev
1412

1513
# Add a new low-privileged user
1614
RUN adduser --shell /sbin/login www-data -DH

docker-compose-for-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
- DB_PASSWORD=eshaan
1515
- DB_NAME=rtbctf
1616
- DB_PORT=5432
17-
- WORKERS=8
17+
- WORKERS=4
1818
- ADMIN_PASS=admin
1919
depends_on:
2020
- postgres

src/FlaskRTBCTF/main/forms.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class SettingsForm(FlaskForm):
2626
@admin_only
2727
def setup(self):
2828
if self.is_submitted():
29+
step = 3
2930
try:
3031
settings = Settings.query.get(1)
3132

@@ -41,16 +42,19 @@ def setup(self):
4142

4243
cache.delete(key="past_running_time")
4344
cache.delete(key="settings")
44-
return redirect(url_for("main.setup", step=3))
45+
step = 3
4546

4647
except SQLAlchemyError:
4748
db.session.rollback()
4849
flash("Transaction failed. Please try again.", "danger")
49-
return redirect(url_for("main.setup"), step=2)
50+
step = 2
5051

5152
else:
5253
flash("Form validation failed. Please try again.", "danger")
53-
return redirect(url_for("main.setup", step=2))
54+
step = 2
55+
56+
return redirect(url_for("main.setup"), step=step)
57+
# lgtm [py/call/wrong-named-argument]
5458

5559

5660
class WebsiteForm(FlaskForm):
@@ -86,8 +90,9 @@ def setup(self):
8690
except SQLAlchemyError:
8791
db.session.rollback()
8892
flash("Transaction failed. Please try again.", "danger")
89-
return redirect(url_for("main.setup"), step=3)
9093

9194
else:
9295
flash("Error: Couldn't save form data.", "danger")
93-
return redirect(url_for("main.setup", step=3))
96+
97+
return redirect(url_for("main.setup"), step=3)
98+
# lgtm [py/call/wrong-named-argument]

src/populate_db_for_testing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ def gen_email():
10221022

10231023

10241024
def gen_ip():
1025-
return "127.0.{0}.{0}".format(random.randint(1, 100), random.randint(1, 100))
1025+
return "127.0.{0}.{0}".format(random.randint(1, 100))
10261026

10271027

10281028
def populate_users():
@@ -1044,7 +1044,7 @@ def populate_users():
10441044
db.session.add(log)
10451045
if x % 5 == 0:
10461046
db.session.commit()
1047-
except:
1047+
except Exception as _:
10481048
pass
10491049

10501050
db.session.commit()
@@ -1078,7 +1078,7 @@ def populate_challs():
10781078
db.session.add(chal)
10791079
if x % 5 == 0:
10801080
db.session.commit()
1081-
except:
1081+
except Exception as _:
10821082
pass
10831083

10841084
db.session.commit()
@@ -1109,7 +1109,7 @@ def populate_machines():
11091109
db.session.add(m)
11101110
if x % 5 == 0:
11111111
db.session.commit()
1112-
except:
1112+
except Exception as _:
11131113
pass
11141114

11151115
db.session.commit()

0 commit comments

Comments
 (0)