Move docs directory validation to after copying README.md

Signed-off-by: Ruslans Tarasovs <ruslan@tarasovs.com>
This commit is contained in:
Ruslans Tarasovs
2026-03-16 12:38:46 +02:00
committed by Ruslans Tarasovs
parent fd1854e3bc
commit 6ce84626ab
3 changed files with 25 additions and 5 deletions
@@ -121,11 +121,6 @@ export class TechdocsGenerator implements GeneratorBase {
this.options.dangerouslyAllowAdditionalKeys,
);
// Validate that no symlinks in the docs directory point outside the input directory
// This prevents path traversal attacks where malicious symlinks could leak host files
const resolvedDocsDir = path.join(inputDir, docsDir ?? 'docs');
await validateDocsDirectory(resolvedDocsDir, inputDir);
if (parsedLocationAnnotation) {
await patchMkdocsYmlPreBuild(
mkdocsYmlPath,
@@ -139,6 +134,12 @@ export class TechdocsGenerator implements GeneratorBase {
await patchIndexPreBuild({ inputDir, logger: childLogger, docsDir });
}
// Validate that no symlinks in the docs directory point outside the input directory
// This prevents path traversal attacks where malicious symlinks could leak host files
const resolvedDocsDir = path.join(inputDir, docsDir ?? 'docs');
await validateDocsDirectory(resolvedDocsDir, inputDir);
// patch the list of mkdocs plugins
const defaultPlugins = this.options.defaultPlugins ?? [];