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

Revert "ci: Split out the fuzz testing" #4

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,33 @@ jobs:
tar -xaf cln-${{ matrix.CFG }}.tar.bz2
make -j $(nproc) check-units installcheck VALGRIND=${{ matrix.VALGRIND }}

check-fuzz:
name: Run fuzz regression tests
runs-on: ubuntu-22.04
needs:
- prebuild
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install dependencies
run: |
bash -x .github/scripts/setup.sh
pip install -U pip wheel poetry
# Export and then use pip to install into the current env
poetry export -o /tmp/requirements.txt --without-hashes --with dev
pip install -r /tmp/requirements.txt

- name: Build
run: |
./configure --enable-debugbuild --enable-fuzzing --enable-address-sanitizer --enable-ub-sanitizer --disable-valgrind CC=clang
make -j $(nproc) check-fuzz

integration:
name: Test CLN ${{ matrix.name }}
runs-on: ubuntu-22.04
Expand Down
68 changes: 0 additions & 68 deletions .github/workflows/fuzz.yaml

This file was deleted.

15 changes: 10 additions & 5 deletions tests/fuzz/fuzz-ripemd160.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <openssl/ripemd.h>
#include <tests/fuzz/libfuzz.h>

static EVP_MD *ripemd160_algo;

/* Some versions of OpenSSL removed ripemd160 from the default provider. Check
* and load the legacy provider if necessary. */
void init(int *argc, char ***argv)
Expand All @@ -18,12 +20,15 @@ void init(int *argc, char ***argv)
u8 openssl_hash[RIPEMD160_DIGEST_LENGTH];
unsigned hash_size;

if (!EVP_Digest(data, sizeof(data), openssl_hash, &hash_size,
EVP_ripemd160(), NULL)) {
ripemd160_algo = EVP_MD_fetch(NULL, "RIPEMD-160", NULL);
if (!ripemd160_algo) {
OSSL_PROVIDER_load(NULL, "legacy");
assert(EVP_Digest(data, sizeof(data), openssl_hash, &hash_size,
EVP_ripemd160(), NULL));
ripemd160_algo = EVP_MD_fetch(NULL, "RIPEMD-160", NULL);
assert(ripemd160_algo);
}

assert(EVP_Digest(data, sizeof(data), openssl_hash, &hash_size,
ripemd160_algo, NULL));
assert(hash_size == RIPEMD160_DIGEST_LENGTH);
}

Expand Down Expand Up @@ -54,7 +59,7 @@ static void test_vs_openssl(const struct ripemd160 *expected, const u8 *data,
u8 openssl_hash[RIPEMD160_DIGEST_LENGTH];
unsigned hash_size;

assert(EVP_Digest(data, size, openssl_hash, &hash_size, EVP_ripemd160(),
assert(EVP_Digest(data, size, openssl_hash, &hash_size, ripemd160_algo,
NULL));
assert(hash_size == RIPEMD160_DIGEST_LENGTH);
assert(memeq(expected, sizeof(*expected), openssl_hash,
Expand Down
10 changes: 8 additions & 2 deletions tests/fuzz/fuzz-sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
#include <openssl/sha.h>
#include <tests/fuzz/libfuzz.h>

void init(int *argc, char ***argv) {}
static EVP_MD *sha256_algo;

void init(int *argc, char ***argv)
{
sha256_algo = EVP_MD_fetch(NULL, "SHA-256", NULL);
assert(sha256_algo);
}

/* Test that splitting the data and hashing via multiple updates yields the same
* result as not splitting the data. */
Expand Down Expand Up @@ -38,7 +44,7 @@ static void test_vs_openssl(const struct sha256 *expected, const u8 *data,
u8 openssl_hash[SHA256_DIGEST_LENGTH];
unsigned hash_size;

assert(EVP_Digest(data, size, openssl_hash, &hash_size, EVP_sha256(),
assert(EVP_Digest(data, size, openssl_hash, &hash_size, sha256_algo,
NULL));
assert(hash_size == SHA256_DIGEST_LENGTH);
assert(memeq(expected, sizeof(*expected), openssl_hash,
Expand Down
Loading