Merge remote-tracking branch 'origin/topic/awelzel/add-spicy-format'

* origin/topic/awelzel/add-spicy-format:
  testing/external: Update private baselines
  analyzer/syslog: Reformat with spicy-format
  analyzer/finger: Reformat with spicy-format
  scripts/spicy: Reformat with spicy-format
  pre-commit: Add spicy-format
This commit is contained in:
Arne Welzel 2024-09-05 19:19:31 +02:00
commit 2907d9feee
8 changed files with 44 additions and 17 deletions

View file

@ -32,3 +32,10 @@ repos:
hooks:
- id: typos
exclude: '^(.typos.toml|src/SmithWaterman.cc|testing/.*|auxil/.*|scripts/base/frameworks/files/magic/.*|CHANGES)$'
- repo: https://github.com/bbannier/spicy-format
rev: v0.15.0
hooks:
- id: spicy-format
# TODO: Reformat existing large analyzers just before 8.0.
exclude: '(^testing/.*)|(protocol/ldap/.*)|(protocol/quic/.*)|(protocol/websocket/.*)'

15
CHANGES
View file

@ -1,3 +1,18 @@
7.1.0-dev.247 | 2024-09-05 19:19:31 +0200
* testing/external: Update private baselines (Arne Welzel, Corelight)
* analyzer/syslog: Reformat with spicy-format (Arne Welzel, Corelight)
* analyzer/finger: Reformat with spicy-format (Arne Welzel, Corelight)
* scripts/spicy: Reformat with spicy-format (Arne Welzel, Corelight)
* pre-commit: Add spicy-format (Arne Welzel, Corelight)
This excludes the larger protocol analyzers. These should be formatted
during the 7.2 cycle, shortly before 8.0.
7.1.0-dev.241 | 2024-09-04 14:53:19 -0700
* Check for netbios to avoid reporting extra bad DNS opcodes (Tim Wojtulewicz, Corelight)

View file

@ -1 +1 @@
7.1.0-dev.241
7.1.0-dev.247

View file

@ -507,4 +507,3 @@ public function vector_size(id: string): uint64 &cxxname="zeek::spicy::rt::vecto
##
## v: opaque handle to the Zeek vector, as returned by other functions
public function vector_size(v: ZeekVector): uint64 &cxxname="zeek::spicy::rt::vector_size";

View file

@ -16,15 +16,19 @@ import zeek;
## size: Total number of bytes the file contains, if known; will be passed on to Zeek
public type File = unit(mime_type: optional<string> = Null, size: optional<uint64> = Null) {
on %init {
self.fid = zeek::file_begin(mime_type);
self.fid = zeek::file_begin(mime_type);
if ( size )
zeek::file_set_size(*size, self.fid);
if (size)
zeek::file_set_size(*size, self.fid);
}
: bytes &chunked &eod { zeek::file_data_in($$, self.fid); }
: bytes &chunked &eod {
zeek::file_data_in($$, self.fid);
}
on %finally { zeek::file_end(self.fid); }
on %finally {
zeek::file_end(self.fid);
}
## Zeek-side file ID
var fid: string;

View file

@ -8,13 +8,15 @@ module Finger;
import spicy;
const OptionalWhiteSpace = /[ \t]*/;
const NewLine = /\r?\n/;
const NewLine = /\r?\n/;
public type Request = unit {
public type Request = unit {
: OptionalWhiteSpace;
switch {
-> : /\/W/ { self.whois = True; }
-> : /\/W/ {
self.whois = True;
}
-> : void;
};
@ -24,12 +26,12 @@ public type Request = unit {
# We require valid UTF-8 to weed out binary data.
self.user = self.arg[0].decode();
if ( |self.arg[1]| > 0 )
if (|self.arg[1]| > 0)
self.host = self.arg[1].decode();
}
on %done {
if ( |self.arg[0]| > 0 || self.whois )
on %done {
if (|self.arg[0]| > 0 || self.whois)
spicy::accept_input();
}
@ -43,12 +45,12 @@ type ReplyLine = unit {
: NewLine;
on %done {
if ( |self.data| > 10 )
if (|self.data| > 10)
# Require some non-trivial output to accept.
spicy::accept_input();
}
};
public type Reply = unit {
public type Reply = unit {
: ReplyLine[];
};

View file

@ -15,7 +15,7 @@ public type Message = unit {
on %done {
spicy::accept_input();
if ( self?.prio ) {
if (self?.prio) {
self.severity = (self.prio.value & 0x07);
self.facility = (self.prio.value & 0x03f8) >> 3;
}

View file

@ -1 +1 @@
e051f29d1f03f2264b8cf1ff5ed9bfba9d326c45
5db3bb717a3507ffb3b94766dbe485855286571d