Repository navigation
feat: strengthen secret redaction to handle split secrets. - #4398
Conversation
86d50df to
5f1497a
Compare
5f1497a to
9852072
Compare
9852072 to
f0e324d
Compare
f0e324d to
8b4b0d9
Compare
vito
left a comment
There was a problem hiding this comment.
(Sorry for the delay, back from another short vacation.)
This is great so far! I did some local testing on this and it seems to work well, even for vars that are cut into separate chunks and not lines (I forced this to happen with some strategic sleeps): https://gist.github.com/vito/4b05b65fac9c2e53d8fe8660945158ad
I don't really follow the stdout vs. stderr changes though. 😕 Why do we treat them any differently? Shouldn't we just redact on both? Why is it necessary to direct the resource's output to stdout when really it's printed on stderr?
I suspect it'd be common for stderr to accidentally have secrets printed from a task. bash -x for example will print out commands taking secrets as arguments, and the trace lines normally go to stderr. For some reason the trace logs seem to end up going to stdout though which doesn't match real-world behavior. I wonder where that's happening? It causes the 'stdout' stream to get interspersed with the trace output and prevented the redaction in this case:
Granted, this is an unrealistic scenario (users probably won't be literally echoing chunks as separate commands in their scripts). Maybe I'll open a separate issue for stderr getting munged into stdout. It seems to be the case on master too. 🤔
|
@vito wrt stdout/stderr, my idea is to make put/get/task consistent. There are two types of step ouput: I feel it would be helpful if we set a principle that type1 going to log-event(stderr) and type2 going to log-event(stdout). This way, though we mix stdout and stderr from task, I don't think it is a problem because users only build logs from GUI. Comparing to mixing concourse output with task's stderr, I believe mixing task's stdout&stderr is better. The principle will also benefit future data analysis, because log-event(stdout) is system log and log-event(stderr) is user log. Back to this PR, redacting secrets is CPU costly. A single line of "pulling ======== xx MB" showing on GUI is actually a lot of log writes, but they should not go through redaction process at all. Only user log holds risk of leaking secrets. With distinct system log and user log, we only do redaction against user log, so that it saves a lot of CPU resource. |
|
@evanchaoli 🤔 That seems like a separate problem from the goals of this PR. It sounds like you want a way to separate the image fetching output from the task's output. I agree with that but I don't think it should be done by messing with and changing the meaning of Right now resources must use At this point resource type authors (prototype authors?) will be able to print logs like normal, and it would be confusing to find upon inspection that your logs are somehow getting changed to Similarly, it would be confusing to me if my task which prints to IMO we should just filter both streams regardless. Intuitively, both are just as likely to contain credentials: I totally agree that it would be nice to be able to distinguish image fetching output from task output. I'd like to see it render differently in the UI, even. But I think that's a topic for a separate PR/issue, and I think it should be done in some other way so that |
|
@vito Time difference really slows down our communication [Facepalm]. I agree one PR should focus on a single issue, which is a rule we are following in our daily development. But here for this PR, I want to distinguish image fetching output from task (actually including put/get steps) output is to make the redaction feature more efficient. Now, there are already some confusion to resource type author and pipeline author:
If we clearly state in documentation that like "output step's output going to log-event(stdiout)", I guess it should be ok to resource type author and pipeline author, as they anyway has no way to view stdout and stderr differently. If we want to distinguish sys output (image fetch etc), and step's stdout/stderr, I think only way is to introduce a third log-event source, say "sys", other than "stdout" and "stderr". This can be together with the "protocol" feature. But I guess it will take some time to get the "prototype" feature released. How about this way that let's open an issue on me, once the "prototype" feature is merged (before released), get/put get able to print to stdout, sys log, step's stdout and stderr are all distinguished, I can make a PR to add redaction back to stderr. So that now we can benefit improvement of redaction efficiency, and we won't forget to add redaction to stderr in future. I don't see I would move off my current project in short term, so I can promise to follow up the issue. |
|
@evanchaoli Yeah the timezone difference is a bit rough. I'll try to reply earlier in the mornings so there's a little more overlap (though it's hard to make a 12hr difference work either way lol). Thanks for being patient. Let me try to summarize my thoughts on this:
I'm still in support of being able to distinguish image fetching logs from task output, which could be done by adding another field to the event origin to differentiate its stdio from the step's stdio: Lines 100 to 103 in 7e41cf6 ...but this should probably be a separate PR since it'll involve more components (i.e. the web UI). Does this make sense? 😅 |
|
@vito OK, this is a good discussion. Let's move things forward. I can easily remove the stdout/stderr related changes. Just to confirm with you, if I update the PR by your Monday morning, is it possible to include this PR in 5.6? I wish to have a full functional redaction feature in 5.6. |
Resolve concourse#4389 Signed-off-by: Chao Li <[email protected]>
8b4b0d9 to
2e8496a
Compare
|
@vito I have deleted stdout/stderr related changes, and now redacting on both stdout and stderr. Tests are updated accordingly. Please take a look again. Thanks a lot. |
|
@vito Thank you so much for including this in 5.6. |

Resolve #4389
Highlights:
Close()method todbEventWriter, because as we normalize log lines, if don't close a writer, then the last line might be lost.get/put's user logs are redirected to stdout. So that we only do redaction on stdout.The following screen shot shows my test result:

In this test, I managed to generate a 20K-line build log with some secrets embedded including multiple line secrets. As we can see, all secrets are redacted, and multiple secrets are redacted at line level.