From e6af74c8aa1219b192d8d33f618584042e1d61c9 Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Thu, 11 May 2023 19:58:11 +0200 Subject: [PATCH] Fix generation of file IDs. They weren't stable, and potentially repetitive. Note: We should backport this to the external plugin. --- src/spicy/protocol-analyzer.cc | 9 +++++++-- .../btest/Baseline/spicy.file-analysis-data-in/output | 4 ++-- .../btest/Baseline/spicy.file-data-in-at-offset/output | 4 ++-- testing/scripts/spicy/canonify-zeek-log | 3 --- testing/scripts/spicy/canonify-zeek-log-sorted | 3 --- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/spicy/protocol-analyzer.cc b/src/spicy/protocol-analyzer.cc index 821356ecf7..05b64895e3 100644 --- a/src/spicy/protocol-analyzer.cc +++ b/src/spicy/protocol-analyzer.cc @@ -18,11 +18,16 @@ using namespace zeek::spicy::rt; void EndpointState::debug(const std::string& msg) { spicy::rt::debug(_cookie, msg); } static auto create_endpoint(bool is_orig, analyzer::Analyzer* analyzer, ::spicy::rt::driver::ParsingType type) { + static uint64_t id_counter = 0; + + ++id_counter; + cookie::ProtocolAnalyzer cookie{.analyzer = analyzer, .is_orig = is_orig, - .fstate_orig = cookie::FileStateStack(hilti::rt::fmt("%x.orig", analyzer->GetID())), + .fstate_orig = + cookie::FileStateStack(hilti::rt::fmt("%" PRIx64 ".orig", id_counter)), .fstate_resp = - cookie::FileStateStack(hilti::rt::fmt("%x.resp", analyzer->GetID()))}; + cookie::FileStateStack(hilti::rt::fmt("%" PRIx64 ".resp", id_counter))}; // Cannot get parser here yet, analyzer may not have been fully set up. return EndpointState(std::move(cookie), type); diff --git a/testing/btest/Baseline/spicy.file-analysis-data-in/output b/testing/btest/Baseline/spicy.file-analysis-data-in/output index f041df16ae..8a97453dba 100644 --- a/testing/btest/Baseline/spicy.file-analysis-data-in/output +++ b/testing/btest/Baseline/spicy.file-analysis-data-in/output @@ -1,3 +1,3 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -FL4lmy3f7owPUUoQ8l -FhCRq1oIy2uDU8rog +FM47gX3vI5ofQPm1li +FZjUS57tUkGFTibv3 diff --git a/testing/btest/Baseline/spicy.file-data-in-at-offset/output b/testing/btest/Baseline/spicy.file-data-in-at-offset/output index f041df16ae..8a97453dba 100644 --- a/testing/btest/Baseline/spicy.file-data-in-at-offset/output +++ b/testing/btest/Baseline/spicy.file-data-in-at-offset/output @@ -1,3 +1,3 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -FL4lmy3f7owPUUoQ8l -FhCRq1oIy2uDU8rog +FM47gX3vI5ofQPm1li +FZjUS57tUkGFTibv3 diff --git a/testing/scripts/spicy/canonify-zeek-log b/testing/scripts/spicy/canonify-zeek-log index c4f22cea32..4cf49537e3 100755 --- a/testing/scripts/spicy/canonify-zeek-log +++ b/testing/scripts/spicy/canonify-zeek-log @@ -9,9 +9,6 @@ else sed="sed -E" fi -# File IDs changed between Zeek 3.1 and 3.2. - ${sed} 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g' | - ${sed} 's/F[A-Za-z0-9]{14,17}/XXXXXXXXXXXXXXXXX/g' | $(dirname $0)/diff-remove-timestamps | $(dirname $0)/diff-remove-abspath diff --git a/testing/scripts/spicy/canonify-zeek-log-sorted b/testing/scripts/spicy/canonify-zeek-log-sorted index a4ff5ddbc9..80d89fd9f5 100755 --- a/testing/scripts/spicy/canonify-zeek-log-sorted +++ b/testing/scripts/spicy/canonify-zeek-log-sorted @@ -9,10 +9,7 @@ else sed="sed -E" fi -# File IDs changed between Zeek 3.1 and 3.2. - ${sed} 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g' | - ${sed} 's/F[A-Za-z0-9]{15,17}/XXXXXXXXXXXXXXXXX/g' | $(dirname $0)/diff-sort | $(dirname $0)/diff-remove-timestamps | $(dirname $0)/diff-remove-abspath