Commit graph

89 commits

Author SHA1 Message Date
Vern Paxson
441baaf2c1 added &no_ZAM_opt/&no_CPP_opt attributes and --no-opt-files/--no-opt-funcs for controlling skipping script optimization 2025-09-23 09:05:40 -07:00
Evan Typanski
111583602e Fix Coverity issue with new Attributes ctor 2025-08-20 08:28:18 -04:00
Evan Typanski
4445bc1daf Fix parameter attributes pretending to be records
Parameters relied on is_record for a couple of validations, but they are
not records and should not be treated as such. This way we can validate
&optional better.
2025-08-14 12:00:15 -04:00
Tim Wojtulewicz
f386deba94 Fix clang-tidy performance-enum-size warnings in headers 2025-06-23 08:35:24 -07:00
Vern Paxson
b0d9a841f5 improved error cascade for invalid attributes 2024-06-04 10:36:36 -07:00
Vern Paxson
a927d61e59 minor fixes for script optimization, exporting of attr_name, script layout tweak 2023-12-04 16:48:19 -08:00
Benjamin Bannier
f5a76c1aed Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The
one place where we deviate is header include order since Zeek depends on
headers being included in a certain order.
2023-10-30 09:40:55 +01:00
Arne Welzel
431767d04b Add &default_insert attribute for tables
This is based on the discussion in zeek/zeek#2668. Using &default with tables
can be confusing as the default value is not inserted. The following example
prints an empty table at the end even new Service records was instantiated.

    type Service: record {
        occurrences: count &default=0;
        last_seen: time &default=network_time();
    };

    global services: table[string] of Service &default=Service();

    event zeek_init()
        {
        services["http"]$occurrences += 1;
        services["http"]$last_seen = network_time();

        print services;
        }

Changing above &default to &default_insert will insert the newly created
default value upon a missed lookup and act less surprising.

Other examples that caused confusion previously revolved around table of sets
 or table of vectors and `add` or `+=` not working as expected.

    tbl_of_vector["http"] += 1
    add tbl_of_set["http"][1];
2023-08-04 12:30:36 +02:00
Tim Wojtulewicz
bd7df9e2bf Add &ordered attribute for tables/sets 2022-10-16 15:31:42 -07:00
Vern Paxson
9f05fe5bfa code formatting and more btest updates 2022-05-26 18:15:48 -07:00
Vern Paxson
a0fc8ca5e4 broader support for AST traversal, including Attr and Attributes objects 2022-05-26 17:38:34 -07:00
Vern Paxson
ffdcc36bd5 factoring to make checking of &default attributes externally accessible 2022-03-31 19:29:17 -07:00
Tim Wojtulewicz
b2f171ec69 Reformat the world 2021-09-16 15:35:39 -07:00
Vern Paxson
d5e6d8e249 more liberal view of attribute equality; allow suppressing attr type-checking 2021-03-18 10:42:49 -07:00
Tim Wojtulewicz
4ad08172d0 Remove obsolete ZEEK_FORWARD_DECLARE_NAMESPACED macros 2021-02-24 14:35:44 -07:00
Vern Paxson
8a3622a726 &is_used attribute to suppress set-but-not-used usage warnings 2021-02-05 22:17:36 -08:00
Vern Paxson
c991c54690 &is_set => &is_assigned 2021-02-04 12:18:46 -08:00
Jon Siwek
cfe29c2488 Merge branch 'master' into topic/vern/reaching-defs 2021-02-01 17:27:37 -08:00
Tim Wojtulewicz
0618be792f Remove all of the random single-file deprecations
These are the changes that don't require a ton of changes to other files outside
of the original removal.
2021-01-27 10:52:40 -07:00
Vern Paxson
ca33a15626 &is_set attribute to suppress -u possibly-used-but-not-set warnings 2021-01-23 10:30:41 -08:00
Tim Wojtulewicz
96d9115360 GH-1079: Use full paths starting with zeek/ when including files 2020-11-12 12:15:26 -07:00
Jon Siwek
5e6bb843ab Merge remote-tracking branch 'origin/topic/timw/174-duplicate-attributes'
- Replaced "tag" with "attribute" in the error message since the former
  is not exactly the same concept/meaning and also not user-facing
  terminology

* origin/topic/timw/174-duplicate-attributes:
  Allow duplicate attributes in full redefs
  Short-circuit checking of whether attr exists
  Expanded check for other tag types, fixed btest to cover more tags
  GH-174: Add warning for duplicate attributes
2020-08-31 17:39:47 -07:00
Tim Wojtulewicz
9106f3f722 Allow duplicate attributes in full redefs 2020-08-28 09:55:40 -07:00
Tim Wojtulewicz
fe0c22c789 Base: Clean up explicit uses of namespaces in places where they're not necessary.
This commit covers all of the common and base classes.
2020-08-24 12:07:00 -07:00
Tim Wojtulewicz
01ce18894b Rename types in ZeekList.h to be consistent with the style guide 2020-08-20 16:11:47 -07:00
Tim Wojtulewicz
106a92a9a8 Rename BroList.h to ZeekList.h 2020-08-20 16:11:46 -07:00
Johanna Amann
36db9d8369 TableSync: don't raise &on_change, smaller fixes
This addresses PR feedback. The main component in this commit is to
disable &on_change notifications when &backend loads a table from sqlite
on startup.
2020-07-17 14:21:27 -07:00
Johanna Amann
6d2aa84952 SyncTables: address feedback part 1 - naming (broker and zeek)
This commit fixes capitalization issues.
2020-07-17 10:56:28 -07:00
Johanna Amann
7c37226eaa Merge remote-tracking branch 'origin/master' into topic/johanna/table-changes 2020-07-13 17:11:55 -07:00
Johanna Amann
2b2a40f49c Zeek Table<->Brokerstore: cleanup, documentation, small fixes
This commit adds script/c++ documentation and fixes a few loose ends.
It also adds tests for corner cases and massively improves error
messages.

This also actually introduces type-compatibility checking and introduces
a new attribute that lets a user override this if they really know what
they are doing. I am not quite sure if we should really let that stay in
- but it can be very convenient to have this functionality.

One test is continuing to fail - the expiry test is very flaky. This is,
I think, caused by delays of the broker store forwarding. I am unsure if
we can actually do anything about that.
2020-07-10 16:58:34 -07:00
Jon Siwek
8597b998bb Add deprecation expression to deprecated prototype/parameter messages 2020-07-10 10:57:57 -07:00
Johanna Amann
e1a45d33e0 Merge remote-tracking branch 'origin/master' into topic/johanna/table-changes
* origin/master: (47 commits)
  scan.l: Remove "constant" did_module_restore logic
  Fix FreeBSD CI script to install right SWIG package
  Update submodule(s)
  GH-928: use realpath() instead of inode to de-duplicate scripts
  Update submodule(s)
  GH-1040: Add zero-indexed version of str_split
  Fix WhileStmt to call Stmt(Tag) ctor
  GH-1041: Move compress_path to a bif that uses normalize_path
  Update submodule(s)
  Update submodule(s)
  Update submodule(s)
  Fix --enable-mobile-ipv6 build
  Fix namespace of GetCurrentLocation() to zeek::detail
  Add backtrace() and print_backtrace()
  Rename BroString files to ZeekString
  Update NEWS entry with note about class renames
  Rename BroObj to Obj
  Rename BroString to zeek::String
  Move Func up to zeek namespace, rename BroFunc to ScriptFunc
  Mark global val_mgr as deprecated and fix uses of it to use namespaced version
  ...
2020-07-09 14:07:03 -07:00
Tim Wojtulewicz
02cef05f93 Rename BroObj to Obj 2020-07-02 16:15:01 -07:00
Tim Wojtulewicz
937a462e70 Move Frame and Scope to zeek::detail namespace 2020-06-30 20:51:53 -07:00
Tim Wojtulewicz
ec9eff0bd5 Use type aliases for IntrusivePtr definitions 2020-06-30 20:37:30 -07:00
Tim Wojtulewicz
9364e6a5b7 Move IntrusivePtr and utility methods to the zeek namespace 2020-06-30 20:19:12 -07:00
Jon Siwek
4668378d91 Merge remote-tracking branch 'origin/topic/timw/1032-namespaced-enums'
Merge adjustments:
- Added back in deprecation tag for base_type_no_ref()
- Added back the deprecated plugin::hook_name() function

* origin/topic/timw/1032-namespaced-enums:
  Deprecate plugin::HookType and plugin::component::Type in a different way
  Deprecate init_class and IDScope in another way.
  Deprecate TypeTag and friends in a different way
  Deprecate attr_tag in a different way, rename to AttrTag
2020-06-30 16:55:36 -07:00
Johanna Amann
318a72c303 BrokerStore<->Zeek table - introdude &backend attribute
The &backend attribute allows for a much more convenient way of
interacting with brokerstores. One does not need to create a broker
store anymore - instead all of this is done internally.

The current state of this partially works. This should work fine for
persistence - but clones are currently not yet correctly attached.
2020-06-30 16:33:52 -07:00
Jon Siwek
35fa042fd6 Merge remote-tracking branch 'origin/topic/timw/1034-IndexTypes'
Minor tweaks during merge:
- Remove/default superfluous ~Attributes()
- Added in resize() calls to accompany reserve() of associated vectors

* origin/topic/timw/1034-IndexTypes:
  Revert Attributes::Attrs back to return an attr_list and mark it deprecated
  GH-1034: Revert TypeList::Types() back to return a type_list* and mark it deprecated
2020-06-30 15:56:49 -07:00
Tim Wojtulewicz
a280bfa0b1 Deprecate attr_tag in a different way, rename to AttrTag 2020-06-30 12:47:54 -07:00
Tim Wojtulewicz
5b8aaf6497 Revert Attributes::Attrs back to return an attr_list and mark it deprecated 2020-06-30 10:39:03 -07:00
Johanna Amann
c8a3a90339 Merge remote-tracking branch 'origin/master' into topic/johanna/table-changes
* origin/master: (33 commits)
  Fix location where CI places build.tgz
  Update submodule(s)
  Disable some deprecation diagnostics for GCC
  Compare pcap_next_ex() result to PCAP_ERROR/PCAP_ERROR_BREAK
  Optimize Connection::RemovalEvent() for bare-mode usage
  Rename BroType to Type
  Update NEWS
  Review cleanup
  Move Type types to zeek namespace
  Review cleanup
  Restrict Cirrus CI to only zeek repo's branches
  GH-977: Improve pcap error handling
  Remove not-useful code in iosource::Manager::OpenPktSrc
  GH-999: Stop formatting DHCP Client ID Hardware Type 0 as MAC
  Remove inline from some static KeyedHash members
  Improve Func.h inclusion
  Fix NVT analyzer memory leak from multiple telnet authn name options
  Rename aux/ to auxil/
  Move Flare/Pipe from the bro namespace to zeek::detail
  Move Attr to the zeek::detail namespace
  ...
2020-06-15 14:19:02 -07:00
Jon Siwek
d4f3cad7d1 Merge remote-tracking branch 'origin/topic/timw/266-namespaces'
Merge adjustments:

- Preserved original `base_type_no_ref` argument type as ::TypeTag
- Removed superfluous #pragma guard around deprecated TableVal ctor
- Clarify NEWS regarding MetaHook{Pre,Post} deprecations
- Simplify some `::zeek::` qualifications to just `zeek::`
- Prefixed FORWARD_DECLARE_NAMESPACED macro with ZEEK_

* origin/topic/timw/266-namespaces:
  Disable some deprecation diagnostics for GCC
  Rename BroType to Type
  Update NEWS
  Review cleanup
  Move Type types to zeek namespace
  Move Flare/Pipe from the bro namespace to zeek::detail
  Move Attr to the zeek::detail namespace
  Move Trigger into the zeek::detail namespace
  Move ID to the zeek::detail namespace
  Move Anon.h into zeek::detail namespace
  Mark all of the aliased classes in plugin/Plugin.h deprecated, and fix all of the plugins that were using them
  Move all of the base plugin classes into the zeek::plugin namespace
  Expr: move all classes into zeek::detail
  Stmt: move Stmt classes into zeek::detail namespace
  Add utility macro for creating namespaced aliases for classes
2020-06-11 23:20:51 -07:00
Tim Wojtulewicz
149e3b3c32 Disable some deprecation diagnostics for GCC
Clang automatically disables deprecation warnings for types used within
already-deprecated contexts, such as if you use a deprecated type inside
of a method that's beeen marked as deprecated. GCC doesn't have this
feature so it spews a lot more warnings. These functions are now wrapped
in pragmas that disable the warnings for the usage.
2020-06-11 15:43:11 -07:00
Tim Wojtulewicz
137e416a03 Rename BroType to Type 2020-06-10 14:27:36 -07:00
Johanna Amann
d9de6c4522 Merge remote-tracking branch 'origin/master' into topic/johanna/table-changes
* origin/master: (172 commits)
  GH-985: Fix descriptions of double_to_interval() return values
  Decrease number of CPUs/memory for Cirrus CI tasks
  Change CI script to compile from build/Makefile
  Add missing include in util.cc
  Remove Analyzer.h from bro-bif.h
  Remove IPAddr.h from Reporter.h
  Remove the inclusion of Func.h from NetVar.h, which reduces the inclusion of Func.h overall.
  Update submodule(s)
  Update submodule(s)
  Integrate review feedback
  Update submodule(s)
  Fix crash on using some deprecated environment variables
  Update NEWS
  Update test baselines for new Broker connection status/error strings
  Switch Broker Val converter visitor to return IntrusivePtr
  Change BroFunc ctor to take const-ref IntrusivePtr<ID>
  Add version of Frame::SetElement() taking IntrusivePtr<ID>
  Change Scope/Func inits from id_list* to vector<IntrusivePtr<ID>>
  Change Scope::GenerateTemporary() to return IntrusivePtr
  Deprecate Scope::ReturnType(), replace with GetReturnType()
  ...
2020-06-03 16:09:42 -07:00
Tim Wojtulewicz
60ed29c3b6 Move Attr to the zeek::detail namespace 2020-06-03 15:16:19 -07:00
Tim Wojtulewicz
cbdb8ee074 Expr: move all classes into zeek::detail 2020-06-03 15:16:18 -07:00
Jon Siwek
bee321711f Deprecate Attributes::FindAttr(), replace with Find() 2020-05-26 15:25:08 -07:00
Jon Siwek
6daa33364b Deprecate Attributes::AddAttrs(Attributes*)
Replaced with version taking an IntrusivePtr parameter
2020-05-26 15:12:20 -07:00