Commit Graph

118 Commits

Author SHA1 Message Date
Oliver Gorwits
4b6227fa2b fix tests 2023-07-20 20:39:31 +01:00
Oliver Gorwits
2d5e4dddee #1063 allow acls to match custom_fields 2023-07-20 18:08:36 +01:00
Oliver Gorwits
47c4226788 refactor CustomFields so with_custom_fields is available on backend 2023-07-20 16:51:04 +01:00
Oliver Gorwits
f72acb6006 #1064 implement tags in database and ACL 2023-07-19 11:15:49 +01:00
Oliver Gorwits
6eed661c43 avoid mistaking v6 in ACL for prop:val 2023-07-15 11:08:22 +01:00
Oliver Gorwits
fcd1c45606 allow ACL property match to contain ":" 2023-07-14 20:20:21 +01:00
Oliver Gorwits
2cbb68889a #975 RBAC for port control with new portctl_by_role setting 2023-06-27 22:52:04 +01:00
Oliver Gorwits
33b4a6c231 fix op:and not working for prop:value ACL rules 2023-06-26 19:31:54 +01:00
Oliver Gorwits
a76dc79b79 permit import of check_acl from Util::Permission in case other modules are still using it 2023-06-22 14:11:06 +01:00
Oliver Gorwits
814ccc9267 permit import of check_acl from Util::Permission in case other modules are still using it 2023-06-22 14:09:34 +01:00
Oliver Gorwits
9355f5c2b9 Refactored ACL support with multi-object compare
Squashed commit of the following:

commit 4081e22202693bd7c4ea00e95daad8e628c6fd5a
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Mon May 29 21:02:07 2023 +0100

    large rename of check_acl* to acl_matches*

commit 3cfa284ddd24d68765c255578cc5c184afbdcd83
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Fri May 19 20:39:03 2023 +0100

    update permission doc

commit 8c7bb93cc5e9fafb770f98f446e45cbd94b14894
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Wed May 17 21:50:07 2023 +0100

    migrate most check_acl_only to acl_matches_only

commit c47f699f2a22f08f2f3e093ed0f24c891e6f9a82
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Wed May 17 21:39:19 2023 +0100

    rename check_acl* to be acl_matches*

commit a884a22c3ab1f3262118c3a47ed8e25b0b0a7336
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun May 14 16:50:42 2023 +0100

    update macsuck_no_deviceports to use acl_matches

commit 8c256af728721329b64d071fa529dfc844073ac6
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun May 7 22:54:33 2023 +0100

    update hide_deviceports to use acl_matches multi @things

commit cd5d9978aba1da459be4fed4500f395df13f7784
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sun May 7 22:53:38 2023 +0100

    check_acl fix to allow all @things to offer a property before fallback to missing as empty string

commit 1a3ab9a7646e9f994f03126d45fc36e9e5a13ed5
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Tue May 2 15:31:17 2023 +0100

    add ignore_deviceports to portproperties discover; improve comments

commit 51385ce89458dc939587dae902fda431719c22c9
Merge: b97c07d2 3f8ffe78
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Tue May 2 15:21:48 2023 +0100

    Merge branch 'master' into og-acl_multidict

commit b97c07d237d750c1d9eb3095d8ff3908512eac2a
Author: Oliver Gorwits <oliver@cpan.org>
Date:   Sat Mar 25 14:37:53 2023 +0000

    add support for arrayref of items, and unblessed hash, to check_acl
