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

(PUP-11429) Make split() sensitive-aware #8858

Merged
merged 1 commit into from
Oct 5, 2023

Conversation

cocker-cc
Copy link
Contributor

@cocker-cc cocker-cc requested a review from a team January 18, 2022 10:11
@cocker-cc cocker-cc requested a review from a team as a code owner January 18, 2022 10:11
@cocker-cc cocker-cc requested a review from a team January 18, 2022 10:11
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch 2 times, most recently from 193d458 to 0303709 Compare January 21, 2022 01:08
@CLAassistant
Copy link

CLAassistant commented Feb 7, 2022

CLA assistant check
All committers have signed the CLA.

@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from 0303709 to 08ed5cd Compare February 7, 2022 19:02
@joshcooper
Copy link
Contributor

@cocker-cc can you rebase your PR on d2ae297, it has fixes for the unrelated Ruby 3 failures.

@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from 08ed5cd to ab46fc0 Compare February 23, 2022 09:50
@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from ab46fc0 to f8f1811 Compare April 14, 2022 21:00
@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from f8f1811 to d78552d Compare July 23, 2022 10:18
@joshcooper joshcooper closed this Aug 24, 2022
@joshcooper joshcooper reopened this Aug 24, 2022
@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from d78552d to 42211b6 Compare August 30, 2022 11:33
@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from 42211b6 to e48e2b3 Compare October 17, 2022 11:58
@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from e48e2b3 to 83d306b Compare April 21, 2023 12:40
@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from 83d306b to 94baaf0 Compare June 19, 2023 12:15
@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from 94baaf0 to 8950b94 Compare August 4, 2023 11:29
@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from 8950b94 to 05ac1a5 Compare September 20, 2023 11:05
@joshcooper
Copy link
Contributor

jenkins please test this with server tests

param 'Sensitive[String]', :sensitive
param 'Type[Regexp]', :pattern
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry coming back to this after some time. I'm thinking we need to preserve the sensitive-ness of the returned values like we did in 10724d7, otherwise, the sensitive data may lose its sensitive-ness and end up in a log file.

I think we want to add return_type 'Sensitive[Array[String]]' for each dispatch and then for each split_*_sensitive method wrap the result back in Sensitive. For example something like:

def split_String_sensitive(sensitive, pattern)
  wrap(split_String(sensitive.unwrap, pattern))
end

def wrap(array)
  Puppet::Pops::Types::PSensitiveType::Sensitive.new(array)
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we need to preserve the sensitive-ness of the returned values like we did in [10724d7]

My main Goal with all my many PRs concearning Sensitive is, that the Enduser should have to deal with the Subject Sensitive as little as possible.
Enduser: “I have a String, which I want to split. It may be Sensitive, but I don't really know. So please, split, take care of it by yourself.”
Following your Example, the Result could be a Sensitive[Array[String]] (unusual enough) and the Enduser would not be able to f.e.:

$mystring2 = $mystring1.split(' ').join('_')

because join does not yet accept a Sensitive[Array[String]], and as long as this is the Case with join and many other Functions, I do not agree to your Proposal.

epp() returning a Sensitive[String] in your linked Commit works flawless, only because file already knows by itself how to deal with Sensitive[String], and the Enduser does not have to care. Perfect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cocker-cc I understand why you're not wanting to modify functions to accept Sensitive, but the current state is Sensitive is its own data type, it's not an attribute of a String, etc. See @hlindberg comments in https://puppet.atlassian.net/browse/PUP-10092?focusedCommentId=75281 about why this is true. Therefore, the function must be updated to explicitly accept a Sensitive value.

Also from a security standpoint, we don't want the split function to have the side effect of automatically typecasting the Sensitive value to Array[String]. That is a security footgun and it will leak into logs, reports and puppetdb.

I think it's reasonable for join to accept an array where some of the elements may be Sensitive, and if so, wrap the resulting array in Sensitive. That way Sensitive values round trip correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's reasonable for join to accept an array where some of the elements may be Sensitive,
and if so, wrap the resulting array in Sensitive. That way Sensitive values round trip correctly.

This is exactly, what I am saying. But until then…
And apart from join there are several other Functions to educate 😃

In one of my PRs I introduced here an additional Parameter to let the Enduser decide, if the Returnvalue should be sensitive. Could this perhaps be an option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay – I am conviced. Returning Sensitive (like epp() does) hands over the Responsibility to handle Sensitive correctly to the next Function.
I adopted your suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great, thanks @cocker-cc! Also for the future, what built in functions do you think should accept Sensitive but don't currently? Sounds like join should accept it, any others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For regsubst() I have an open PR
Those related to Passwords, f.e. length, chomp, …

@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from 05ac1a5 to 3f0a04c Compare October 4, 2023 23:25
Let split() accept Values of Type Sensitive.
In this Case the Returnvalue will also be of Type Sensitive.
@cocker-cc cocker-cc force-pushed the Make_split_sensitive-aware branch from 3f0a04c to 940db71 Compare October 4, 2023 23:28
@joshcooper joshcooper merged commit 80226e9 into puppetlabs:main Oct 5, 2023
9 checks passed
@joshcooper
Copy link
Contributor

Backport to 7.x #9118

@cocker-cc cocker-cc deleted the Make_split_sensitive-aware branch June 13, 2024 20:05
@joshcooper joshcooper added the enhancement New feature or request label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants