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

Remove instances of hard admin credentials #981

Merged
merged 8 commits into from
Jan 10, 2024

Conversation

derek-ho
Copy link
Contributor

@derek-ho derek-ho commented Dec 21, 2023

Description

In 3.0.0 and backported to 2.12.0 release is a change where security demo configuration requires an initial admin password to be passed in on setup. This PR does that.

Issues Resolved

[List any issues this PR will resolve]

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@derek-ho
Copy link
Contributor Author

Can somebody add backport 2.x label?

@derek-ho
Copy link
Contributor Author

Can somebody review my deletion of integtest.sh file? Is that unused in this repo? The idea is coming from: opensearch-project/opensearch-build#497, in which it seems this file should have been migrated to build repo. Additionally it contains reference to admin:admin so I removed it, but can bring it back if that's wrong/is actively being used by this repo somehow.

Signed-off-by: Derek Ho <[email protected]>
@@ -62,8 +62,8 @@ jobs:
else
echo "Keep OpenSearch Security"
nohup ./opensearch-windows-install.bat &
timeout 900 bash -c 'while [[ "$(curl -o /dev/null -w ''%{http_code}'' -u admin:admin -k https://localhost:9200)" != "200" ]]; do echo sleeping 5; sleep 5; done'
curl -sk https://localhost:9200/_cluster/health?pretty -u admin:admin
timeout 900 bash -c 'while [[ "$(curl -o /dev/null -w ''%{http_code}'' -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k https://localhost:9200)" != "200" ]]; do echo sleeping 5; sleep 5; done'
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems that env.OPENSEARCH_INITIAL_ADMIN_PASSWORD is not defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I was accidentally editing a backport branch, fixed now

@Hailong-am
Copy link
Collaborator

#978

Signed-off-by: Derek Ho <[email protected]>
Copy link
Member

@kavilla kavilla Dec 21, 2023

Choose a reason for hiding this comment

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

whoops. this is the one jenkins executes.

source

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. I found this: https://github.com/opensearch-project/opensearch-build/blob/f92f571a42eecfc3279c217c5bd53922517054d0/scripts/components/functionalTestDashboards/build.sh. I will revert this deletion. @kavilla can you help me understand what/if any changes need to be made in integtest.sh in terms of the admin:admin credentials? I feel like there is some assumption about the setup of the OpenSearch backend that FTR would be running against, but I don't know where that is setup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yeah that line just need to replace it with admin:urnewpassword if that is the expected password. basically the integtest.sh script gets executed after an OpenSearch and OpenSearch Dashboards of the same version and successful builds get scaled up. Then Jenkins will clone this repo and execute integtest.sh. So as long as you change that password in integtest.sh it will be the credential passed when the tests are executed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have any idea about where those successful builds are generated? It seems like less work to modify that place to get spun up with admin:admin, so none of the component integtest.sh need to be changed.

Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

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

integtest.sh

@SuZhou-Joe
Copy link
Member

#982 for checking if all tests run successfully if security enabled.

@SuZhou-Joe
Copy link
Member

@derek-ho seems the OSD in main fails to launch according to #982 , do you know who we can ask to take a look?

@derek-ho
Copy link
Contributor Author

@kavilla @SuZhou-Joe can you take another look? Added logic to handle the logic of 2.12.0 release and onwards.

@derek-ho
Copy link
Contributor Author

@derek-ho seems the OSD in main fails to launch according to #982 , do you know who we can ask to take a look?

Let me check this

@SuZhou-Joe
Copy link
Member

@kavilla @SuZhou-Joe can you take another look? Added logic to handle the logic of 2.12.0 release and onwards.

LGTM

Signed-off-by: Derek Ho <[email protected]>
@SuZhou-Joe
Copy link
Member

@kavilla , could you please take a look on this PR and unblock the requested change if it looks good to you?

integtest.sh Outdated
USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'`
PASSWORD=`echo $CREDENTIAL | awk -F ':' '{print $2}'`
# Starting in 2.12.0, security demo configuration script requires an initial admin password
if (( ${version_array[0]} > 2 || (${version_array[0]} == 2 && ${version_array[1]} >= 12) )); then
Copy link
Member

Choose a reason for hiding this comment

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

imo i dont think this need. I'm not positive if version is being passed I can check but ideally. This file will be checked out via branches or tags. So since this is on main and main is expected to 3.0.0. Which just need to make sure we backport this to 2.x then it's in the 2.12 release branch. And then dont backport any further.

One other thing is I'm not positive how this password gets set. So when the integration tests get ran they get executed after the cluster is started.

Originally this takes from an environment variable that needs to be set pre opensearch-tar-install is that correct?

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 am not sure. I asked this question in a comment in a PR in the build repo. However, this seems plausible to me. I think in the build repo the default one is used on all branches so we need to add that logic there. I removed it for now, pending confirmation from build team that this would be checked out per branch.

@derek-ho
Copy link
Contributor Author

derek-ho commented Jan 9, 2024

@kavilla can you re-review and merge if it looks good? I applied your suggestions and this seems to be blocking a few other PRs and workflows, thanks!

@kavilla kavilla self-requested a review January 10, 2024 17:56
@kavilla kavilla merged commit 8391566 into opensearch-project:main Jan 10, 2024
36 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 10, 2024
* Remove instances of hard admin credentials

opensearch-project/opensearch-build#4302

Signed-off-by: Derek Ho <[email protected]>
(cherry picked from commit 8391566)
ruanyl pushed a commit that referenced this pull request Jan 11, 2024
* Remove instances of hard admin credentials

opensearch-project/opensearch-build#4302

Signed-off-by: Derek Ho <[email protected]>
(cherry picked from commit 8391566)

Co-authored-by: Derek Ho <[email protected]>
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.

4 participants