Page MenuHomePhabricator

Add an `ArcanistChmodLinter`.
ClosedPublic

Authored by joshuaspence on May 18 2014, 10:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 24, 10:29 PM
Unknown Object (File)
Apr 1 2024, 10:02 PM
Unknown Object (File)
Feb 18 2024, 9:51 PM
Unknown Object (File)
Jan 27 2024, 8:17 AM
Unknown Object (File)
Jan 16 2024, 8:44 PM
Unknown Object (File)
Dec 23 2023, 8:37 PM
Unknown Object (File)
Dec 22 2023, 3:28 AM
Unknown Object (File)
Dec 21 2023, 6:06 AM
Subscribers

Details

Reviewers
epriestley
Group Reviewers
Blessed Reviewers
Maniphest Tasks
Restricted Maniphest Task
Commits
rARC904fbe737ce5: Add an `ArcanistChmodLinter`.
Summary

Fixes T3922. Add a linter which complains if files are executable when they shoudn't be.

Test Plan

Tested by modifying the .arclint file of the rARC repository and running arc lint --everything.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

joshuaspence retitled this revision from to Add an `ArcanistChmodLinter`..
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
joshuaspence added a task: Restricted Maniphest Task.
src/lint/linter/ArcanistChmodLinter.php
49

Maybe we want to make a Filesystem::isExecutable function to use here.

79–88

This could be moved to libphutil possibly.

108–115

This list is probably incomplete... Also it seems strange to me that text/plain is required, but this is apparently the MIME type of ./bin/arc, which is obviously a valid executable.

Furthermore, in rP, bin/aphlict and support/aphlict/server/aphlict_launcher.php are both detected as being of MIME type 'text/x-c, which seems incorrect. Possible we could have some magic comment (like the vim modeline) which tells us what type of file this is.

Hmm, I worry that the getScriptMimeTypes() stuff is going to have like a billion false positives for all time, and generally that MIME type detection won't work well here.

What do you think about this instead?

  • Don't try to detect MIME types.
  • Assume real executables (binaries) will be covered by shouldLintBinaryFiles() already.
  • Just check for shebang on the first line of executable files.
  • If it's not present, raise "Unnecessary +x or missing shebang."

That sounds reasonable and probably catches 99% of what I had intended to catch.

joshuaspence edited edge metadata.
  • Don't try to detect MIME types.
  • Assume real executables (binaries) will be covered by shouldLintBinaryFiles() already.
  • Just check for shebang on the first line of executable files.
epriestley edited edge metadata.

Seems pretty reasonable, let's see if it holds up in practice. Thanks!

This revision is now accepted and ready to land.May 18 2014, 11:54 PM
epriestley updated this revision to Diff 21821.

Closed by commit rARC904fbe737ce5 (authored by @joshuaspence, committed by @epriestley).