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

extra bytes prepended to (esp. json) output from santactl fileinfo ... --key <path> can be dropped? #112

Closed
arubdesu opened this issue Oct 10, 2016 · 3 comments
Assignees
Milestone

Comments

@arubdesu
Copy link
Contributor

arubdesu commented Oct 10, 2016

I noticed that I'm getting extra bytes in the front of a string outputted from fileinfo's --key flag, and the inimitable @pudquick figured out it was in the color codes embedded in it. It definitely shouldn't be in there for json output, but I'd not expect colored output to be particularly useful for values returned with --key, either - more pressing is trying to use the python json module to .loads the value wasn't working for me.

@tburgin tburgin self-assigned this Oct 10, 2016
@russellhancox
Copy link
Collaborator

It definitely shouldn't be in there for json output

It isn't?

santactl fileinfo --json --key Rule /usr/bin/yes
{
  "Rule" : "Blacklisted"
}

@arubdesu
Copy link
Contributor Author

Au contraire mon frère, to my chagrin

#!/usr/bin/python
import json
import subprocess

path = "/Applications/WWDC.app"
cmd = ["/usr/local/bin/santactl", "fileinfo", "--cert-index", "1", "--key", "SHA-256", "--json",
       path]
output = subprocess.check_output(cmd)
with open("/tmp/jsony_output", 'wb') as outfile:
    outfile.write(output)

screenshot 2016-10-10 17 12 17

@russellhancox
Copy link
Collaborator

Aha: [2K is not a color code, it's the sequence for clear line. It's the only escape sequence I can see that isn't checking for JSON output or the presence of a TTY.

Tom's fixing now.

@arubdesu arubdesu changed the title Color codes in (esp. json) output from santactl fileinfo ... --key <path> can be dropped? extra bytes prepended to (esp. json) output from santactl fileinfo ... --key <path> can be dropped? Oct 11, 2016
@tburgin tburgin closed this as completed Oct 12, 2016
@tburgin tburgin added this to the 0.9.14 milestone Oct 12, 2016
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

3 participants