fix(security): critical security and stability fixes
Some checks failed
Default (tags) / security (push) Successful in 1m2s
Default (tags) / test (push) Failing after 46m14s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped

This commit is contained in:
2025-08-14 14:30:54 +00:00
parent 6eac957baf
commit 5fbcf81c2c
19 changed files with 1647 additions and 1301 deletions

View File

@@ -11,6 +11,7 @@ import type { THttpMethod } from '../../protocols/http/index.js';
import { QuickProtocolDetector } from './quick-detector.js';
import { RoutingExtractor } from './routing-extractor.js';
import { DetectionFragmentManager } from '../utils/fragment-manager.js';
import { HttpParser } from '../../protocols/http/parser.js';
/**
* Simplified HTTP detector
@@ -56,6 +57,17 @@ export class HttpDetector implements IProtocolDetector {
// Extract routing information
const routing = RoutingExtractor.extract(buffer, 'http');
// Extract headers if requested and we have complete headers
let headers: Record<string, string> | undefined;
if (options?.extractFullHeaders && isComplete) {
const headerSection = buffer.slice(0, headersEnd).toString();
const lines = headerSection.split('\r\n');
if (lines.length > 1) {
// Skip the request line and parse headers
headers = HttpParser.parseHeaders(lines.slice(1));
}
}
// If we don't need full headers and we have complete headers, we can return early
if (quickResult.confidence >= 95 && !options?.extractFullHeaders && isComplete) {
return {
@@ -76,7 +88,8 @@ export class HttpDetector implements IProtocolDetector {
protocol: 'http',
domain: routing?.domain,
path: routing?.path,
method: quickResult.metadata?.method as THttpMethod
method: quickResult.metadata?.method as THttpMethod,
headers: headers
},
isComplete,
bytesNeeded: isComplete ? undefined : buffer.length + 512 // Need more for headers