Skip to content

Commit 381a0ca

Browse files
committed
Add CINI parser (ECSC 2024)
1 parent 1944eec commit 381a0ca

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

front/src/ctfnote/parsers/cini.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { ParsedTask, Parser } from '.';
2+
import { parseJson, parseJsonStrict } from '../utils';
3+
4+
interface Events {
5+
gamePause?: unknown;
6+
events: [
7+
{
8+
id: number;
9+
name: string;
10+
sections: [
11+
{
12+
id: number;
13+
name: string;
14+
challenges: [
15+
{
16+
id: number;
17+
title: string;
18+
tags: string[];
19+
authors: string[];
20+
currentScore: number;
21+
currentGlobalSolves: number;
22+
hidden: boolean;
23+
}
24+
];
25+
}
26+
];
27+
}
28+
];
29+
}
30+
31+
const CINIParser: Parser = {
32+
name: 'Cybersecurity National Lab (CINI) platform and ECSC 2024 (Turin) parser',
33+
hint: 'paste platform /api/challenges',
34+
35+
parse(s: string): ParsedTask[] {
36+
const tasks = [];
37+
const data = parseJsonStrict<Events>(s);
38+
39+
for (const event of data.events) {
40+
for (const section of event.sections) {
41+
for (const chall of section.challenges) {
42+
tasks.push({ title: chall.title, tags: chall.tags });
43+
}
44+
}
45+
}
46+
47+
return tasks;
48+
},
49+
isValid(s) {
50+
const data = parseJson<Events>(s);
51+
return !Array.isArray(data);
52+
},
53+
};
54+
55+
export default CINIParser;

front/src/ctfnote/parsers/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import HTBParser from './htb';
55
import PicoParser from './pico';
66
import justCTFParser from './justctf';
77
import AngstromParser from './angstrom';
8+
import CINIParser from './cini';
89

910
export type ParsedTask = {
1011
title: string;
@@ -28,4 +29,5 @@ export default [
2829
PicoParser,
2930
justCTFParser,
3031
AngstromParser,
32+
CINIParser,
3133
];

0 commit comments

Comments
 (0)