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

Declare handle_get_credentials variables where they are used #2217

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

mattmundell
Copy link
Contributor

@mattmundell mattmundell commented Jun 4, 2024

What

In handle_get_credentials move the declarations of variables public_key and private_key down to the blocks they are used in.

Why

This reduces the scope of the variables, making the code easier to understand.

There is some performance gain to be made when getting the credentials, but the situation is complex. Hoping small changes like this will make the gains achievable in the future.

Test

To test private_key:

$ o m m "<create_credential><name>usk: username and ssh private key</name><type>usk</type><login>username</login><key><phrase></phrase><private>$(cat ~/tmp/key/ed25519)</private></key></create_credential>"
$ o m m '<get_credentials credential_id="7fc16405-c190-4a5a-999b-bd31a055933f" details="1" format="key"/>'

To test public_key:

$ o m m "<create_credential><name>gpg</name><type>pgp</type><login>username</login><key><phrase>test</phrase><public>$(cat ~/tmp/key/gpg.pub)</public></key></create_credential>"
$ o m m '<get_credentials credential_id="85fda2a1-ba94-4f64-b9d8-33935f469ab4" details="1" format="key"/>'

References

/pull/2122 explores the potential performance gains.

@mattmundell mattmundell requested a review from a team as a code owner June 4, 2024 07:17
Copy link

github-actions bot commented Jun 4, 2024

Conventional Commits Report

😢 No conventional commits found.

👉 Learn more about the conventional commits usage at Greenbone.

@a-h-abdelsalam a-h-abdelsalam merged commit 074c2a8 into main Jun 12, 2024
11 checks passed
@a-h-abdelsalam a-h-abdelsalam deleted the mv-vars branch June 12, 2024 12:30
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.

2 participants