Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IFileSystem } from '../../domain/interfaces';
import { IPlatformProviders } from '../ports/platform-detection.port';
import { InitProjectInput } from './use-case.types';
import * as path from 'path';

/**
* The commit types GIT-08 itself enumerates, in its own `pattern`. Kept in the
Expand Down Expand Up @@ -185,7 +186,11 @@ evolith sdlc gate-status
</PropertyGroup>
</Project>
`;
await this.fs.writeFile(`${projectDir}/${input.name}.csproj`, csproj);
// The .csproj takes its name from the directory the use case already
// validated and built (`${cwd}/${name}`), not from a second read of
// `input.name`: same string, but CodeQL only sees the sanitizer on the
// variable, and this property read kept js/path-injection open on the sink.
await this.fs.writeFile(`${projectDir}/${path.basename(projectDir)}.csproj`, csproj);
await this.fs.ensureDir(`${projectDir}/src`);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ describe('InitializeProjectUseCase · the name is a directory, not a path (CWE-2
},
);

it('names the .csproj after the validated directory, never a second read of input.name', async () => {
const { fs, root } = await init({ name: 'Billing.Api', runtime: 'dotnet' });
expect(fs.files.has(`${root}/Billing.Api.csproj`)).toBe(true);
});

it('keeps accepting the dotted and dashed names npm does', async () => {
const { root } = await init({ name: 'acme.billing-api_v2' });
expect(root).toBe('/tmp/acme.billing-api_v2');
Expand Down
Loading