A software dependency is a component, package, library, or resource required for another component to function. In AI-generated code, dependencies may appear through pattern matching rather than deliberate engineering choice, creating maintenance, licensing, security, and supply-chain risk. section 8.2.4
Evaluate every dependency before accepting generated code:
- Check known vulnerabilities with tools such as Snyk, Dependabot, or npm audit. section 8.2.4
- Check license compatibility with tools such as FOSSA or license-checker. section 8.2.4
- Verify that the package exists, remains maintained, and has no suspicious ownership changes. section 8.2.4
- Ask whether the dependency is necessary; unnecessary libraries expand the attack surface and may add substantial complexity. section 8.2.4
Dependencies also exist outside a function's visible lines. Libraries, data structures, invocation conventions, configuration, and neighboring services can determine whether a seemingly valid change is compatible with the real application. Isolated snippets invite invented methods, substituted libraries, and altered security behavior. section 3.2
async function authenticateUser(req, res) {
const { username, password } = req.body;
try {
const user = await DatabaseClient.findUser(username);
if (!user) {
return res.status(401).send("Unauthorized");
}
const isValid = await bcrypt.compare(
password, user.passwordHash);
if (!isValid) {
return res.status(401).send("Unauthorized");
}
const token = jwt.sign({ id: user.id },
"secret", { expiresIn: "1h" });
res.json({ token });
} catch (err) {
console.error(err);
res.status(500).send("Internal server error");
}
}Inspect the authentication function's surrounding dependencies: DatabaseClient, bcrypt, jwt, passwordHash, and the request-handling contract. section 3.2
A plausible but unsafe refactor
An isolated authentication snippet was transformed by an AI into code using an invented database method, plain-text password comparison, a different JWT library, changed status semantics, and a hardcoded secret. The code's dependencies and project conventions were missing from the prompt, so the generated result sounded confident while breaking security and compatibility. section 3.2


































