Temporary / Dynamically Creating Sensitive Values for Masking

I’m just wondering if there is any way to temporarily create a sensitive value for the purpose of masking any further logging of the value in subsequent steps.

My specific requirement is that I have a common C# script step template which is running as the first step which is responsible for handling Authorization in to a web service. This step template will set an output variable which contains the Authorization header which subsequent steps will consume and use. This will be in the scheme of either Basic or Bearer depending on the environment.

If we focus on just the Basic scheme, I will need to take a password (which is already sensitive) and Base64 encode it (which is not sensitive or masked.)

I want to be able to log out the authorization header value in subsequent steps to ensure that it’s successfully retrieved the correct header, but I don’t want to log out the password.

e.g. I would want my log output to include the scheme and username, which would look something like this “Basic dXNlcm5hbWU6*******”

Hi @joedm,

Thanks for getting in touch! I think what you’re after would be to mark your output variables as sensitive. You can do this by appending your Set-OctopusVariable with -sensitive. This is for use in PowerShell, and we have examples using C#, Bash, etc. in the following doc page.

This would mark the whole variable being created as sensitive, and your example seems to indicate that you want part of the variable being masked which unfortunately I don’t think would be possible.

I hope this helps get you going! Let me know if you have any further questions going forward. :slight_smile:

Best regards,

Kenny

Thanks @Kenneth_Bates

It looks like exactly what I am looking for.

I will create an additional output variable with the Base64 encoded password and mark this new output variable as sensitive. Then theoretically even if I never use the output variable again, it should automatically mask the password portion of the full Authorization value.

Hi @joedm,

You’re very welcome. Great to hear that should help! Don’t hesitate to reach out if you have any questions or concerns in the future. :slight_smile:

Best regards,

Kenny

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.