-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
(PUP-11429) Make split() sensitive-aware #8858
Conversation
Can one of the admins verify this patch? |
193d458
to
0303709
Compare
0303709
to
08ed5cd
Compare
@cocker-cc can you rebase your PR on d2ae297, it has fixes for the unrelated Ruby 3 failures. |
08ed5cd
to
ab46fc0
Compare
ab46fc0
to
f8f1811
Compare
f8f1811
to
d78552d
Compare
d78552d
to
42211b6
Compare
42211b6
to
e48e2b3
Compare
e48e2b3
to
83d306b
Compare
83d306b
to
94baaf0
Compare
94baaf0
to
8950b94
Compare
8950b94
to
05ac1a5
Compare
jenkins please test this with server tests |
param 'Sensitive[String]', :sensitive | ||
param 'Type[Regexp]', :pattern | ||
end | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
, …
05ac1a5
to
3f0a04c
Compare
Let split() accept Values of Type Sensitive. In this Case the Returnvalue will also be of Type Sensitive.
3f0a04c
to
940db71
Compare
Backport to 7.x #9118 |
PUP-11429