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

TraceSecrets Don't Always Work #2122

Closed
BlythMeister opened this issue Oct 5, 2018 · 5 comments · Fixed by #2123
Closed

TraceSecrets Don't Always Work #2122

BlythMeister opened this issue Oct 5, 2018 · 5 comments · Fixed by #2123

Comments

@BlythMeister
Copy link
Contributor

Description

Text registered with a trace secret will print when opening and closing tags (and maybe other places)

Repro steps

Register a secret
Do a trace with a description containing the secret

Expected behavior

Secret doesn't show in console

Actual behavior

Secret does show

@matthid
Copy link
Member

matthid commented Oct 5, 2018

Secrets also will show when external processes print the secrets (and the output is not redirected) or if you use System.Console directly. It's not a perfect solution whatsoever. Can you give a small example snippet on what you mean?

@BlythMeister
Copy link
Contributor Author

The script

open Fake.Core

TraceSecrets.register "*******" "ThisIsASecret"

Trace.traceTask  "Testing" "ThisIsASecret" |> Trace.useWith true (fun _ -> Trace.logfn "does this print: ThisIsASecret" )

Will output

Starting task 'Testing': ThisIsASecret
does this print: *******
Finished (Success) 'Testing' in 00:00:00.0188163

So when using logfn the secret doesn't print (which is good)
When using trace, the secret does print

@matthid
Copy link
Member

matthid commented Oct 5, 2018

Agreed this could work. So the secret is part of a task-description, which is certainly unusual...

@BlythMeister
Copy link
Contributor Author

In my example, it's logging which environment variables being set.

So i have a collection of environment variables to set, and wrapper the setting in a trace which logs key and value.
I want the value for all except the secret ones to show.

actual code

[
          "FixedStructure", "true"
          "FixedPath", ""
          "Environment", "INT"
          "ClientCode", "BUILD"
          "DeployService", "http://na.com"
          "EnsconceDir", @"D:\Ensconce\V1"
          "DbUser", "DBuser"
          "DbPassword", "DBPassword"
          "DbServer", "(local)"
        ]
        |> List.iter (fun (name, value) -> (Trace.traceTask "Set environment variable" (sprintf "key: %s | value: %s" name value) |> Trace.useWith true (fun _ -> Environment.setEnvironVar name value)))

where DBPassword has been set as a secret earlier in the script.

@BlythMeister
Copy link
Contributor Author

another completely contrived example to show different behaviour for outputting secrets:

open Fake.Core
open Fake.Core.TargetOperators

TraceSecrets.register "*******" "ThisIsASecret"

Target.description "ThisIsASecret"
Target.create "ThisIsASecret" (fun (_:TargetParameter) ->
    Trace.traceTask  "ThisIsASecret" "ThisIsASecret" |> Trace.useWith true (fun _ -> Trace.logfn "does this print: ThisIsASecret" )
)
    
Target.create "Default" ignore
    
"ThisIsASecret" ==> "Default"

Target.run 0 "Default" []

outputs

run Default
Building project with version: LocalBuild
Shortened DependencyGraph for Target Default:
<== Default
<== *******

The running order is:
Group - 1


Group - 2

  • Default
    Starting target 'ThisIsASecret': ThisIsASecret
    Starting task 'ThisIsASecret': ThisIsASecret
    does this print: *******
    Finished (Success) 'ThisIsASecret' in 00:00:00.0041784
    Finished (Success) 'ThisIsASecret' in 00:00:00.0964323
    Starting target 'Default'
    Finished (Success) 'Default' in 00:00:00.0006130

Build Time Report

Target Duration


******* 00:00:00.0915413
Default 00:00:00.0000499
Total: 00:00:00.2397017
Status: Ok

i'll have a look to see if i can fix this :)

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

Successfully merging a pull request may close this issue.

2 participants