Page MenuHomePhabricator

Add an `ArcanistChmodLinter`.
ClosedPublic

Authored by joshuaspence on May 18 2014, 10:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 10:55 AM
Unknown Object (File)
Fri, Nov 15, 11:00 AM
Unknown Object (File)
Mon, Nov 11, 1:06 AM
Unknown Object (File)
Thu, Nov 7, 8:38 AM
Unknown Object (File)
Sun, Oct 27, 3:12 PM
Unknown Object (File)
Sun, Oct 27, 1:36 PM
Unknown Object (File)
Oct 20 2024, 2:10 AM
Unknown Object (File)
Oct 19 2024, 11:19 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).