Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file-nullbyte messes up terminal (when run against binary files?) #14

Open
kbabioch opened this issue Apr 30, 2020 · 3 comments
Open

file-nullbyte messes up terminal (when run against binary files?) #14

kbabioch opened this issue Apr 30, 2020 · 3 comments

Comments

@kbabioch
Copy link
Contributor

The file-nullbyte check seems to mess up terminals. I've checked it on multiple *nix machines (Linux, macOS) and the terminals are only showing "weird" characters and/or behave strangely, after the following command is run:

docker run --rm -v $(pwd):/data cytopia/file-lint file-nullbyte --path .

$(pwd) is the checked out repository, and contains some binary files inside the .git/ directory

The result looks something like this:

W7Om,ҧ)ӘG2
R2        iG:U!%{|=7h>r$rCzيZWbnڒ0[~`ٻ@|?B屙QlW`/UA=~F};aL_ٚ1xmIo@Mܬ
m99φiXn t?0LӚbΤy`QV(oWiƯk0vUpC6`yn]s_I+}R*g\7r3A@B{<lkuH5nY?$ebxjbBxiX9MyCgm5؈c$1qP&uQUF        xYÙx</JNI?6,D"(A(r)N<
                                                                            r$R%T-@&^(~%Yk175,c1omiwziìĿXC7;zgY6co<
                                                                                                                   fwSXSdme^Z(NЉ*lw]Tl3
                                                                                                                                       g<k..NL(K)hv9&5տlX9=-k
W3~?lwKzBwEP?Wipx|4q.YF1~K93e36ef28bb545f9c4650c7f13ce2f59b442180.pack:|* #*-2Ds*2E%к<  d_xږGՕYSOb9'YIz9sU_~^ @wYdrҴ:x/U5ӧHtYaYbNla|0m쇷k7XYpi1;
                          *h#!o<Ov6thOQ]&r5Sk$wɄ_N>VSh"ldRD@nt?|hk]fi7Li9(i؄TP
                                                                             k,ć|9g4}w0
                                                                                       nrua,
;r͎¨rvz֍Ki+d瑿AAeOV\cp?Z,<*f{woYvMSTytVnZ*                                                   F9W_̲D037웨5yi{:0~PgBӌĥ-]w˷z         ەG3L:#;@X*
                                         :i6bp?%XF?R    ѮCSa8[fOga1xmKs@ڣ"Hb}dOSWW35UNTE
./.git/objects/pack/pack-693e36ef28bb545f9c4650c7f13ce2f59b442180.pack:BrR1Ρ$AEgͤyLi(UXIDDAD!%5S          CAMV   !PCrOC<34EU'
qsɽM)epKũ                                                                                                                   U@ ⶮa`XŰ)xlZκjzΊ!,벾2Lo -OE[O.\z#6tXz`/Ѥbk8j^׳'k^؍fgOv
./.git/objects/pack/pack-693e36ef28bb545f9c4650c7f13ce2f59b442180.pack:c2ljxvPAMyFX
vIDu]E\S'v SAHSەB,%;3mSUU䡝<5s
                              f#G9duyu4}|JdS6-Ox_oT_6g
                                                      tcUN#M)oHڸUq
                                                                  %I~XDxSˮFQk#6e

                                                                                |}dUzUV]dƀ)b
./.git/objects/pack/pack-693e36ef28bb545f9c4650c7f13ce2f59b442180.pack:3
LkftbFPpHx54H}/pack/pack-693e36ef28bb545f9c4650c7f13ce2f59b442180.pack:-+z\gָ| y(Bdr\[k8'c9(yt;Umc

The terminal needs to be reset afterwards.

The example snippet for this check looks like this:

# file-crlf
FILE_NULLBYTE_EXTENSION=""
FILE_NULLBYTE_IGNORE=".git,*.svn,*.pyc"
FILE_NULLBYTE_TEXT=0
FILE_NULLBYTE_SIZE=1

This results in binary files being scanned.

Now I'm wondering:

  • Is it a good idea to run this check against binary files in the first place?
  • Why is it messing up the terminal? This should not happen, regardless of whether binary files are involved or not.
@cytopia
Copy link
Owner

cytopia commented Apr 30, 2020

Scanning all files in the path is the default behaviour to be consistent with all included checks. To circumvent this you can explicitly use the argument --text to ignore all binary files.

@kbabioch
Copy link
Contributor Author

Having this as default is fine (with me), but at least the example in the README.md should have FILE_NULLBYTE_TEXT set to 1.

Furthermore the check itself should still not cause errors and mis-configure the terminal. So I would still consider this to be a bug :-).

kbabioch added a commit to kbabioch/docker-file-lint that referenced this issue Apr 30, 2020
…iles

This updates the recommended / suggested configuration file presented in
the `README.md` file, so that `file-nullbyte` is only searching text
files by default (`FILE_NULLBYTE_TEXT=0).

Searching binary files for null bytes (`NUL`) makes not too much sense,
since it will regularly find such files, and it is perfectly fine for
them to contain these bytes.

This addresses one aspect of an issue with searching binary files with
this particular file check (documented in cytopia#14).
@kbabioch
Copy link
Contributor Author

I've prepared a change in #15 to change the README.md accordingly. This addresses the documentation aspect, but does NOT fix the bug itself :-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants