feat: harden server pull deployments and git hygiene
This commit is contained in:
@@ -99,3 +99,26 @@ test("Git Validator recognizes remote aliases and secret-shaped tracked paths",
|
||||
assert.equal(isSensitiveTrackedPath("config/private.pem"), true);
|
||||
assert.equal(isSensitiveTrackedPath(".env.example"), false);
|
||||
});
|
||||
|
||||
test("Git Validator reports reproducibility, CI and editor hygiene and creates reviewable defaults", async (t) => {
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), "forgeflow-hygiene-"));
|
||||
t.after(() => rm(root, { recursive: true, force: true }));
|
||||
await git(["init", "-b", "main"], root);
|
||||
await git(["config", "user.name", "ForgeFlow Test"], root);
|
||||
await git(["config", "user.email", "forgeflow@example.invalid"], root);
|
||||
await git(["remote", "add", "origin", "https://gitea.example.test/jens/app.git"], root);
|
||||
await writeFile(path.join(root, "package.json"), '{"name":"app"}\n', "utf8");
|
||||
await writeFile(path.join(root, "README.md"), "# App\n", "utf8");
|
||||
await writeFile(path.join(root, ".gitignore"), ".env\n", "utf8");
|
||||
await git(["add", "."], root);
|
||||
await git(["commit", "-m", "Initial"], root);
|
||||
const validator = new GitValidatorService({ git: new GitService(), gitea: { getBranchProtection: async () => ({ protected: true, enableForcePush: false }) } });
|
||||
const repository = { fullName: "jens/app", name: "app", owner: { login: "jens" }, defaultBranch: "main", localPath: root, cloneUrl: "https://gitea.example.test/jens/app.git" };
|
||||
const report = await validator.scan(repository);
|
||||
assert.equal(report.checks.find((check) => check.id === "dependency-lock").status, "warning");
|
||||
assert.equal(report.checks.find((check) => check.id === "continuous-integration").status, "warning");
|
||||
for (const action of ["add-gitattributes", "add-editorconfig"])
|
||||
await validator.repair(repository, { fixAction: action });
|
||||
assert.match(await readFile(path.join(root, ".gitattributes"), "utf8"), /text=auto/);
|
||||
assert.match(await readFile(path.join(root, ".editorconfig"), "utf8"), /root = true/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user