Merge remote-tracking branch 'origin/topic/awelzel/stmt-extern'

* origin/topic/awelzel/stmt-extern:
  Bump zeekjs for STMT_ANY deprecation
  Stmt: Deprecate STMT_ANY
  Stmt: Introduce STMT_EXTERN
This commit is contained in:
Arne Welzel 2024-02-08 15:12:16 +01:00
commit 382121fd8c
5 changed files with 44 additions and 4 deletions

32
CHANGES
View file

@ -1,3 +1,35 @@
6.2.0-dev.533 | 2024-02-08 15:12:16 +0100
* Bump zeekjs for STMT_ANY deprecation (Arne Welzel, Corelight)
* GH-3529: Stmt: Deprecate STMT_ANY (Arne Welzel, Corelight)
This isn't used in-tree and has been misused by some external plugins
of mine (zeekjs and zeek-perf-support) for their own Stmt subclasses.
These plugins should be updated to use the new STMT_EXTERN statement.
Handle STMT_ANY explicitly in stmt_name() for the time being
to fix #3529 until we remove STMT_ANY for good.
* Stmt: Introduce STMT_EXTERN (Arne Welzel, Corelight)
It's currently possible for plugin's to implement their own statement
subclasses and override the Exec() implementation. This has been leveraged
by ZeekJS [1] and zeek-perf-support [2] as well as a private WASM plugin.
All of these used STMT_ANY as the tag of their own statement subclasses.
With STMT_EXTERN, we make the possibility to add external code into the AST
somewhat more supported. It's all in detail space and plugin authors have
no guarantee for stability, but it seems such a powerful extension point
that IMO we should keep it.
I'm conscious there's the broader topic how this interacts with ZAM
optimization like in-lining or rewriting of statements. However, this
already applies to the STMT_ANY usage of the mentioned plugins.
[1] https://github.com/corelight/zeekjs
[2] https://github.com/zeek/zeek-perf-support
6.2.0-dev.528 | 2024-02-07 12:45:30 -0700 6.2.0-dev.528 | 2024-02-07 12:45:30 -0700
* Update .gitignore to add Emacs and Vim temp files (Tim Wojtulewicz) * Update .gitignore to add Emacs and Vim temp files (Tim Wojtulewicz)

View file

@ -1 +1 @@
6.2.0-dev.528 6.2.0-dev.533

@ -1 +1 @@
Subproject commit 70d88f4b10e36f8715eb0f2a25eb0fc0eb4fce37 Subproject commit 84826e2f733f69843fb470328877c27758ebe164

View file

@ -52,8 +52,15 @@ const char* stmt_name(StmtTag t) {
"ZAM", "ZAM",
"null", "null",
"assert", "assert",
"extern",
}; };
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
if ( int(t) == STMT_ANY )
return "any";
#pragma GCC diagnostic pop
return stmt_names[int(t)]; return stmt_names[int(t)];
} }

View file

@ -6,7 +6,7 @@ namespace zeek::detail {
// These are in a separate file to break circular dependences // These are in a separate file to break circular dependences
enum StmtTag { enum StmtTag {
STMT_ANY = -1, STMT_ANY [[deprecated("Remove in v7.1 - Unused and plugins should use STMT_EXTERN.")]] = -1,
STMT_ALARM, // Does no longer exist but kept to create enums consistent. STMT_ALARM, // Does no longer exist but kept to create enums consistent.
STMT_PRINT, STMT_PRINT,
STMT_EVENT, STMT_EVENT,
@ -31,7 +31,8 @@ enum StmtTag {
STMT_ZAM, // a ZAM function body STMT_ZAM, // a ZAM function body
STMT_NULL, STMT_NULL,
STMT_ASSERT, STMT_ASSERT,
#define NUM_STMTS (int(STMT_ASSERT) + 1) STMT_EXTERN, // for custom Stmt subclasses provided by plugins
#define NUM_STMTS (int(STMT_EXTERN) + 1)
}; };
enum StmtFlowType { enum StmtFlowType {