remove mindless dev comments

This commit is contained in:
overcuriousity
2025-08-02 12:13:16 +02:00
parent 3973479ae4
commit 57c507915f
12 changed files with 13 additions and 200 deletions

View File

@@ -14,14 +14,13 @@ function getEnv(key: string): string {
return value;
}
// Use the analyzer AI for smart prompting (smaller, faster model)
const AI_ENDPOINT = getEnv('AI_ANALYZER_ENDPOINT');
const AI_API_KEY = getEnv('AI_ANALYZER_API_KEY');
const AI_MODEL = getEnv('AI_ANALYZER_MODEL');
const rateLimitStore = new Map<string, { count: number; resetTime: number }>();
const RATE_LIMIT_WINDOW = 60 * 1000; // 1 minute
const RATE_LIMIT_MAX = 5; // 5 enhancement requests per minute per user
const RATE_LIMIT_MAX = 5;
function sanitizeInput(input: string): string {
return input
@@ -30,7 +29,7 @@ function sanitizeInput(input: string): string {
.replace(/\b(system|assistant|user)\s*[:]/gi, '[ROLE_REMOVED]')
.replace(/\b(ignore|forget|disregard)\s+(previous|all|your)\s+(instructions?|context|rules?)/gi, '[INSTRUCTION_REMOVED]')
.trim()
.slice(0, 1000); // Shorter limit for enhancement
.slice(0, 1000);
}
function checkRateLimit(userId: string): boolean {
@@ -59,7 +58,6 @@ function cleanupExpiredRateLimits() {
}
}
// Clean up expired limits every 5 minutes
setInterval(cleanupExpiredRateLimits, 5 * 60 * 1000);
function createEnhancementPrompt(input: string): string {
@@ -140,7 +138,6 @@ export const POST: APIRoute = async ({ request }) => {
],
max_tokens: 300,
temperature: 0.7,
// Enhanced: Better parameters for consistent forensics output
top_p: 0.9,
frequency_penalty: 0.2,
presence_penalty: 0.1
@@ -171,27 +168,23 @@ export const POST: APIRoute = async ({ request }) => {
throw new Error('Response is not an array');
}
// Enhanced validation and cleaning for forensics context
questions = questions
.filter(q => typeof q === 'string' && q.length > 20 && q.length < 200) // More appropriate length for forensics questions
.filter(q => q.includes('?')) // Must be a question
.filter(q => typeof q === 'string' && q.length > 20 && q.length < 200)
.filter(q => q.includes('?'))
.filter(q => {
// Enhanced: Filter for forensics-relevant questions
const forensicsTerms = ['forensisch', 'log', 'dump', 'image', 'artefakt', 'evidence', 'incident', 'system', 'netzwerk', 'zeitraum', 'verfügbar'];
const lowerQ = q.toLowerCase();
return forensicsTerms.some(term => lowerQ.includes(term));
})
.map(q => q.trim())
.slice(0, 3); // Max 3 questions
.slice(0, 3);
// If no valid forensics questions, return empty array (means input is complete)
if (questions.length === 0) {
questions = [];
}
} catch (error) {
console.error('Failed to parse enhancement response:', aiContent);
// If parsing fails, assume input is complete enough
questions = [];
}

View File

@@ -43,7 +43,7 @@ interface KnowledgebaseContributionData {
const rateLimitStore = new Map<string, { count: number; resetTime: number }>();
const RATE_LIMIT_WINDOW = 60 * 60 * 1000; // 1 hour
const RATE_LIMIT_MAX = 3; // Max 3 submissions per hour per user
const RATE_LIMIT_MAX = 3;
function checkRateLimit(userEmail: string): boolean {
const now = Date.now();

View File

@@ -1,4 +1,4 @@
// src/pages/api/upload/media.ts (UPDATED - Using consolidated API responses)
// src/pages/api/upload/media.ts
import type { APIRoute } from 'astro';
import { withAPIAuth } from '../../../utils/auth.js';
import { apiResponse, apiError, apiServerError, apiSpecial, handleAPIRequest } from '../../../utils/api.js';

View File

@@ -173,29 +173,24 @@ const phases = data.phases;
<script define:vars={{ toolsData: data.tools, phases: data.phases }}>
window.toolsData = toolsData;
// Approach selection functionality
window.selectApproach = function(approach) {
console.log(`Selected approach: ${approach}`);
// Hide any existing results
const aiResults = document.getElementById('ai-results');
if (aiResults) aiResults.style.display = 'none';
// Visual feedback for selection
document.querySelectorAll('.approach-card').forEach(card => {
card.classList.remove('selected');
});
document.querySelector(`.approach-card.${approach}`).classList.add('selected');
if (approach === 'methodology') {
// Show NIST methodology section
const methodologySection = document.getElementById('methodology-section');
if (methodologySection) {
methodologySection.classList.add('active');
window.scrollToElementById('methodology-section');
}
} else if (approach === 'targeted') {
// Show targeted scenarios section
const targetedSection = document.getElementById('targeted-section');
if (targetedSection) {
targetedSection.classList.add('active');
@@ -204,34 +199,28 @@ const phases = data.phases;
}
};
// Phase selection function (integrates with existing ToolFilters)
window.selectPhase = function(phase) {
console.log(`Selected NIST phase: ${phase}`);
// Remove active class from all phase cards
document.querySelectorAll('.phase-card').forEach(card => {
card.classList.remove('active');
});
// Add active class to selected phase card
const selectedCard = document.querySelector(`.phase-card.phase-${phase}`);
if (selectedCard) {
selectedCard.classList.add('active');
}
// Use existing phase filter functionality
const existingPhaseButton = document.querySelector(`[data-phase="${phase}"]`);
if (existingPhaseButton && !existingPhaseButton.classList.contains('active')) {
existingPhaseButton.click();
}
// Switch to grid view to show results
const gridToggle = document.querySelector('.view-toggle[data-view="grid"]');
if (gridToggle && !gridToggle.classList.contains('active')) {
gridToggle.click();
}
// Scroll to results using consolidated utility
window.scrollToElementById('tools-grid');
};
@@ -296,7 +285,6 @@ const phases = data.phases;
break;
}
// Add smooth scrolling to filters section after layout settles
setTimeout(() => {
window.scrollToElementById('filters-section');
}, 150);
@@ -369,7 +357,6 @@ const phases = data.phases;
}, 2000);
} else {
console.warn('Tool card not found in grid:', toolName);
// Fallback to tools grid
window.scrollToElementById('tools-grid');
}
}, 300);
@@ -407,7 +394,6 @@ const phases = data.phases;
window.scrollToElement(firstMatch);
} else {
console.warn('Tool chip not found in matrix:', toolName);
// Fallback to matrix container
window.scrollToElementById('matrix-container');
}
}, 500);