Skip to content

Commit 9e32f50

Browse files
authored
Merge branch 'CTFd:master' into master
2 parents 4b67e37 + 45ffa11 commit 9e32f50

File tree

8 files changed

+31
-33
lines changed

8 files changed

+31
-33
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
lint:
2-
flake8 --ignore=E402,E501,E712,W503,E203,I002 --exclude=ctfcli/templates **/*.py
2+
ruff check --ignore=E402,E501,E712,I002 --exclude=ctfcli/templates --exclude=build .
33
black --check --exclude=ctfcli/templates .
44

55
format:

ctfcli/cli/challenges.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def install(self, challenge=None, force=False, ignore=()):
173173
else: # If we don't break because of duplicated challenge names
174174
click.secho(f'Installing {challenge["name"]}', fg="yellow")
175175
create_challenge(challenge=challenge, ignore=ignore)
176-
click.secho(f"Success!", fg="green")
176+
click.secho("Success!", fg="green")
177177

178178
def sync(self, challenge=None, ignore=()):
179179
if challenge is None:
@@ -209,7 +209,7 @@ def sync(self, challenge=None, ignore=()):
209209

210210
click.secho(f'Syncing {challenge["name"]}', fg="yellow")
211211
sync_challenge(challenge=challenge, ignore=ignore)
212-
click.secho(f"Success!", fg="green")
212+
click.secho("Success!", fg="green")
213213

214214
def update(self, challenge=None):
215215
config = load_config()
@@ -339,7 +339,7 @@ def deploy(self, challenge, host=None, args=None):
339339
)
340340
else:
341341
click.secho(
342-
f"An error occured during deployment", fg="red",
342+
"An error occured during deployment", fg="red",
343343
)
344344

345345
def push(self, challenge=None):
@@ -364,7 +364,7 @@ def push(self, challenge=None):
364364

365365
def healthcheck(self, challenge):
366366
config = load_config()
367-
challenges = config["challenges"]
367+
_challenges = config["challenges"]
368368

369369
# challenge_path = challenges[challenge]
370370
path = Path(challenge)
@@ -406,11 +406,11 @@ def healthcheck(self, challenge):
406406

407407
if rcode != 0:
408408
click.secho(
409-
f"Healcheck failed", fg="red",
409+
"Healcheck failed", fg="red",
410410
)
411411
sys.exit(1)
412412
else:
413413
click.secho(
414-
f"Success", fg="green",
414+
"Success", fg="green",
415415
)
416416
sys.exit(0)

ctfcli/cli/pages.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ class Pages(object):
1717
def install(self):
1818
try:
1919
_config = load_config()
20-
except:
20+
except Exception as e:
21+
print(e)
2122
click.secho("No ctfcli configuration found", fg="red")
2223
sys.exit(1)
2324

2425
pages = Path("./pages")
2526
if pages.is_dir() is False:
2627
click.secho(
27-
f'"pages" folder not found. All pages must exist in the "pages" folder.',
28+
'"pages" folder not found. All pages must exist in the "pages" folder.',
2829
fg="red",
2930
)
3031
sys.exit(1)

ctfcli/cli/plugins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def install(self, url):
1818
pip3 = shutil.which("pip3")
1919

2020
if pip is None and pip3 is None:
21-
click.secho(f"Neither pip nor pip3 was found, is it in the PATH?", fg="red")
21+
click.secho("Neither pip nor pip3 was found, is it in the PATH?", fg="red")
2222
return
2323

2424
if pip is None:

ctfcli/utils/challenge.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def sync_challenge(challenge, ignore=[]):
7979
# Create new flags
8080
if challenge.get("flags") and "flags" not in ignore:
8181
# Delete existing flags
82-
current_flags = s.get(f"/api/v1/flags", json=data).json()["data"]
82+
current_flags = s.get("/api/v1/flags", json=data).json()["data"]
8383
for flag in current_flags:
8484
if flag["challenge_id"] == challenge_id:
8585
flag_id = flag["id"]
@@ -88,11 +88,11 @@ def sync_challenge(challenge, ignore=[]):
8888
for flag in challenge["flags"]:
8989
if type(flag) == str:
9090
data = {"content": flag, "type": "static", "challenge_id": challenge_id}
91-
r = s.post(f"/api/v1/flags", json=data)
91+
r = s.post("/api/v1/flags", json=data)
9292
r.raise_for_status()
9393
elif type(flag) == dict:
9494
flag["challenge_id"] = challenge_id
95-
r = s.post(f"/api/v1/flags", json=flag)
95+
r = s.post("/api/v1/flags", json=flag)
9696
r.raise_for_status()
9797

9898
# Update topics
@@ -110,7 +110,7 @@ def sync_challenge(challenge, ignore=[]):
110110
# Add new challenge topics
111111
for topic in challenge["topics"]:
112112
r = s.post(
113-
f"/api/v1/topics",
113+
"/api/v1/topics",
114114
json={
115115
"value": topic,
116116
"type": "challenge",
@@ -122,22 +122,22 @@ def sync_challenge(challenge, ignore=[]):
122122
# Update tags
123123
if challenge.get("tags") and "tags" not in ignore:
124124
# Delete existing tags
125-
current_tags = s.get(f"/api/v1/tags", json=data).json()["data"]
125+
current_tags = s.get("/api/v1/tags", json=data).json()["data"]
126126
for tag in current_tags:
127127
if tag["challenge_id"] == challenge_id:
128128
tag_id = tag["id"]
129129
r = s.delete(f"/api/v1/tags/{tag_id}", json=True)
130130
r.raise_for_status()
131131
for tag in challenge["tags"]:
132132
r = s.post(
133-
f"/api/v1/tags", json={"challenge_id": challenge_id, "value": tag}
133+
"/api/v1/tags", json={"challenge_id": challenge_id, "value": tag}
134134
)
135135
r.raise_for_status()
136136

137137
# Upload files
138138
if challenge.get("files") and "files" not in ignore:
139139
# Delete existing files
140-
all_current_files = s.get(f"/api/v1/files?type=challenge", json=data).json()[
140+
all_current_files = s.get("/api/v1/files?type=challenge", json=data).json()[
141141
"data"
142142
]
143143
for f in all_current_files:
@@ -158,13 +158,13 @@ def sync_challenge(challenge, ignore=[]):
158158

159159
data = {"challenge_id": challenge_id, "type": "challenge"}
160160
# Specifically use data= here instead of json= to send multipart/form-data
161-
r = s.post(f"/api/v1/files", files=files, data=data)
161+
r = s.post("/api/v1/files", files=files, data=data)
162162
r.raise_for_status()
163163

164164
# Create hints
165165
if challenge.get("hints") and "hints" not in ignore:
166166
# Delete existing hints
167-
current_hints = s.get(f"/api/v1/hints", json=data).json()["data"]
167+
current_hints = s.get("/api/v1/hints", json=data).json()["data"]
168168
for hint in current_hints:
169169
if hint["challenge_id"] == challenge_id:
170170
hint_id = hint["id"]
@@ -181,7 +181,7 @@ def sync_challenge(challenge, ignore=[]):
181181
"challenge_id": challenge_id,
182182
}
183183

184-
r = s.post(f"/api/v1/hints", json=data)
184+
r = s.post("/api/v1/hints", json=data)
185185
r.raise_for_status()
186186

187187
# Update requirements
@@ -246,18 +246,18 @@ def create_challenge(challenge, ignore=[]):
246246
for flag in challenge["flags"]:
247247
if type(flag) == str:
248248
data = {"content": flag, "type": "static", "challenge_id": challenge_id}
249-
r = s.post(f"/api/v1/flags", json=data)
249+
r = s.post("/api/v1/flags", json=data)
250250
r.raise_for_status()
251251
elif type(flag) == dict:
252252
flag["challenge"] = challenge_id
253-
r = s.post(f"/api/v1/flags", json=flag)
253+
r = s.post("/api/v1/flags", json=flag)
254254
r.raise_for_status()
255255

256256
# Create topics
257257
if challenge.get("topics") and "topics" not in ignore:
258258
for topic in challenge["topics"]:
259259
r = s.post(
260-
f"/api/v1/topics",
260+
"/api/v1/topics",
261261
json={
262262
"value": topic,
263263
"type": "challenge",
@@ -270,7 +270,7 @@ def create_challenge(challenge, ignore=[]):
270270
if challenge.get("tags") and "tags" not in ignore:
271271
for tag in challenge["tags"]:
272272
r = s.post(
273-
f"/api/v1/tags", json={"challenge_id": challenge_id, "value": tag}
273+
"/api/v1/tags", json={"challenge_id": challenge_id, "value": tag}
274274
)
275275
r.raise_for_status()
276276

@@ -288,7 +288,7 @@ def create_challenge(challenge, ignore=[]):
288288

289289
data = {"challenge_id": challenge_id, "type": "challenge"}
290290
# Specifically use data= here instead of json= to send multipart/form-data
291-
r = s.post(f"/api/v1/files", files=files, data=data)
291+
r = s.post("/api/v1/files", files=files, data=data)
292292
r.raise_for_status()
293293

294294
# Add hints
@@ -303,7 +303,7 @@ def create_challenge(challenge, ignore=[]):
303303
"challenge_id": challenge_id,
304304
}
305305

306-
r = s.post(f"/api/v1/hints", json=data)
306+
r = s.post("/api/v1/hints", json=data)
307307
r.raise_for_status()
308308

309309
# Add requirements

ctfcli/utils/pages.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
def get_current_pages():
1111
s = generate_session()
12-
return s.get(f"/api/v1/pages", json=True).json()["data"]
12+
return s.get("/api/v1/pages", json=True).json()["data"]
1313

1414

1515
def get_existing_page(route, pageset=None):
@@ -67,5 +67,5 @@ def install_page(matter, path_obj):
6767
"auth_required": auth_required,
6868
"format": format,
6969
}
70-
r = s.post(f"/api/v1/pages", json=data)
70+
r = s.post("/api/v1/pages", json=data)
7171
r.raise_for_status()

development.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@ twine==3.1.1
33
setuptools==46.1.3
44
wheel==0.34.2
55
black==19.10b0
6-
flake8==3.7.9
7-
flake8-bugbear==20.1.2
8-
flake8-comprehensions==3.1.4
96
isort==4.3.21
10-
flake8-isort==2.8.0
7+
ruff==0.0.254

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ arrow==1.2.3
1010
# via jinja2-time
1111
binaryornot==0.4.4
1212
# via cookiecutter
13-
certifi==2022.9.24
13+
certifi==2022.12.7
1414
# via requests
1515
chardet==5.0.0
1616
# via binaryornot

0 commit comments

Comments
 (0)