Skip to content

Conversation

@evallesp
Copy link
Contributor

We're adding json type files to crawl_n_mask.
It checks the extension and return the value of the masked key different between yaml and json formats.

@evallesp evallesp requested a review from a team as a code owner October 24, 2025 12:02
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 24, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

@danpawlik danpawlik left a comment

Choose a reason for hiding this comment

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

Generally it looks ok, but want to see result

Copy link
Contributor

@michburk michburk left a comment

Choose a reason for hiding this comment

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

I did a test running the module locally with some basic examples. I noticed that in JSON files, the secrets get masked slightly differently than in yaml files. I ran crawl_n_mask on a dir with the following yaml and json files.
yaml file:

---
password: password123

json file:

{
  "password": "password123"
}

after crawling the dir, the files look like:

---
password: 'pa**********23'
{
    "password": "p**********3"
}

The secret in the yaml file is masked as expected, but it seems that in the json file, the double quotes surrounding the actual secret are counted as part of the secret's length.

for word in PROTECT_KEYS:
if key.strip() == word:
masked = partial_mask(value)
if key.strip().replace('"', "") == word.strip():
Copy link
Contributor

@michburk michburk Oct 24, 2025

Choose a reason for hiding this comment

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

Could move this key.strip().replace('"', "") into a variable calculated just above the for loop in order to avoid constantly re-evaluating these string operations while we check the same key against each new word in PROTECT_KEYS.

@evallesp evallesp force-pushed the add-json-extension-crawl-n-mask branch from 87435b7 to f4fb6b9 Compare October 27, 2025 15:10
@evallesp
Copy link
Contributor Author

I did a test running the module locally with some basic examples. I noticed that in JSON files, the secrets get masked slightly differently than in yaml files. I ran crawl_n_mask on a dir with the following yaml and json files. yaml file:

---
password: password123

json file:

{
  "password": "password123"
}

after crawling the dir, the files look like:

---
password: 'pa**********23'
{
    "password": "p**********3"
}

The secret in the yaml file is masked as expected, but it seems that in the json file, the double quotes surrounding the actual secret are counted as part of the secret's length.

Good catch. I've updated the PR, but waiting the testproject results

@evallesp evallesp force-pushed the add-json-extension-crawl-n-mask branch from f4fb6b9 to 9fea55a Compare October 27, 2025 16:35
@michburk
Copy link
Contributor

Json masking is working properly now in my local tests 👍

@softwarefactory-project-zuul
Copy link

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/36c4a133dea84791b8f96f3a6d087a22

✔️ openstack-k8s-operators-content-provider SUCCESS in 1h 36m 26s
✔️ podified-multinode-edpm-deployment-crc SUCCESS in 1h 18m 20s
✔️ cifmw-crc-podified-edpm-baremetal SUCCESS in 1h 21m 58s
✔️ noop SUCCESS in 0s
✔️ cifmw-pod-ansible-test SUCCESS in 8m 40s
cifmw-pod-pre-commit FAILURE in 7m 49s
✔️ build-push-container-cifmw-client SUCCESS in 17m 29s

@danpawlik
Copy link
Contributor

@evallesp re-run black on the python file and we can go

We're adding json type files to crawl_n_mask.
It checks the extension and return the value of the masked
key different between yaml and json formats.
@evallesp evallesp force-pushed the add-json-extension-crawl-n-mask branch from 9fea55a to 88ebe1c Compare October 28, 2025 11:37
@evallesp
Copy link
Contributor Author

@evallesp re-run black on the python file and we can go

done

@evallesp
Copy link
Contributor Author

@evallesp
Copy link
Contributor Author

evallesp commented Nov 2, 2025

I think this is redundant since the creation of: #3447

@evallesp evallesp closed this Nov 4, 2025
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.

3 participants