// engine/security-analyzer/profile-detector.ts — Feature profile and auth detection
// SPEC-029
// === Feature profile detection ===
const PROFILE_KEYWORDS = [
    { keywords: ['api', 'endpoint', 'route', 'rest', 'graphql'], profile: 'public-api' },
    {
        keywords: ['auth', 'login', 'signup', 'register', 'password', 'jwt', 'oauth', 'session'],
        profile: 'auth',
    },
    {
        keywords: ['database', 'query', 'sql', 'db', 'schema', 'orm', 'repository'],
        profile: 'db-access',
    },
    { keywords: ['upload', 'file', 'attachment', 'media', 'image'], profile: 'file-upload' },
    { keywords: ['html', 'render', 'template', 'ui', 'frontend', 'view'], profile: 'html-render' },
    {
        keywords: ['pii', 'personal', 'email', 'phone', 'ssn', 'gdpr', 'privacy'],
        profile: 'pii-data',
    },
];
export function detectSecurityProfiles(title, description, tags) {
    const lower = `${title} ${description} ${tags.join(' ')}`.toLowerCase();
    const profiles = [];
    for (const { keywords, profile } of PROFILE_KEYWORDS) {
        if (keywords.some((kw) => lower.includes(kw))) {
            profiles.push(profile);
        }
    }
    if (profiles.length === 0) {
        profiles.push('internal-service');
    }
    return profiles;
}
// === Auth mechanism detection ===
export function detectAuthMechanism(description, tags) {
    const lower = `${description} ${tags.join(' ')}`.toLowerCase();
    if (lower.includes('jwt') || lower.includes('json web token')) {
        return 'jwt';
    }
    if (lower.includes('oauth') || lower.includes('oauth2')) {
        return 'oauth2';
    }
    if (lower.includes('api key') || lower.includes('apikey') || lower.includes('api_key')) {
        return 'api-key';
    }
    if (lower.includes('session') || lower.includes('cookie')) {
        return 'session';
    }
    if (lower.includes('basic auth') || lower.includes('basic authentication')) {
        return 'basic';
    }
    return 'none';
}
//# sourceMappingURL=profile-detector.js.map