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

ROX-12569 Change local-sensor cluster id #3127

Merged
merged 3 commits into from Sep 23, 2022

Conversation

lvalerom
Copy link
Contributor

@lvalerom lvalerom commented Sep 19, 2022

Description

sensor-integration-test were tracing the following due to invalid cluster_id:

kubernetes/listener/resources: 2022/09/12 14:13:45.462640 convert.go:48: Error: uuid: incorrect UUID length 4 in string "1234"
kubernetes/listener/resources: 2022/09/12 14:13:45.486336 convert.go:48: Error: uuid: incorrect UUID length 4 in string "1234"
kubernetes/listener/resources: 2022/09/12 14:13:46.459133 convert.go:48: Error: uuid: incorrect UUID length 4 in string "1234"

Checklist

  • Investigated and inspected CI test results
  • [ ] Unit test and regression tests added
  • [ ] Evaluated and added CHANGELOG entry if required
  • [ ] Determined and documented upgrade steps
  • [ ] Documented user facing changes (create PR based on openshift/openshift-docs and merge into rhacs-docs)

If any of these don't apply, please comment below.

Testing Performed

Manual testing and CI:

go test -race -count=1 github.com/stackrox/rox/sensor/tests/replay -v
make sensor-integration-test

@gitguardian
Copy link

gitguardian bot commented Sep 19, 2022

⚠️ GitGuardian has uncovered 5 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id Secret Commit Filename
3485722 RSA Private Key 44ac2bd tools/local-sensor/certs/caKey.pem View secret
4494364 Generic Private Key 44ac2bd tools/local-sensor/certs/caKey.pem View secret
4494365 Generic Private Key 44ac2bd tools/local-sensor/certs/key.pem View secret
4515690 Generic Private Key 9045ed8 tools/local-sensor/certs/caKey.pem View secret
4515691 Generic Private Key 9045ed8 tools/local-sensor/certs/key.pem View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@roxbot
Copy link
Contributor

roxbot commented Sep 19, 2022

Images are ready for the commit at 9045ed8.

To use with deploy scripts, first export MAIN_IMAGE_TAG=3.72.x-125-g9045ed8d46.

@lvalerom lvalerom requested review from a team, md2119 and theencee September 19, 2022 11:48
Copy link
Contributor

@msugakov msugakov left a comment

Choose a reason for hiding this comment

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

The change looks ok.
You may want to calm down GitGuardian that complains about finding secrets in .pem files, not sure how it's done.
Also, I have no clue how to capture data for safety-net-* files and I wasn't able to spot instructions. Could you please link it somewhere visibly or write it down if it is not yet written?

@@ -57,7 +57,7 @@ func (suite *ReplayEventsSuite) SetupSuite() {
panic(err)
}
suite.fakeCentral = centralDebug.MakeFakeCentralWithInitialMessages(
message.SensorHello("1234"),
message.SensorHello("12345678-1234-1234-1234-123456789abc"),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not valid UUIDv4. Here is the validation rule that I found after quick googling: https://stackoverflow.com/a/19989922

Maybe let's use something like this?

Suggested change
message.SensorHello("12345678-1234-1234-1234-123456789abc"),
message.SensorHello("00000000-0000-4000-A000-000000000000"),

Copy link
Contributor

Choose a reason for hiding this comment

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

... and apply to all 3 occurrences

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair. I'll change it. It's interesting though,pkg/uuid.go is not complaining with 12345678-1234-1234-1234-123456789abc (haven't look at the code)

@lvalerom
Copy link
Contributor Author

lvalerom commented Sep 19, 2022

You may want to calm down GitGuardian that complains about finding secrets in .pem files, not sure how it's done.

@gavin-stackrox Do you know how to do this? We use these secrets for test purposes only.

I have no clue how to capture data for safety-net-* files and I wasn't able to spot instructions. Could you please link it somewhere visibly or write it down if it is not yet written?

@msugakov The instruction are in this PR #2473. I think it's a good idea to have them written down somewhere else. Maybe in a comment in the tests code?

@msugakov
Copy link
Contributor

I think a README.md in sensor/tests/replay may be even better.

Copy link
Contributor

@fredrb fredrb left a comment

Choose a reason for hiding this comment

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

I'm fine with this change. But for the record, I think a better way of addressing this is to mock the TLS configuration for local-sensor, as described here: https://issues.redhat.com/browse/ROX-11015

The only reason local-sensor needs these files is to extract the ID from the cert CN. The gRPC connection is being mocked anyway so the contents of the certificate are irrelevant.

@lvalerom
Copy link
Contributor Author

I think a better way of addressing this is to mock the TLS configuration for local-sensor, as described here: https://issues.redhat.com/browse/ROX-11015

I agree with you, ROX-11015 should be the way to go to fix this properly. However, ROX-11015 might end up being a rabbit hole and this PR gives a quick patch to keep the log from spamming those uuid errors 🙂

@lvalerom lvalerom force-pushed the lvm/ROX-12569-change-local-sensor-cluster-id branch from 1759114 to 9045ed8 Compare September 23, 2022 07:52
@lvalerom lvalerom merged commit 2de65f0 into master Sep 23, 2022
@lvalerom lvalerom deleted the lvm/ROX-12569-change-local-sensor-cluster-id branch September 23, 2022 14:11
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.

None yet

5 participants