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

Not able to pass output from earlier step as text #14

Open
richa-p opened this issue Sep 13, 2021 · 3 comments
Open

Not able to pass output from earlier step as text #14

richa-p opened this issue Sep 13, 2021 · 3 comments

Comments

@richa-p
Copy link

richa-p commented Sep 13, 2021

Hello,

I'm trying to read a file and then send it in Text section but it's not working. Here is the sample:

  • name: Read scan results summary
    id: scan-results
    run: |
    SAST_SUMMARY=$(cat sast-summary.txt)
    echo "::set-output name=SAST_SUMMARY::${SAST_SUMMARY}"
  • name: Send a message to Microsoft Teams
    if: ${{ steps.pipeline-scan.outcome == 'failure' }}
    uses: aliencube/microsoft-teams-actions@v0.8.0
    with:
    webhook_uri: ${{env.WEBHOOK_URI}}
    title: 'Veracode Pipeline Scan found vulnerabilities in ${{ env.REPOSITORY_NAME }}'
    summary: 'Flaws Summary: '
    text: 'Flaws text: ${{steps.scan-results.outputs.SAST_SUMMARY}}'
    theme_color: a72828
    actions: '[{ "@type": "OpenUri", "name": "View Results", "targets": [{ "os": "default", "uri": "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" }] }]'

Am I missing anything? Or this is not supported with the current version?

@riker09
Copy link

riker09 commented Sep 21, 2021

Is this the content of your YAML file?

jobs:
  your-job:
    runs-on: ubuntu-latest
    steps:
    - name: Read scan results summary
      id: scan-results
      run: |
        SAST_SUMMARY=$(cat sast-summary.txt)
        echo "::set-output name=SAST_SUMMARY::${SAST_SUMMARY}"
    - name: Send a message to Microsoft Teams
      if: ${{ steps.pipeline-scan.outcome == 'failure' }}
      uses: aliencube/microsoft-teams-actions@v0.8.0
      with:
        webhook_uri: ${{env.WEBHOOK_URI}}
        title: 'Veracode Pipeline Scan found vulnerabilities in ${{ env.REPOSITORY_NAME }}'
        summary: 'Flaws Summary: '
        text: 'Flaws text: ${{steps.scan-results.outputs.SAST_SUMMARY}}'
        theme_color: a72828
        actions: '[{ "@type": "OpenUri", "name": "View Results", "targets": [{ "os": "default", "uri": "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" }] }]'

(I have added the jobs to steps paragraphs)

Do you get any errors?

From my experience the workflow files are pretty fragile when it comes to single and double quotes. If your output SAST_SUMMARY contains single quotes this might break the second step since text is also single-quote-escaped.

@richa-p
Copy link
Author

richa-p commented Sep 30, 2021

Thanks for your response.
Correct that's the step configured in yaml file and SAST_SUMMARY may or may not contain single quotes.

I can give a try with double quotes, but then if for some reason SAST_SUMMARY has double quotes, then it will fail again.

@riker09
Copy link

riker09 commented Oct 1, 2021

Yup, unfortunately that is something one must be aware of. I think you should opt for either double or single quotes and then take every action you can think of to make sure that the quotes are properly escaped.

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

2 participants