QuestionQ97

DevSecOps Pipeline-Code Stage

Elizabeth Moss works as a DevSecOps engineer for an IT company based in San Diego, California. Because of AWS's strong security and cost-effective services, her organization migrated all workloads from on-premises to AWS in 2017.

Elizabeth wants to prevent AWS keys from being committed into repositories, so she performed the following steps:

  • Created a global git-templates directory from the command line
  • Inside it, created another directory named hooks
  • Inside the hooks directory, created a file named pre-commit
  • Pasted into the pre-commit file a script designed to prevent AWS keys from being committed into repositories

She now needs to make sure that the pre-commit hook is executable.

Which command should Elizabeth run to make the pre-commit hook executable?

  • A chmod a+e ~/.hooks/git-templates/pre-commit
  • B chmod a+e ~/.git-templates/hooks/pre-commit
  • C chmod a+x ~/.git-templates/hooks/pre-commit
  • D chmod a+x ~/.hooks/git-templates/pre-commit
Explanation

In Unix-like systems, file permissions are granted using chmod with the flags r (read), w (write), and x (execute) — there is no 'e' permission flag, so any command using 'a+e' is invalid syntax and will not work as intended. To make a script executable, the correct flag is 'x' (e.g., a+x, which grants execute permission to all users). Additionally, based on the directory structure Elizabeth created — a global git-templates directory containing a hooks subdirectory, which in turn contains the pre-commit file — the correct file path is ~/.git-templates/hooks/pre-commit. Combining the correct permission flag with the correct path yields: chmod a+x ~/.git-templates/hooks/pre-commit.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!