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 55b83a7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
58 changes: 58 additions & 0 deletions front/src/ctfnote/parsers/cini.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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, ECSC 2024 (Turin) parser',
hint: 'paste platform /api/challenges',

parse(s: string): ParsedTask[] {
const tasks = [];
const data = parseJsonStrict<Events>(s);
if (!Array.isArray(data)) {
return [];
}

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 55b83a7

Please sign in to comment.