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

fix: decryption before every substitution disabled #733

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

mkanoor
Copy link
Contributor

@mkanoor mkanoor commented Feb 24, 2025

Calling ansible-vault as a separate process is a huge overhead and takes upto 2 seconds per variable. Doing this over and over before every substitution slows doen the entire processing. Now we decrypt once at startup and keep the decrypted values in memory and reuse them during substitution.

https://issues.redhat.com/browse/AAP-40490

Calling ansible-vault as a separate process is a huge overhead
and takes upto 2 seconds per variable. Doing this over and over
before every substitution slows doen the entire processing.
Now we decrypt once at startup and keep the decrypted values
in memory and reuse them during substitution.

https://issues.redhat.com/browse/AAP-40490
Copy link
Contributor

@Alex-Izquierdo Alex-Izquierdo left a comment

Choose a reason for hiding this comment

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

LGTM, but one question @mkanoor @bzwei
Right now we are decrypting the values one per one.
ansible-vault can decrypt a whole file, why not create a file with all the encrypted values and decrypt them in only one call of the cli?

@mkanoor
Copy link
Contributor Author

mkanoor commented Feb 24, 2025

@Alex-Izquierdo currently we dont store anything in files locally when doing the decryption we pass in the fields via pexpect one at a time.

@Alex-Izquierdo
Copy link
Contributor

@Alex-Izquierdo currently we dont store anything in files locally when doing the decryption we pass in the fields via pexpect one at a time.

@mkanoor That's my point. Through a file would be even more performant since we call the cli only once.
We can create the file with the encrypted values and read the decrypted values from the stdout, if the security is your concern.

@mkanoor
Copy link
Contributor Author

mkanoor commented Feb 24, 2025

@Alex-Izquierdo that might require some re-write and testing. @bzwei did we try this earlier I remember we had some solution using python packages not sure if we decrypted all variables in a single file. Not sure how that works. If there are embedded multi lines in the data. Is there a marker of when the clear text starts and when it ends.

@bzwei
Copy link
Contributor

bzwei commented Feb 25, 2025

If we want to call the decrypt cli only once, we may assemble all secret variables into a json string and encrypt it at eda-server side and decrypt and parse json at the engine side.

Alex-Izquierdo added a commit to ansible/eda-server that referenced this pull request Feb 25, 2025
# [ AAP-40490]  increase activation readiness timeout 

## Description
We have detected that ansible-rulebook might be slow at starting when
decrypting vaulted variables.
After #1088 we have received
several reports for activations being restarted as unresponsive after
not receive the heartbeat in time. In combination with
ansible/ansible-rulebook#733 we agreed to
increase the default value of RULEBOOK_READINESS_TIMEOUT_SECONDS for
safeness.

Jira: https://issues.redhat.com/browse/AAP-40490

## Type of Change
<!-- Mandatory: Check one or more boxes that apply -->
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Documentation update
- [ ] Test update
- [ ] Refactoring (no functional changes)
- [ ] Development environment change
- [ ] Configuration change
- [ ] CI change

## Self-Review Checklist
<!-- These items help ensure quality - they complement our automated CI
checks -->
- [X] I have performed a self-review of my code
- [ ] I have added relevant comments to complex code sections
- [ ] I have updated documentation where needed
- [ ] I have considered the security impact of these changes
- [ ] I have considered performance implications
- [ ] I have thought about error handling and edge cases
- [ ] I have tested the changes in my local environment
- [ ] I have run the linters and test suite locally
- [ ] I have tested the changes on integration environment

## Testing Instructions
Create an activation with multiple credentials. 

### Prerequisites
None

### Expected Results
The activation is not set as unresponsive and it is set as running by
the system

## Additional Context
None

### Required Actions
None

Signed-off-by: Alex <[email protected]>
@mkanoor
Copy link
Contributor Author

mkanoor commented Feb 25, 2025

If we want to call the decrypt cli only once, we may assemble all secret variables into a json string and encrypt it at eda-server side and decrypt and parse json at the engine side.

@bzwei The problem with that is "Data in Transit" is not encrypted

@bzwei
Copy link
Contributor

bzwei commented Feb 25, 2025

If we want to call the decrypt cli only once, we may assemble all secret variables into a json string and encrypt it at eda-server side and decrypt and parse json at the engine side.

@bzwei The problem with that is "Data in Transit" is not encrypted

why not encrypted? I am proposing the server encrypts the json string and sends to client. So data in transit is encrypted. Then client decrypts, parses the decrypted json, and inserts sensitive variables in memory.

@Alex-Izquierdo
Copy link
Contributor

@mkanoor @bzwei Anyway, I think we can merge this to improve the thing in the meantime while we are working on a better solution. WDYT?

@mkanoor
Copy link
Contributor Author

mkanoor commented Feb 26, 2025

@Alex-Izquierdo @bzwei We have to fix this in a separate PR I am thinking we take all the extra vars that we get from the controller put into a temporary yaml file and then decrypt the whole yaml file using ansible vault and keep those decrypted values in memory and delete the temporary yaml file.

@mkanoor mkanoor merged commit 6030d0b into ansible:main Feb 26, 2025
11 checks passed
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.

3 participants