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

Property value contains brackets #6

Open
jan-cerny opened this issue Nov 9, 2022 · 2 comments
Open

Property value contains brackets #6

jan-cerny opened this issue Nov 9, 2022 · 2 comments

Comments

@jan-cerny
Copy link

After the version 0.1.20 of the notiz-dev/github-action-json-property action has been released, we experience a different behavior of the .prop property which causes our CI jobs to fail. The value returned by this property now contains brackets [ and ] which weren't there with the previous version.

An example of a workflow affected by this change is https://github.com/ComplianceAsCode/content/blob/master/.github/workflows/automatus-cs9.yaml

In our workflow, we have a JSON output.json that can look for example like this:

{"rules": ["accounts_passwords_pam_faillock_dir"], "product": "rhel8", "bash": "True", "ansible": "True"}

Then, we have a step that is using notiz-dev/github-action-json-property:


      - name: Get rule ids to be tested
        if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
        id: rules
        uses: notiz-dev/github-action-json-property@release
        with:
          path: 'output.json'
          prop_path: 'rules'

Then, we use this step in another step in a run command as ${{join(steps.rules.outputs.prop)}}.

      - name: Run tests in a container - Ansible
        if: ${{ steps.ansible.outputs.prop == 'True' && steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
        run: tests/test_rule_in_container.sh --dontclean --logdir logs_ansible --remediate-using ansible --name ssg_test_suite --datastream $DATASTREAM ${{join(steps.rules.outputs.prop)}}
        env:
          ADDITIONAL_TEST_OPTIONS: "--duplicate-templates --add-product-to-fips-certified centos9 --product rhel9"

Previously, the string returned by ${{join(steps.rules.outputs.prop)}} didn't contain [ and ].

For example, in the job https://github.com/ComplianceAsCode/content/actions/runs/3036087676/jobs/4887043536 for the JSON {"rules": ["accounts_umask_etc_profile"], "product": "rhel8", "bash": "False", "ansible": "True"} it returned accounts_umask_etc_profile.

After the update, the format changes and looks like the raw JSON with [ and ] and quotes.

For example, in the job https://github.com/ComplianceAsCode/content/actions/runs/3418678327/jobs/5691495274 for the JSON {"rules": ["accounts_passwords_pam_faillock_dir"], "product": "rhel8", "bash": "True", "ansible": "True"} it returned ["accounts_passwords_pam_faillock_dir"].

For this moment, we have fixed this by using the older version v0.1.0 explicitly in our GH actions workflows.

But what would be the proper fix? Should we use the output in a different way? Or can it be a bug in your tool?

Thanks for any advice.

@jlsjonas
Copy link

jlsjonas commented Dec 23, 2022

Previously, the string returned by ${{join(steps.rules.outputs.prop)}} didn't contain [ and ].

Is it perhaps returning the prop value as string instead of parsed now? (@jan-cerny you could attempt ${{join(fromJson(steps.rules.outputs.prop))}} instead to confirm this)

@ggbecker
Copy link

Previously, the string returned by ${{join(steps.rules.outputs.prop)}} didn't contain [ and ].

Is it perhaps returning the prop value as string instead of parsed now? (@jan-cerny you could attempt ${{join(fromJson(steps.rules.outputs.prop))}} instead to confirm this)

It seems to work. Let's see how it goes: ComplianceAsCode/content@5ffe39f

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

No branches or pull requests

3 participants