fix: address CodeQL warnings on include-extractor

- Remove unused HEADER_GLOB constant in include-extractor.ts
- Use fs.mkdtempSync for secure temp dir creation in tests
  (CodeQL: 'Insecure temporary file')
This commit is contained in:
HuangWenjie 2026-05-07 17:48:46 +08:00
parent c61ceff07b
commit fcc4319ab9
2 changed files with 3 additions and 7 deletions

View file

@ -32,7 +32,6 @@ import {
const HEADER_EXTENSIONS = new Set(['.h', '.hpp', '.hxx', '.hh']);
const HEADER_GLOB = '**/*.{h,hpp,hxx,hh}';
const SOURCE_GLOB = '**/*.{c,cpp,cc,cxx,h,hpp,hxx,hh}';
const STANDARD_IGNORES = [

View file

@ -11,8 +11,7 @@ describe('IncludeExtractor', () => {
let extractor: IncludeExtractor;
beforeEach(() => {
tmpDir = path.join(os.tmpdir(), `gitnexus-include-${Date.now()}`);
fs.mkdirSync(tmpDir, { recursive: true });
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gitnexus-include-'));
extractor = new IncludeExtractor();
});
@ -164,15 +163,13 @@ int main() { return 0; }`,
describe('cross-repo matching', () => {
it('provider and consumer produce matching contractIds', async () => {
// Simulate provider repo (header-only)
const providerDir = path.join(os.tmpdir(), `gitnexus-include-provider-${Date.now()}`);
fs.mkdirSync(providerDir, { recursive: true });
const providerDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gitnexus-include-provider-'));
const providerFile = path.join(providerDir, 'map/base/dice_map_view.h');
fs.mkdirSync(path.dirname(providerFile), { recursive: true });
fs.writeFileSync(providerFile, '#pragma once\nclass DiceMapView {};');
// Simulate consumer repo
const consumerDir = path.join(os.tmpdir(), `gitnexus-include-consumer-${Date.now()}`);
fs.mkdirSync(consumerDir, { recursive: true });
const consumerDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gitnexus-include-consumer-'));
const consumerFile = path.join(consumerDir, 'src/controller.cpp');
fs.mkdirSync(path.dirname(consumerFile), { recursive: true });
fs.writeFileSync(consumerFile, '#include "map/base/dice_map_view.h"\nvoid init() {}');