File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed
front/src/ctfnote/parsers Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import HTBParser from './htb';
55import PicoParser from './pico' ;
66import justCTFParser from './justctf' ;
77import AngstromParser from './angstrom' ;
8+ import CINIParser from './cini' ;
89
910export type ParsedTask = {
1011 title : string ;
@@ -28,4 +29,5 @@ export default [
2829 PicoParser ,
2930 justCTFParser ,
3031 AngstromParser ,
32+ CINIParser ,
3133] ;
You can’t perform that action at this time.
0 commit comments