Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
];