Skip to content

Owls 91448 - Prevent insecure file system warnings by ensuring files are at a minimum of umask 027 and handle Openshift platform. #2533

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

Merged
merged 16 commits into from
Sep 21, 2021

Conversation

ankedia
Copy link
Member

@ankedia ankedia commented Sep 13, 2021

  • Added a helm variable with name cloudPlatform to detect the Openshift platform.

  • For the default (not Openshift) platforms, this change makes sure that files in DOMAIN_HOME dir are at a minimum of umask 027. For this, it (a) restricts the execute permission for shell scripts to user-only, (b) removes group write and execute permissions on boot.properties and (c) preserves permissions when extracting the files from zip file.

  • For the operator running on OpenShift, this change adds a system property to WLS startup to disable umask 027 checks (all domain styles). For Model-in-image domain on Openshift, it also uses chmod -R g=u {domain home} to give group the same permission as the user for files in DOMAIN_HOME dir.

private static final List<String> RESERVED_NAMES = Arrays.asList(
DOMAIN_UID, DOMAIN_NAME, DOMAIN_HOME, NODEMGR_HOME, SERVER_NAME, SERVICE_NAME,
ADMIN_NAME, AS_SERVICE_NAME, ADMIN_PORT, ADMIN_PORT_SECURE, ADMIN_SERVER_PORT_SECURE,
LOG_HOME, SERVER_OUT_IN_POD_LOG, DATA_HOME, ACCESS_LOG_IN_LOG_HOME, DYNAMIC_CONFIG_OVERRIDE);
LOG_HOME, SERVER_OUT_IN_POD_LOG, DATA_HOME, ACCESS_LOG_IN_LOG_HOME, DYNAMIC_CONFIG_OVERRIDE, CLOUD_PLATFORM);
Copy link
Member

Choose a reason for hiding this comment

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

Is this going to cause operator upgrade rolling side effect ?

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe it will not cause the rolling side effect, I'll run the upgrade to confirm.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have verified that rolling doesn't happen during upgrade when kubernetesPlatform helm variable is not present. I add the KUBERNETES_PLATFORM environment variable to server pods only when kubernetesPlatform is set in the helm values.

if [[ ! -z ${CLOUD_PLATFORM} && ${CLOUD_PLATFORM} == "Openshift" ]]; then
# Operator running on Openshift platform - change file permissions in the DOMAIN_HOME dir to give
# group same permissions as user .
chmod -R g=u ${DOMAIN_HOME} || return 1
Copy link
Member

Choose a reason for hiding this comment

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

Should we also do it for non mii case? Or this is left as an exercise for the user when they create the domain?

Choose a reason for hiding this comment

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

@jshum2479

I originally suggested that we handle the non-MII cases, but I have a similar concern. In detail:

For one, a recursive file traversal of the entire domain-home seems like it could be prohibitively expensive, especially as it's done for every pod cycle.

For DII in particular, maybe this can this occur solely when the image is created (and be left up to the customer)?

And for DiPV, if we must do something automatic, can it be limited to occur only in the introspector, and, even then, only the first time the introspector sees the domain?

Copy link
Member

Choose a reason for hiding this comment

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

I agreed, doing it in the introspector (before zipping up the domain) is a better place. Do we really need -R or is the check only for bin directory?

Choose a reason for hiding this comment

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

Copy link
Member

@jshum2479 jshum2479 Sep 13, 2021

Choose a reason for hiding this comment

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

Also, have we explored doing it in WDT also, it won't solve existing domain or one created with older WDT though?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, one more question. Does the new was check provide any guidance on JKS keystore files? Best practice is user read only.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll set up a meeting to go over this. As per the requirements in JIRA OWLS-91448, we should NOT use chmod -R g=u for Model-in-image domain unless the environment is OpenShift. My understanding from JIRA was that, DII case will be handled in image tool and it's customers responsibility to do it for domain-on-pv.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have made the changes to perform the chmod -R g=u ${DOMAIN_HOME} in the introspector for model-in-image domain and to perform chmod -R g=u ${DOMAIN_HOME} in startServer.sh script for domain-home-in-image. My understanding is that we should not be doing chmod -R for the domain-on-pv domains since those changes will be persistent.

Copy link

@tbarnes-us tbarnes-us Sep 16, 2021

Choose a reason for hiding this comment

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

