Skip to content

Comments

HDDS-10604. Whitelist based compliance check for crypto related configuration options#6860

Merged
fapifta merged 19 commits intoapache:masterfrom
dombizita:HDDS-10604
Jul 12, 2024
Merged

HDDS-10604. Whitelist based compliance check for crypto related configuration options#6860
fapifta merged 19 commits intoapache:masterfrom
dombizita:HDDS-10604

Conversation

@dombizita
Copy link
Contributor

@dombizita dombizita commented Jun 24, 2024

What changes were proposed in this pull request?

The goal of this is change is that whenever we ask for a configuration option's value, we are ensuring to do the necessary compliance checks.

In Ozone we have:

  • OzoneConfiguration class, which extends the Hadoop's Configuration class. It also implements the MutableConfigurationSource Ozone interface.
  • LegacyHadoopConfigurationSource (Configuration source to wrap Hadoop Configuration object), which also implements MutableConfigurationSource. This has a Configuration field, which is used to get configuration options.
  • InMemoryConfiguration, which is only used for testing, so I didn't change anything there.

I went through the code and checked how do we get configs. Overall we want to ensure if we get any config property, the compliance check went through before returning them. To make this happen, we only need to make sure that the Configuration#getProps method gives us a Properties object back, thats getProperty method does the compliance check. I created a DelegatingProperties helper class, so we'll delegate the operations to the parent's properties and also do the compliance check in the getProperty. I also added the compliance check to the Properties iterator(), as with that we can access the properties values without calling the getProperty() method.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-10604

How was this patch tested?

Added unit tests, CI: https://github.com/dombizita/ozone/actions/runs/9645109413

dombizita added 10 commits June 13, 2024 00:39
…ionSource

Change-Id: Ib6ff17f7ad48e43f9e69cebf5a25859e29f133d6
Change-Id: I9695dae13b90ed798a159d9a2abae15d7702a56f
Change-Id: I0a8a8328056b8b3879cdb4e202a693242812aa06
Change-Id: Ib385f3ac64d459e40549161e85c6c3408ed0e681
Change-Id: I6f21a2f7bca52cc766f4e7869749b8857a01fb35
Change-Id: I0c5606e846010b850f2ebb7bbf59e1a2e24bea16
Change-Id: Ia0fa7e22c3a70f9e09ff680110e0da7dad095e8f
Change-Id: I7a19bb73ed0b3dcb7da2481ce08e697863344ed2
…onfigurationSource.

Change-Id: Ic3d66056f3a99b12b790346111e8128b8783c26b
Change-Id: I2e92d45508666d98eb4e7c607c04fa56fcae92b0
Copy link
Contributor

@fapifta fapifta left a comment

Choose a reason for hiding this comment

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

Thank you for your work on this one @dombizita!

I know we have looked at problems arose in CI runs together, but now as I look at the changes altogether a few things I realized, please find my comments inline with a few suggestions/question/ideas.

dombizita added 8 commits July 8, 2024 22:34
Change-Id: I7969ce285caae7d4206c867ef196588ca7b4dd98
Change-Id: Id9b6d613eebf1ceefe981fa15138e3a8fbe9d617
Change-Id: If1f8c5685a69b9ea5ddc711317f28b919e127891
Change-Id: Id09e59492a43e0c23c1a9324b1fa8496fdc872a1
Change-Id: Ib05465d46789d455176acff6f3e58fe8ab1b9c9e
Change-Id: If2596dbb206a56a26a3b10ecea697faf2a902fc4
Change-Id: I909c37f15008409511df134c06206df560d70c0c
Change-Id: I7fc507671df1a1f2cae12433ae894d4d7f8522b6
@dombizita
Copy link
Contributor Author

With the recent changes I added, when we call the entrySet() method in the DelegatingProperties class it throws UnsupportedOperationException. The goal with this is that we can't get values from its Properties object without the compliance check. I thought that the entrySet is only used in the iterator() method (which I handle in the DelegatingProperties class), but from the failures we see that in the Configuration class we use it elsewhere too, e.g. in the getValByRegex() method.

Error:  Tests run: 6, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.654 s <<< FAILURE! - in org.apache.hadoop.hdds.TestHddsUtils
Error:  org.apache.hadoop.hdds.TestHddsUtils.testRedactSensitivePropsForLogging  Time elapsed: 0.015 s  <<< ERROR!
java.lang.UnsupportedOperationException: Entryset is not available in DelegatingProperties
	at org.apache.hadoop.hdds.conf.DelegatingProperties.entrySet(DelegatingProperties.java:165)
	at org.apache.hadoop.conf.Configuration.getValByRegex(Configuration.java:3935)
	at org.apache.hadoop.hdds.conf.OzoneConfiguration.getOzoneProperties(OzoneConfiguration.java:281)
	at org.apache.hadoop.hdds.HddsUtils.processForLogging(HddsUtils.java:792)
	at org.apache.hadoop.hdds.TestHddsUtils.testRedactSensitivePropsForLogging(TestHddsUtils.java:256)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

I'll look into this later.

@dombizita
Copy link
Contributor Author

dombizita commented Jul 10, 2024

I checked where do we use the entrySet() method in the Configuration class on its Properties (I didn't find usages in other configuration related classes). These are the occurrences:

  • iterator() - it's handled as we overwrite the iterator() method in both the OzoneConfiguration and the LegacyHadoopConfigurationSource classes
  • overlay() - we are just putting everything form one Properties object to another Properties object. This shouldn't cause problems, as later when we read from them we will do the compliance check
  • dumpConfiguration() - it doesn't call the getValue() on the entrySet element, shouldn't be a problem
  • write() - this will call the item.getValue(), but it will only write it out to a DataOutput, so once we read from this, we will do the compliance check
  • getValByRegex() - we are calling the item.getValue(), bust we are only checking if it's a String, we don't do anything else with it. Later when we are returning with the key value map, we are getting the value with this call substituteVars(getProps().getProperty(item)) where the item is the key name.

Based on this, we can say that the only occurrence where we are actually doing something with a configuration value that we got through a props.entrySet() call is handled. But because of the other usages I can't throw an UnsupportedOperationException. I update my patch, so I can see a better CI run, based on the ongoing review I can change it later.

…et() call

Change-Id: I313db78e455b78e0a6efaef4334a122eeee5e420
Copy link
Contributor

@fapifta fapifta left a comment

Choose a reason for hiding this comment

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

Thank you @dombizita for going after all the possible cases where we use the entryset, and also to summarize it here. It is really pleasant to look at the change overall as it became elegant and simple at the end of the day, so even it took some time, I think it does worth it looking at what we have now.

@fapifta fapifta merged commit c768815 into apache:master Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants