79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
const { pool } = require('./src/config/database');
|
|
|
|
const lessons = [
|
|
{
|
|
lesson_key: 'sql-injection-shop',
|
|
title: 'SQL Injection Attack - Online Shop Demo',
|
|
description: 'Learn how SQL injection vulnerabilities work through a realistic online shop scenario',
|
|
module_path: 'sql-injection-shop',
|
|
config_path: 'sql-injection-shop.yaml',
|
|
difficulty_level: 'intermediate',
|
|
estimated_duration: 20
|
|
},
|
|
{
|
|
lesson_key: 'browser-in-browser-attack',
|
|
title: 'Browser-in-the-Browser (BitB) Attack',
|
|
description: 'Learn to identify sophisticated phishing attacks that mimic legitimate browser windows',
|
|
module_path: 'browser-in-browser-attack',
|
|
config_path: 'browser-in-browser-attack.yaml',
|
|
difficulty_level: 'advanced',
|
|
estimated_duration: 25
|
|
}
|
|
];
|
|
|
|
async function seedLessons() {
|
|
const client = await pool.connect();
|
|
|
|
try {
|
|
console.log('Starting to seed new lessons...');
|
|
|
|
for (const lesson of lessons) {
|
|
// Check if lesson already exists
|
|
const existingResult = await client.query(
|
|
'SELECT id FROM lessons WHERE lesson_key = $1',
|
|
[lesson.lesson_key]
|
|
);
|
|
|
|
if (existingResult.rows.length > 0) {
|
|
console.log(`Lesson "${lesson.lesson_key}" already exists, skipping...`);
|
|
continue;
|
|
}
|
|
|
|
// Insert new lesson
|
|
const result = await client.query(
|
|
`INSERT INTO lessons (lesson_key, title, description, module_path, config_path, difficulty_level, estimated_duration)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
RETURNING id`,
|
|
[
|
|
lesson.lesson_key,
|
|
lesson.title,
|
|
lesson.description,
|
|
lesson.module_path,
|
|
lesson.config_path,
|
|
lesson.difficulty_level,
|
|
lesson.estimated_duration
|
|
]
|
|
);
|
|
|
|
console.log(`✓ Created lesson: ${lesson.title} (ID: ${result.rows[0].id})`);
|
|
}
|
|
|
|
console.log('\n✅ All new lessons seeded successfully!');
|
|
console.log('\nYou can now assign these lessons to events via the admin panel.');
|
|
|
|
} catch (error) {
|
|
console.error('Error seeding lessons:', error);
|
|
throw error;
|
|
} finally {
|
|
client.release();
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
seedLessons()
|
|
.then(() => process.exit(0))
|
|
.catch((error) => {
|
|
console.error('Seed failed:', error);
|
|
process.exit(1);
|
|
});
|