If the image tool is going to handle DII then why does startServer need to? (You wrote "DII case will be handled in image tool " and "I have made the changes to perform ... chmod -R g=u ${DOMAIN_HOME} in startServer.sh script for domain-home-in-image.")

Copy link
Member Author

Choose a reason for hiding this comment

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

My comment "DII case will be handled in the image tool" on 9/13 was based on my previous understanding. However, in the standup meeting discussion on Tuesday 9/14, Derek and Robert Patrick suggested to also do chmod -R u=g ${DOMAIN_HOME} for DII in the operator.

Copy link
Member

@russgold russgold left a comment

Choose a reason for hiding this comment

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

I see changes to two Java files, but no unit tests for those changes.
[ANIL]
Added following new unit tests in JobHelperTest.java and PodHelperTestBase.java -
whenOperatorHasKubernetesPlatformConfigured_introspectorPodSpecHasKubernetesPlatformEnvVariable
whenNotConfigured_KubernetesPlatform_introspectorPodSpecHasNoKubernetesPlatformEnvVariable
whenOperatorHasKubernetesPlatformConfigured_createdPodSpecContainerHasKubernetesPlatformEnvVariable
whenNotConfigured_KubernetesPlatform_createdPodSpecContainerHasNoKubernetesPlatformEnvVariable

@ankedia ankedia requested a review from mriccell September 16, 2021 18:55
@ankedia ankedia marked this pull request as ready for review September 17, 2021 13:41
@ankedia ankedia changed the title Owls 91448 - Prevent insecure file system warnings domain by ensuring files are at a minimum of umask 027 and handle Openshift platform. Owls 91448 - Prevent insecure file system warnings by ensuring files are at a minimum of umask 027 and handle Openshift platform. Sep 17, 2021
@@ -116,3 +116,6 @@ see [OpenShift]({{<relref "/userguide/platforms/environments#openshift">}}).
#### Using a dedicated namespace

When the user that installs an individual instance of the operator does not have the required privileges to create resources at the Kubernetes cluster level, a dedicated namespace can be used for the operator instance and all the WebLogic domains that it manages. For more details about the `dedicated` setting, please refer to [Operator Helm configuration values]({{< relref "/userguide/managing-operators/using-helm#operator-helm-configuration-values" >}}).

#### Set the Helm chart property `kubernetesPlatorm` to `OpenShift`
Beginning with operator version 4.0, set the operator `kubernetesPlatform` Helm chart property to `OpenShift`. This property accommodates OpenShift security requirements. For more information, see [Operator Helm configuration values]({{<relref "/userguide/managing-operators/using-helm#operator-helm-configuration-values">}}).
Copy link
Member

Choose a reason for hiding this comment

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

I think that we should backport this change to 3.3.2. @mriccell, do you agree?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to "Beginning with operator version 3.3.2".

This could be either the `anyuid` SCC or a custom one that you define for user/group `1000`. For more information, see [OpenShift]({{<relref "/security/openshift.md">}}) in the Security section.
To accommodate OpenShift security requirements:
- For security requirements to run WebLogic in OpenShift, see the [OpenShift chapter]({{<relref "/security/openshift.md">}}) in the Security section.
- Beginning with operator version 4.0, specify the `kubernetesPlatorm` Helm chart property with value `OpenShift`. For more information, see [Operator Helm configuration values]({{<relref "/userguide/managing-operators/using-helm#operator-helm-configuration-values">}}).
Copy link
Member

Choose a reason for hiding this comment

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

As above, I think that this change should go in to 3.3.2.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to "Beginning with operator version 3.3.2".

@ankedia ankedia requested a review from rjeberhard September 21, 2021 17:04
@rjeberhard rjeberhard merged commit a78f6b3 into main Sep 21, 2021
@ankedia ankedia deleted the owls_91448 branch September 22, 2021 17:11
ankedia added a commit that referenced this pull request Sep 22, 2021
…are at a minimum of umask 027 and handle Openshift platform. (#2533)

* Prevent insecure file system warnings by ensuring files are at a minimum of umask 027 and handle Openshift platform.
rjeberhard pushed a commit that referenced this pull request Sep 22, 2021
…are at a minimum of umask 027 and handle Openshift platform. (#2533) (#2543)

* Prevent insecure file system warnings by ensuring files are at a minimum of umask 027 and handle Openshift platform.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants