Phát triển phần mềm với GitHub Copilot
Thalia Barrera
AI Engineering Curriculum Manager, DataCamp

def get_user(username):
query = f"SELECT * FROM users \
WHERE username = '{username}'"
return db.execute(query)
Kẻ tấn công có thể chèn SQL:
users[quay màn hình]
[quay màn hình]
Rà soát có mục tiêu
Rà soát
#selectiontìm lỗ hổng SQL injection và XSS
Quét toàn mã nguồn
Quét
@workspacetìm thông tin xác thực hoặc API key hardcode
[quay màn hình]

Sinh mã phòng thủ
Thêm kiểm tra dữ liệu đầu vào cho endpoint này. Từ chối kiểu không mong đợi và giới hạn độ dài.
Đừng chỉ tìm lỗ hổng — hãy ngăn chúng
.github/copilot-instructions.md
## Security standards
- Use parameterized queries
- Never hardcode credentials or API keys
- Validate and sanitize all user input
- Use bcrypt or argon2 for password hashing
.github/instructions/security.instructions.md
applyTo: "**/*.py"
- Use secrets module instead of random for tokens
- Escape all user input in Jinja2 templates
✅ Bảo mật trở thành một phần của cách bạn viết mã
Phát triển phần mềm với GitHub Copilot