Evaluate your understanding of key GitHub security best practices. This quiz covers important measures and strategies for maintaining code repository security, access control, and incident prevention in collaborative development environments.
Which method is recommended to minimize unauthorized access to a private repository when inviting new collaborators?
Explanation: Limiting collaborator permissions to only what is necessary greatly reduces potential security risks, ensuring users cannot perform unintended actions. Granting full owner access gives excessive power and increases danger if accounts are compromised. Allowing anonymous read-only access even temporarily can expose sensitive information. Sharing repository links publicly can inadvertently invite breaches from untrusted individuals.
What is a best practice to prevent accidentally exposing secrets, such as API keys, in a public repository?
Explanation: By keeping secrets in files excluded from version control, you avoid the risk of leaking them if the repository becomes public or shared. Committing secrets directly makes them immediately visible to all with access. Encrypting without proper key management or documenting passwords in plain text both pose major risks. Password protection alone does not prevent secrets in code from being exposed.
When a project uses several third-party dependencies, which practice best helps reduce the risk of including vulnerable components?
Explanation: Staying up to date ensures that any known security holes are patched quickly. Locking dependencies and neglecting updates leaves software vulnerable as threats emerge. Popularity does not guarantee security, and ignoring advisories can lead to undetected issues. Using unofficial sources increases risk as they can be tampered with or outdated.
If sensitive information is accidentally committed and pushed to a GitHub repository, which initial action should be taken?
Explanation: Sensitive data needs to be removed not just from the current code but from all historical commits where it appeared. Simply renaming a file does not erase its history. Proceeding without remediation leaves information exposed. Ignoring the issue can seriously compromise security and data privacy.
Why is enabling two-factor authentication (2FA) for all contributors considered an effective security measure on collaborative development platforms?
Explanation: 2FA requires users to provide a second factor, like a temporary code, in addition to their password, significantly increasing account security. Allowing multiple devices without checks weakens security. Disabling password requirements or granting unlimited access based on codes undermines identity protection and defeats the purpose of strong authentication.