Skip to content

Commit

Permalink
Add CINI parser (ECSC 2024)
Browse files Browse the repository at this point in the history
  • Loading branch information
erdnaxe committed Jun 8, 2024
1 parent 1944eec commit 381a0ca
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
55 changes: 55 additions & 0 deletions front/src/ctfnote/parsers/cini.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { ParsedTask, Parser } from '.';
import { parseJson, parseJsonStrict } from '../utils';

interface Events {
gamePause?: unknown;
events: [
{
id: number;
name: string;
sections: [
{
id: number;
name: string;
challenges: [
{
id: number;
title: string;
tags: string[];
authors: string[];
currentScore: number;
currentGlobalSolves: number;
hidden: boolean;
}
];
}
];
}
];
}

const CINIParser: Parser = {
name: 'Cybersecurity National Lab (CINI) platform and ECSC 2024 (Turin) parser',
hint: 'paste platform /api/challenges',

parse(s: string): ParsedTask[] {
const tasks = [];
const data = parseJsonStrict<Events>(s);

for (const event of data.events) {
for (const section of event.sections) {
for (const chall of section.challenges) {
tasks.push({ title: chall.title, tags: chall.tags });
}
}
}

return tasks;
},
isValid(s) {
const data = parseJson<Events>(s);
return !Array.isArray(data);
},
};

export default CINIParser;
2 changes: 2 additions & 0 deletions front/src/ctfnote/parsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import HTBParser from './htb';
import PicoParser from './pico';
import justCTFParser from './justctf';
import AngstromParser from './angstrom';
import CINIParser from './cini';

export type ParsedTask = {
title: string;
Expand All @@ -28,4 +29,5 @@ export default [
PicoParser,
justCTFParser,
AngstromParser,
CINIParser,
];

0 comments on commit 381a0ca

Please sign in to comment.