diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b4f6713..14c7112 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -26,7 +26,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - name: Build Application using script @@ -35,6 +35,6 @@ jobs: cmake -B ${{github.workspace}}/build -G Ninja ninja -C ${{github.workspace}}/build - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml new file mode 100644 index 0000000..d49be10 --- /dev/null +++ b/.github/workflows/scorecard.yml @@ -0,0 +1,73 @@ +# This workflow uses actions that are not certified by GitHub. They are provided +# by a third-party and are governed by separate terms of service, privacy +# policy, and support documentation. + +name: Scorecard supply-chain security +on: + # For Branch-Protection check. Only the default branch is supported. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection + branch_protection_rule: + # To guarantee Maintained check is occasionally updated. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained + schedule: + - cron: '33 14 * * 6' + push: + branches: [ "master" ] + +# Declare default permissions as read only. +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + # Needed to upload the results to code-scanning dashboard. + security-events: write + # Needed to publish results and get a badge (see publish_results below). + id-token: write + # Uncomment the permissions below if installing in a private repository. + # contents: read + # actions: read + + steps: + - name: "Checkout code" + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + persist-credentials: false + + - name: "Run analysis" + uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 + with: + results_file: results.sarif + results_format: sarif + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: + # - you want to enable the Branch-Protection check on a *public* repository, or + # - you are installing Scorecard on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional. + # repo_token: ${{ secrets.SCORECARD_TOKEN }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. + publish_results: true + + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF + # format to the repository Actions tab. + - name: "Upload artifact" + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + + # Upload the results to GitHub's code scanning dashboard (optional). + # Commenting out will disable upload of results to your repo's Code Scanning dashboard + - name: "Upload to code-scanning" + uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9 + with: + sarif_file: results.sarif diff --git a/README.md b/README.md index d62f7ea..54ac164 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build CI](https://github.com/adulau/ssldump/actions/workflows/build.yml/badge.svg)](https://github.com/adulau/ssldump/actions/workflows/build.yml) [![CodeQL analysis](https://github.com/adulau/ssldump/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/adulau/ssldump/actions/workflows/codeql-analysis.yml) +[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/adulau/ssldump/badge)](https://securityscorecards.dev/viewer/?uri=github.com/adulau/ssldump) # Release and tagging diff --git a/pcap/pcap_logger.c b/pcap/pcap_logger.c index 8c0a9bb..8998881 100644 --- a/pcap/pcap_logger.c +++ b/pcap/pcap_logger.c @@ -54,7 +54,11 @@ static int init_pcap_logger(void *data) { } static int deinit_pcap_logger(void) { - fdatasync(pcap_fd); +#if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO > 0) + fdatasync(pcap_fd); +#else + fsync(pcap_fd); +#endif close(pcap_fd); return 0; } diff --git a/ssl/ssl.enums.c b/ssl/ssl.enums.c index feb8513..c4ac065 100644 --- a/ssl/ssl.enums.c +++ b/ssl/ssl.enums.c @@ -244,7 +244,7 @@ static int decode_HandshakeType_ClientHello(ssl_obj *ssl, SSL_DECODE_UINT16(ssl, "extensions len", 0, data, &exlen); if(exlen) { explain(ssl, "extensions\n"); - while(data->len) { + while(data->len > 0) { SSL_DECODE_UINT16(ssl, "extension type", 0, data, &ex); if(!ja3_ex_str) ja3_ex_str = calloc(7, 1); @@ -1714,6 +1714,7 @@ decoder extension_decoder[] = { {55, "external_id_hash", decode_extension}, {56, "external_session_id", decode_extension}, {13172, "next_protocol_negotiation", decode_extension}, + {0xfe0d, "encrypted_client_hello", decode_extension}, {0xff01, "renegotiation_info", decode_extension}, {-1}}; diff --git a/ssl/ssldecode.c b/ssl/ssldecode.c index 40a81fb..c57af01 100644 --- a/ssl/ssldecode.c +++ b/ssl/ssldecode.c @@ -555,6 +555,7 @@ int ssl_restore_session(ssl_obj *ssl, ssl_decoder *d) { case TLSV1_VERSION: case TLSV11_VERSION: case TLSV12_VERSION: + case TLSV13_VERSION: if((r = ssl_generate_keying_material(ssl, d))) ABORT(r); break; @@ -658,6 +659,7 @@ int ssl_process_client_key_exchange(ssl_obj *ssl, case TLSV1_VERSION: case TLSV11_VERSION: case TLSV12_VERSION: + case TLSV13_VERSION: if((r = ssl_generate_keying_material(ssl, d))) ABORT(r); break;