Skip to content

Commit

Permalink
Merge pull request #268 from erdnaxe/ecsc-importer
Browse files Browse the repository at this point in the history
CINI (ECSC 2024) importer
  • Loading branch information
JJ-8 authored Jul 14, 2024
2 parents 08eed9b + a7290b1 commit f618fa9
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 31 deletions.
56 changes: 56 additions & 0 deletions front/src/ctfnote/parsers/cini.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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);
if (data == null) return false;
return data.gamePause !== undefined && data.events !== undefined;
},
};

export default CINIParser;
29 changes: 0 additions & 29 deletions front/src/ctfnote/parsers/ecsc.ts

This file was deleted.

4 changes: 2 additions & 2 deletions front/src/ctfnote/parsers/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import CTFDParser from './ctfd';
import ECSCParser from './ecsc';
import RawParser from './raw';
import HTBParser from './htb';
import PicoParser from './pico';
import justCTFParser from './justctf';
import AngstromParser from './angstrom';
import CINIParser from './cini';
import HitconParser from './hitcon';

export type ParsedTask = {
Expand All @@ -24,10 +24,10 @@ export type Parser = {
export default [
RawParser,
CTFDParser,
ECSCParser,
HTBParser,
PicoParser,
justCTFParser,
AngstromParser,
CINIParser,
HitconParser,
];

0 comments on commit f618fa9

Please sign in to comment.