Coding with AI tools: GitHub Copilot

Sefism.

Chapter 08

Security and licences

What never goes into a prompt, secrets, hallucinated packages, insecure patterns AI repeats, scanning, licences of copied code, data settings and your employer's or university's AI policy.

Never paste this

Also called sensitive data, confidential

What
The list of things that never go into a prompt, a file the tool can read or a screenshot you attach, whatever the tool's privacy settings say.
Why
Prompts leave your machine. One pasted production key or customer record can be a breach and a firing offence.
Code
API keys, tokens, passwords, private keys (.pem, id_rsa)
.env files and cloud credentials
Customer or patient data, real emails, phone numbers
Production database dumps or connection strings
Employer code if policy forbids it
Exam, assignment or take-home questions where AI is banned
Anything under NDA

Secrets out of code and context

Also called environment variables, secret scanning, .env

What
Keeping secrets in environment variables or a secrets manager, listing .env in .gitignore, blocking it from the tool and scanning commits for leaks.
Why
AI tools happily hard-code a key they saw to make something work. Scanners catch it before it reaches a public repository.
Shell
echo ".env" >> .gitignore
gitleaks git -v            # scan history for secrets
gitleaks dir .             # scan the working folder
# Leaked? Rotate the key first, then clean history

Watch out

Deleting a leaked key from the latest commit and thinking it is gone: it is still in Git history, so rotate it.

Hallucinated packages

Also called slopsquatting, package hallucination, typosquatting

What
Package names a model invents that do not exist, or that attackers have since registered with malicious code because models keep suggesting the same fake names.
Why
One npm install or pip install of a fake package runs someone else's code on your machine. Every new dependency needs a check before install.

Watch out

Letting an agent in an auto-approve mode install packages it chose itself.

Checking a new dependency

Also called npm audit, pip-audit, supply chain

What
Confirming a package is real, maintained, widely used and needed, and auditing known vulnerabilities, before adding it.
Why
Every dependency is code you trust and ship. Many AI suggestions add a package for something the standard library already does.
Shell
npm view left-pad repository time.modified
npm audit                  # known vulnerabilities
pip index versions requests
pip-audit                  # Python, from PyPA
# Check: official repo, recent releases, downloads,
# and whether the standard library already does it

Insecure patterns AI repeats

Also called SQL injection, XSS, insecure defaults

What
Classic flaws that appear often in generated code: SQL built by string concatenation, unescaped HTML, eval, disabled TLS verification, CORS set to allow everyone, weak password hashing and missing authorisation checks.
Why
Models learned from public code, including insecure code. Knowing the list lets you spot them in review in seconds.
Example
Generated: db.query("SELECT * FROM users WHERE id = " + id). Safe: a parameterised query such as db.query("... WHERE id = $1", [id]).

Watch out

Asking the tool to "act as a security expert" and assuming the output is now secure: tell it the concrete rules instead.

Static analysis on AI code

Also called SAST, linter, Semgrep, CodeQL

What
Automated tools that scan source code for bug and security patterns without running it, run locally and in CI on every pull request.
Why
They check every line at machine speed, including the lines you skimmed. Ask the agent to run them and fix findings as part of done.
Shell
semgrep scan --config auto   # community rules
npx eslint .                 # JavaScript/TypeScript
ruff check .                 # Python
# In CI: run on every pull request

Licences and copied code

Also called open source licence, code referencing, attribution

What
Generated code can occasionally match public code closely, and that code may carry a licence with conditions such as attribution or sharing your changes.
Why
Licence problems surface late and expensively. Some tools can flag or block suggestions that match public code; know your tool's setting and your employer's rule.

Watch out

Pasting a large, distinctive block from an AI answer into a closed-source product without asking where it came from.

Data use and privacy settings

Also called privacy mode, training opt-out, data retention

What
Account and organisation settings that control whether your prompts and code may be kept or used to train models. They differ by tool, plan and whether you use a personal or company account.
Why
The same tool can be fine for a side project and forbidden for client work. Check the settings before you open a work repository.
Code
# github.com > Settings > Copilot: check whether
# suggestions matching public code are allowed and
# your data settings. Business and Enterprise
# policies are set by the organisation.

Employer and university AI policy

Also called acceptable use, academic integrity

What
The written rules on which AI tools you may use, on what code and data, and whether you must disclose it, set by your employer, client or course.
Why
Breaking them can mean a failed course or a lost job, even if the code was good. When unsure, ask before you start.

Watch out

Assuming that because a tool is installed on a work laptop, it is approved for every repository.

08 · Security and licences8 / 11