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

feat: added Github CI workflow #317

Closed
wants to merge 40 commits into from
Closed

Conversation

airween
Copy link
Member

@airween airween commented Apr 11, 2024

Added .github/workflow/ci.yml and necessary files with a complex test workflow for each PR.

A brief summary about how does it work:

  • set up dependencies (required packages)
  • install latest ModSecurity3 release
  • get ModSecurity-nginx source
  • get latest Nginx soure
  • build Nginx with ModSecurity module
  • start Nginx with ModSecurity
  • there are two virtual hosts
  • there is only one rule
  • run a valid request (expected code is 200) and an attack (expected code is 403) against both vhosts

.github/mime.types Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
@airween airween requested a review from theseion April 12, 2024 13:02
@airween
Copy link
Member Author

airween commented Apr 12, 2024

@theseion many thanks for your suggestion. Please take a review again, if everything is fine I'm going to merge it.

.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
@theseion
Copy link

theseion commented Apr 14, 2024

Looks to me like you were trying to set environment variables from scripts, but scripts are isolated, so export will have no effect on the next script (neither will a cd at the end of a script block btw). What you should do instead is setting the environment variable for the step, like so:

      - name: Build nginx with ModSecurity-nginx module
        working-directory: nginx
        env:
          CC: "${{ matrix.compiler }}"
        run: |
          echo "Compiler: ${CC}"

          ./auto/configure --with-ld-opt="-Wl,-rpath,/usr/local/lib" --without-pcre2 --add-module=/home/runner/work/ModSecurity-nginx/ModSecurity-nginx/ModSecurity-nginx
          make
          make modules
          sudo make install

@airween
Copy link
Member Author

airween commented Apr 14, 2024

What you should do instead is setting the environment variable for the step, like so:

Thanks!

How can I use environment variables in evaluation, eg. in an if statement?

    if [ matrix.compiler == "gcc" ]; then
        ...

${{ matrix.compiler }} it's not good, because it's the evaluated value (literally "gcc").

@theseion
Copy link

By passing it through an environment variable like so:

- name: a script
  env:
    COMPILER: "${{ matrix.compiler }}"
  run: |
    if [ "${COMPILER}" == "gcc" ]; then
      ...

@airween
Copy link
Member Author

airween commented Apr 14, 2024

By passing it through an environment variable like so:

- name: a script
  env:
    COMPILER: "${{ matrix.compiler }}"
  run: |
    if [ "${COMPILER}" == "gcc" ]; then
      ...

I'm afraid in this case the evaluated code will be something similar:

    if [ "gcc" == "gcc" ]; then

which is always true.

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@airween
Copy link
Member Author

airween commented Apr 16, 2024

See the newest clear version: #318.

@airween airween closed this Apr 16, 2024
@airween airween deleted the ghci branch April 16, 2024 20:01
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.

2 participants