2023-05-29 21:32:07 +01:00
Oliver Gorwits
949aeb9eea delete hook (#1032)
* make log_message optional in delete_device

* add hooks support to delete job

* make delete job high prio

* web delete now queues job instead of inline delete

* move web logging into web package and remove userlog from device delete helper

* submit delete job for expire device instead of inline delete

* fixes to get web submit form for delete device to work

* enable delete hook functionality
2023-04-30 22:58:42 +01:00
Oliver Gorwits
1d988bbf7c implement ignore_layers, force_macsuck, force_arpnip config settings (#1002)
* implementation of ignore_layers, force_macsuck, force_arpnip and macwalk

* use new WalkJobs view to get devices needing macsuck

* also new query for discoverall, arpwalk, nbtwalk

* faux record has a last_defer stamp so we can see when the backend started

* fix typo
2023-03-15 14:44:42 +00:00
Oliver Gorwits
db112d99cd #989 netdisco-deploy and netdisco-db-deploy respect ND2_DB_ROLLBACK 2023-03-08 13:49:02 +00:00
Oliver Gorwits
4bb9b25ae9 #901 node_ip time_last can be before time_first 2023-03-03 15:34:16 +00:00
Oliver Gorwits
d9a384d1d0 #949 replace other occurances of now() with LOCALTIMESTAMP 2023-03-03 14:17:38 +00:00
Oliver Gorwits
e43f6de283 #953 fix port reconfig (vlan) fail due to missing DB column data 2023-01-10 13:05:12 +00:00
Oliver Gorwits
2338a83f2b avoid pulling port_properties rows if with_properties already called 2022-12-04 12:26:10 +00:00
Oliver Gorwits
826e1db39d API Endpoints to submit arpnip and macsuck results (#942)
* Add macsuck worker to collect various PortAccessEntity (NAC) attributes

* Incorporate PAE feedback on #937

 * missing Result/Device.pm column added
 * pae_is... columns instead of pae_capabilities
 * moved most code to Util/PortAccessEntity.pm so the update can
   be done in discover and macsuck

* Refactor PAE attributes during discover as separate Plugin

* PortAccessEntity: don't use device->dns in log string

* Fix "Experimental keys on scalar is now forbidden" test failure

* Revamp pae_control and add missing attribute

 - device.pae_control (text) is now device.pae_is_enabled (bool)
 - also store pae_authconfig_port_control (port mode auto/force(un)Auth)

* Fix "Experimental keys on scalar is now forbidden" test failure

 - ... again because of botched merge
 - at least perlgolfed away a set of curly braces

* Update PortAccessEntity.pm

* Incorporate @ollyg PR feedback

* allow actions without transport to run when there are also no creds

* initial refactor for separate gather, process, store phases for macsuck

* factor out the vlan sanity check

* additional help with log of action workers

* cleanup logic in check macsuck

* refactor to make main phases only

* some fixes

* implement file slurp. amazingly the whole thing works

* remove outdated noop from test

* treat error as critical, use cancel to suppress further drivers

* big refactor to share mac sanity code to both paths

* fix inverted logic on vlan sanity filter

* some code tidy

* fix error in default value

* fix for vlan 0 nodes input from cli

* ensure imported MACs are IEEE format

* add api endpoint, no useful return status yet

* exit status if error from nodes PUT

* suppress other networked workers when direct workers are active

* better log showing worker

* fix status recording to get first error or last done message

* implement arpnip API PUT

* avoid package redeclaration error

* make sure write API methods require admin status

* add doc for passing JSON data to arpnip and macsuck

* update manifest

* remove option to do jobs in web handler; all by queue now

* use job entry timestamp for offline queued jobs

* fix store username and IP on api PUT

* never de-duplicate user-submitted jobs; never reset DeviceSkip for offline jobs

* myworker no longer needed

* make logic cleaner

Co-authored-by: Christian Ramseyer <ramseyer@netnea.com>
2022-11-25 15:24:23 +00:00
Oliver Gorwits
0e9ff81cf5 Add worker to collect various PortAccessEntity (NAC) attributes (PR #937, partially implements #887)
* Add macsuck worker to collect various PortAccessEntity (NAC) attributes

* Incorporate PAE feedback on #937

 * missing Result/Device.pm column added
 * pae_is... columns instead of pae_capabilities
 * moved most code to Util/PortAccessEntity.pm so the update can
   be done in discover and macsuck

* Refactor PAE attributes during discover as separate Plugin

* PortAccessEntity: don't use device->dns in log string

* Fix "Experimental keys on scalar is now forbidden" test failure

* Revamp pae_control and add missing attribute

 - device.pae_control (text) is now device.pae_is_enabled (bool)
 - also store pae_authconfig_port_control (port mode auto/force(un)Auth)

* Fix "Experimental keys on scalar is now forbidden" test failure

 - ... again because of botched merge
 - at least perlgolfed away a set of curly braces

* Update PortAccessEntity.pm

* Incorporate @ollyg PR feedback

Co-authored-by: Christian Ramseyer <ramseyer@netnea.com>
2022-11-04 10:03:26 +01:00
Oliver Gorwits
1d5f3ce316 #929 implement first half of multi tenancy with tenant_databases setting 2022-09-24 19:01:16 +01:00
Oliver Gorwits
790c51b257 #925 implement ignore_deviceports and hide_deviceports 2022-09-20 20:32:35 +01:00
Oliver Gorwits
c375b11cb0 initialise the resolver config for the DNS resolution (how was this even working before?!) 2022-08-15 08:32:13 -04:00
Oliver Gorwits
aa4ca704de also abort macsuck job for macsuck_unsupported devices 2022-05-18 16:36:41 +01:00
Christian Ramseyer
b028898003 netdisco-do -D arpnip ... shows collected arp entries
* debug message added in Util/Node.pm
 * works uniformely for SSH and CLI
2022-02-18 09:16:17 +01:00
nick n
636aa07f2d Give Pseudo Devices better OS, OS ver, Port Descr, Discovered, and DNS Name
* started pseudodevice rework
* give them a type, os, os_ver and num_ports
  * os_ver will be the netdisco version in which they were created
* give their ports the same value for device_port.descr as device_port.port
* add db update to fill out those fields if they are null, which is most likely
* update last_discover if you make changes to the device
* num_ports will not be updates by the db script, neither will device_port.descr

* use device.name, not device.dns for pseudo

* at least try and get reverse dns for pseudo, works if there is one

* add db revision to manifest

* take dns no config into account

* new meta

* new version

Co-authored-by: Oliver Gorwits <ollyg@users.noreply.github.com>
2021-11-06 21:52:59 +00:00
Oliver Gorwits
dc1f76c1aa Feature to gather SNMP Walk, use as Pseudo Device, and Browse Objects
* fix anomalous name

* add gather worker

* fix encoding of binary storage

* store results back to job

* now parsing mbis report to translate

* fix the broken report parser

* rename gather to snapshot

* implement walk code copied from SNMP::Info

* can now bulkwalk and parse mibs report and store resolved walk in cache

* add func/glob aliasing broken

* better aliasing

* implement aliasing from globals and funcs

* fix regexp for matching netdisco-mibs report

* fake cache entry for all ND2 methods called, add comments

* also save to logs/snapshots/IP

* add doc for netdisco-do

* add is_pseudo column to device table

* support for loading cache for pseudo devices

* check for hrSystemUptime as well as sysUpTime for snmp connect

* display pseudo devices with yellow pill for name

* color all cells for layers for pseudo

* no need to b64 encode binary data in scalars as we b64 whole thing after

* tweaked uptime check

* store snapshot to database instead of Job

* expose snapshots in device details tab

* small ux improvements on snap download

* fixes for errors in subnet mask searching

* hide snapshot management for pseudo devices

* update to use new netdisco-mibs object cache

* update for new format oids file

* start of work on loading walk into db for browsing

* store values and meta

* add auto increment col and oid index to browser

* start web plugin for browser

* add virtual search for oid children

* have all oid in separte table (60 seconds load on my laptop)

* rename table and add relation

* store oid as int array

* fix sql for children

* make jstree start working

* working very slow tree expand

* fix to work when first displaying tree

* store both oid and oid_parts

* simplify SQL to speed up (more complicated perl)

* fix sql bug, add better index, prettify tree

* render the snmp node detail

* add node template, make scrollable, pretty print data values (insecure)

* store munge hint

* some dubious code to munge the data

* make sure to filter by IP on device_browser

* make safer the rendering of value data (but need to come back to key ordering)

* fix sorting on object values

* limit the opening of child nodes to keep response good and unclutter

* factor out the munge and make safer

* reject unknown mungers

* show the munger and option (not working) to change

* additional js for munge select

* complete custom munge

* change so that saving to database is only at CLI and on request

* hide snmp tab if no browser rows in the db

* add helpful message when no browser rows for the device

* stub handler for search and add recurse control

* working search

* minor ui fixes

* implement typeahead for leaf search

* limit rows in typeahead

* make sure device_browser is visited in delete and renumber

* add requirements for this branch

* update manifest

* make sure node search and typeahead are restricted to current device only
2021-11-06 07:47:29 +00:00
Oliver Gorwits
5f3ae3bf10 Config setting portctl_nowaps to prevent port control on WAP ports 2021-09-03 06:22:16 +01:00
Oliver Gorwits
e953e3945f ACLs portctl_no and portctl_only for limiting port control targets 2021-09-03 06:15:20 +01:00
Oliver Gorwits
f1224b087c #767 also respect dns->no configuration in hostname_from_ip() 2021-07-24 12:23:43 +01:00
Oliver Gorwits
9eaef17680 Revert "#767 also respect dns->no configuration in ip_from_hostname()"
This reverts commit 74b9583fae.
2021-07-21 09:51:00 +01:00
Oliver Gorwits
74b9583fae #767 also respect dns->no configuration in ip_from_hostname() 2021-07-14 12:25:01 +01:00
Oliver Gorwits
ce29cf2ddb #783 fix FQDN discovery in node monitor emails 2021-07-14 12:07:47 +01:00
nick n
83a946d36e replace unicode nonbreaking space with ascii space (#794) 2021-06-23 22:00:33 +01:00
Oliver Gorwits
669eec46db Implement Hooks per #726 2020-12-23 11:18:38 +00:00
Oliver Gorwits
2b72233738 release 2.046004 2020-10-17 14:28:53 +01:00
Oliver Gorwits
c7b8c3bcbd #748 always call NetAddr::MAC->new() with named mac param 2020-10-17 13:05:46 +01:00
Oliver Gorwits
8acdb67346 minor bug fixes and cleanup 2020-05-15 11:35:12 +01:00
Oliver Gorwits
dff26abc5c API implementation (#712)
* initial v0 creator

* working json api for generic reports

* add require login

* move report swagger into plugin, and set new default layout of noop

* require proper role and also use new util func

* start to tidy authn

* some work on cleaning up web authn

* clean up the authN checks

* fix bug

* fix the auth for api

* fixes to json handling

* set swagger sort order

* enable most reports for api endpoints

* fix doc

* add paramters to reports

* add missed report

* allow api_parameters in reports config

* reorganise api

* add vlan search

* add port search

* make sure to enable layout processing

* add device search

* add v1 to api paths

* add Node Search

* support api_responses

* add device object search; fix spurious ports field in device result class

* handle some plugins just returning undef if search fails

* errors from api seamlessley

* fix error in date range default

* more sensible default for prefix

* change order of endpoints in swagger-ui

* all db row classes can now TO_JSON

* add device_port api endpoint

* add device ports endpoint

* do not expand docs

* add swagger ui json tree formatter

* add all relations from Device table

* add port relations

* add nodes retrieve on device or vlan

* rename to GetAPIKey

* update config for previous commit
2020-04-15 21:15:52 +01:00
Oliver Gorwits
ab6305b4cf default access list for device_auth should be ipv4 and ipv6 2020-02-12 16:55:16 +00:00
Christian Ramseyer
031c3e6d95 Optimize PortMAC query
* We meant well but it turns out that the array unnest and join is
  actually very slow, as the join arguments do not get pushed down
  into the CTE (in Postgres 9/10 at least, later versions remove some
  of the optimization barriers in that specifc type of query)
* This caused a seq scan on both device and device_port, and the query
  is executed many times during macsuck
* The query is now rewritten to use ANY (macaddr[]) and without CTE,
  which seems to be around 20x faster
2020-01-31 10:32:02 +01:00
Christian Ramseyer
f2f5d908bb Fix regression from PR #680
Hi @ollyg! Unfortunately I have found some issues with the code we
finally released in #680:

* get_port_macs expects an array ref but values() returns array,
  so the code was never called due to the return unless... check
* When fw_mac_list had exactly two entries, only the second value
  was bound as a scalar to the parameter. This is probably due
  to the shorthand bind formats described in
  https://metacpan.org/pod/DBIx::Class::ResultSet#DBIC-BIND-VALUES,
  but I'm not a 100% on this.
* return unless now checks for an entry in the list, with the old
  check the statement was also executed for empty lists

In cases where only the device(_port)?.mac lookup worked for uplink
detection, users of 02.044005 - 010 might get a lot of uplinks not
labeled as such.
2020-01-26 22:08:49 +01:00
Oliver Gorwits
e982aded09 add some protections to ACLs and an error log, following #686 2019-12-30 11:23:17 +00:00
Oliver Gorwits
0eab9213c0 should be faster than using IN on large lists 2019-12-21 21:32:27 +00:00
Oliver Gorwits
9a1938ddc9 safety and tidy the port_macs patch 2019-12-21 20:28:20 +00:00
Christian Ramseyer
26d3fbdd40 Reduce macsuck bandwidth usage to database (#680)
* Reduce macsuck bandwidth usage to database

get_port_macs transfers a full list of all device_port.(mac,ip) in every macsuck.
With 8k devices and 40k interfaces it takes up around 15MB. Transferring them 8k times
during an 1h macsuck cycle requires bandwidth in the 300 to 400 mbit/s range.

This patch changes get_port_macs to be called inside walk_fwtable and only transfer
the macs found in the current target device/vlan.
2019-12-21 18:28:47 +00:00
Oliver Gorwits
08969583cb change double negative logic 2019-10-30 19:50:04 +00:00
Ryan Gasik
441ac59661 Add check for is_arpnipable and is_macsuckable in Util::Device
Checks to make sure the device is in storage when checking if L2/L3
is supported on the device. Fixes #669.
2019-10-30 09:10:02 -07:00
Oliver Gorwits
884a75a866 #659 speed up Macsuck::Nodes while using $snmp->cisco_comm_indexing (#661)
* #659 speed up Macsuck::Nodes while using $snmp->cisco_comm_indexing

* Do not read qb_fw_vlan when using cisco_comm_indexing
2019-10-14 22:08:38 +02:00
Oliver Gorwits
409b7c1409 fix tests 2019-09-03 19:59:03 +01:00