Skip to content

Commit 513e86f

Browse files
lpcoxCopilot
andauthored
refactor: remove dead exports from export audit (#2960)
- Remove unused `OptionSourceResolver` type export from main-action.ts (not imported anywhere) — closes #2927 - Remove dead `extractPort` function from log-parser.ts (never called internally or externally) and its barrel re-export — closes #2914 - Remove redundant `PidTrackResult` re-export from pid-tracker.ts (already exported from types/index.ts) — closes #2915 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ef6a9f6 commit 513e86f

5 files changed

Lines changed: 3 additions & 46 deletions

File tree

src/commands/main-action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import {
6262
* Injected to decouple the action handler from the global program instance,
6363
* enabling independent unit testing.
6464
*/
65-
export type OptionSourceResolver = (optionName: string) => string | undefined;
65+
type OptionSourceResolver = (optionName: string) => string | undefined;
6666

6767
/**
6868
* Creates the main `awf` action handler bound to a specific option-source

src/logs/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Log viewing utilities for Squid proxy logs
33
*/
44

5-
export { parseLogLine, extractDomain, extractPort } from './log-parser';
5+
export { parseLogLine, extractDomain } from './log-parser';
66
export { LogFormatter } from './log-formatter';
77
export {
88
discoverLogSources,

src/logs/log-parser.test.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Unit tests for log-parser.ts
33
*/
44

5-
import { parseLogLine, extractDomain, extractPort, parseAuditJsonlLine } from './log-parser';
5+
import { parseLogLine, extractDomain, parseAuditJsonlLine } from './log-parser';
66

77
describe('log-parser', () => {
88
describe('parseLogLine', () => {
@@ -224,26 +224,6 @@ describe('log-parser', () => {
224224
});
225225
});
226226

227-
describe('extractPort', () => {
228-
it('should extract port from CONNECT URL', () => {
229-
expect(extractPort('api.github.com:443', 'CONNECT')).toBe('443');
230-
expect(extractPort('example.com:8080', 'CONNECT')).toBe('8080');
231-
});
232-
233-
it('should return undefined for CONNECT URL without port', () => {
234-
expect(extractPort('api.github.com', 'CONNECT')).toBeUndefined();
235-
});
236-
237-
it('should return undefined for non-CONNECT methods', () => {
238-
expect(extractPort('http://example.com:80/', 'GET')).toBeUndefined();
239-
expect(extractPort('http://example.com/', 'POST')).toBeUndefined();
240-
});
241-
242-
it('should not extract non-numeric port', () => {
243-
expect(extractPort('api.github.com:abc', 'CONNECT')).toBeUndefined();
244-
});
245-
});
246-
247227
describe('parseAuditJsonlLine', () => {
248228
it('should parse a valid JSONL CONNECT entry', () => {
249229
const line = '{"ts":1761074374.646,"client":"172.30.0.20","host":"api.github.com:443","dest":"140.82.114.22:443","method":"CONNECT","status":200,"decision":"TCP_TUNNEL","url":"api.github.com:443"}';

src/logs/log-parser.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,6 @@ export function extractDomain(url: string, host: string, method: string): string
142142
}
143143
}
144144

145-
/**
146-
* Extracts the port from a domain:port string or URL
147-
*
148-
* @param url - URL field or domain:port string
149-
* @param method - HTTP method
150-
* @returns Port number string or undefined
151-
*/
152-
export function extractPort(url: string, method: string): string | undefined {
153-
if (method === 'CONNECT') {
154-
const colonIndex = url.lastIndexOf(':');
155-
if (colonIndex !== -1) {
156-
const possiblePort = url.substring(colonIndex + 1);
157-
if (/^\d+$/.test(possiblePort)) {
158-
return possiblePort;
159-
}
160-
}
161-
}
162-
return undefined;
163-
}
164-
165145
/**
166146
* Parses a single line from the JSONL audit log (audit.jsonl).
167147
*

src/pid-tracker.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ import * as fs from 'fs';
2424
import * as path from 'path';
2525
import { PidTrackResult } from './types';
2626

27-
// Re-export PidTrackResult for convenience
28-
export { PidTrackResult } from './types';
29-
3027
/**
3128
* Parsed entry from /proc/net/tcp
3229
*/

0 commit comments

Comments
 (0)