@oneuptime/common 12.0.22 → 12.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/Models/DatabaseModels/Index.ts +2 -0
  2. package/Models/DatabaseModels/NetworkDevice.ts +44 -0
  3. package/Models/DatabaseModels/NetworkDeviceAutoImportRule.ts +564 -0
  4. package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.ts +38 -0
  5. package/Server/Infrastructure/Postgres/SchemaMigrations/1789100000000-AddNetworkDeviceAutoImportRule.ts +60 -0
  6. package/Server/Infrastructure/Postgres/SchemaMigrations/1789200000000-AddSysObjectIdPatternToAutoImportRule.ts +26 -0
  7. package/Server/Infrastructure/Postgres/SchemaMigrations/1789300000000-AddAutoApplyVendorHealthTemplate.ts +26 -0
  8. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
  9. package/Server/Services/Index.ts +2 -0
  10. package/Server/Services/NetworkDeviceAutoImportRuleEngineService.ts +917 -0
  11. package/Server/Services/NetworkDeviceAutoImportRuleService.ts +181 -0
  12. package/Server/Utils/Monitor/NetworkInventoryUtil.ts +39 -1
  13. package/Tests/Server/Services/AutoImportScanCredentialSelect.test.ts +205 -0
  14. package/Tests/Server/Services/NetworkDeviceAutoImportRuleEngineService.test.ts +933 -0
  15. package/Tests/Server/Utils/Monitor/NetworkInventoryUtil.test.ts +97 -1
  16. package/Tests/Utils/NetworkDiscovery/AutoImportRuleMatcher.test.ts +516 -0
  17. package/Tests/Utils/NetworkDiscovery/DiscoveredDeviceBuilder.test.ts +272 -0
  18. package/Tests/Utils/NetworkDiscovery/ScanTargetUtil.test.ts +164 -0
  19. package/Types/NetworkAutomation/RuleRunResult.ts +84 -0
  20. package/Types/Permission.ts +47 -0
  21. package/Utils/NetworkDiscovery/AutoImportRuleMatcher.ts +257 -0
  22. package/Utils/NetworkDiscovery/DiscoveredDeviceBuilder.ts +183 -0
  23. package/Utils/NetworkDiscovery/DiscoveredHostUtil.ts +95 -0
  24. package/Utils/NetworkDiscovery/DiscoveryImportEligibility.ts +66 -0
  25. package/Utils/NetworkDiscovery/ScanTargetUtil.ts +82 -0
  26. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  27. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  28. package/build/dist/Models/DatabaseModels/NetworkDevice.js +45 -0
  29. package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -1
  30. package/build/dist/Models/DatabaseModels/NetworkDeviceAutoImportRule.js +589 -0
  31. package/build/dist/Models/DatabaseModels/NetworkDeviceAutoImportRule.js.map +1 -0
  32. package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +28 -0
  33. package/build/dist/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js.map +1 -1
  34. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789100000000-AddNetworkDeviceAutoImportRule.js +35 -0
  35. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789100000000-AddNetworkDeviceAutoImportRule.js.map +1 -0
  36. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789200000000-AddSysObjectIdPatternToAutoImportRule.js +19 -0
  37. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789200000000-AddSysObjectIdPatternToAutoImportRule.js.map +1 -0
  38. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789300000000-AddAutoApplyVendorHealthTemplate.js +19 -0
  39. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789300000000-AddAutoApplyVendorHealthTemplate.js.map +1 -0
  40. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
  41. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  42. package/build/dist/Server/Services/Index.js +2 -0
  43. package/build/dist/Server/Services/Index.js.map +1 -1
  44. package/build/dist/Server/Services/NetworkDeviceAutoImportRuleEngineService.js +711 -0
  45. package/build/dist/Server/Services/NetworkDeviceAutoImportRuleEngineService.js.map +1 -0
  46. package/build/dist/Server/Services/NetworkDeviceAutoImportRuleService.js +155 -0
  47. package/build/dist/Server/Services/NetworkDeviceAutoImportRuleService.js.map +1 -0
  48. package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js +26 -0
  49. package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js.map +1 -1
  50. package/build/dist/Types/NetworkAutomation/RuleRunResult.js +24 -0
  51. package/build/dist/Types/NetworkAutomation/RuleRunResult.js.map +1 -1
  52. package/build/dist/Types/Permission.js +41 -0
  53. package/build/dist/Types/Permission.js.map +1 -1
  54. package/build/dist/Utils/NetworkDiscovery/AutoImportRuleMatcher.js +149 -0
  55. package/build/dist/Utils/NetworkDiscovery/AutoImportRuleMatcher.js.map +1 -0
  56. package/build/dist/Utils/NetworkDiscovery/DiscoveredDeviceBuilder.js +121 -0
  57. package/build/dist/Utils/NetworkDiscovery/DiscoveredDeviceBuilder.js.map +1 -0
  58. package/build/dist/Utils/NetworkDiscovery/DiscoveredHostUtil.js +75 -0
  59. package/build/dist/Utils/NetworkDiscovery/DiscoveredHostUtil.js.map +1 -0
  60. package/build/dist/Utils/NetworkDiscovery/DiscoveryImportEligibility.js +59 -0
  61. package/build/dist/Utils/NetworkDiscovery/DiscoveryImportEligibility.js.map +1 -0
  62. package/build/dist/Utils/NetworkDiscovery/ScanTargetUtil.js +60 -0
  63. package/build/dist/Utils/NetworkDiscovery/ScanTargetUtil.js.map +1 -1
  64. package/package.json +1 -1
@@ -0,0 +1,60 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ /*
4
+ * Auto-import rules for network device discovery (issue #3378): a rule table
5
+ * whose conditions decide which discovered hosts become Network Devices with
6
+ * no manual review step, plus a processed-marker column on the scan so the
7
+ * worker that evaluates the rules knows which results it has already seen.
8
+ */
9
+ export class AddNetworkDeviceAutoImportRule1789100000000
10
+ implements MigrationInterface
11
+ {
12
+ public name: string = "AddNetworkDeviceAutoImportRule1789100000000";
13
+
14
+ public async up(queryRunner: QueryRunner): Promise<void> {
15
+ await queryRunner.query(
16
+ `CREATE TABLE "NetworkDeviceAutoImportRule" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "name" character varying(100) NOT NULL, "description" character varying(500), "isEnabled" boolean NOT NULL DEFAULT true, "ipMatchTarget" character varying(100), "sysNamePattern" character varying(500), "sysDescrPattern" character varying(500), "includePingOnlyHosts" boolean NOT NULL DEFAULT false, "isExclusion" boolean NOT NULL DEFAULT false, "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_network_device_auto_import_rule_id" PRIMARY KEY ("_id"))`,
17
+ );
18
+
19
+ for (const column of ["projectId", "name", "isEnabled", "isExclusion"]) {
20
+ await queryRunner.query(
21
+ `CREATE INDEX "IDX_network_device_auto_import_rule_${column}" ON "NetworkDeviceAutoImportRule" ("${column}")`,
22
+ );
23
+ }
24
+
25
+ await queryRunner.query(
26
+ `ALTER TABLE "NetworkDeviceAutoImportRule" ADD CONSTRAINT "FK_nd_auto_import_rule_projectId" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
27
+ );
28
+ await queryRunner.query(
29
+ `ALTER TABLE "NetworkDeviceAutoImportRule" ADD CONSTRAINT "FK_nd_auto_import_rule_createdByUserId" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
30
+ );
31
+ await queryRunner.query(
32
+ `ALTER TABLE "NetworkDeviceAutoImportRule" ADD CONSTRAINT "FK_nd_auto_import_rule_deletedByUserId" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
33
+ );
34
+
35
+ await queryRunner.query(
36
+ `ALTER TABLE "NetworkDeviceDiscoveryScan" ADD "autoImportProcessedAt" TIMESTAMP WITH TIME ZONE`,
37
+ );
38
+
39
+ /*
40
+ * Backfill EVERY existing scan as already-processed, making the feature
41
+ * forward-only. One-shot scans stay "Completed" forever, so without this
42
+ * every scan ever run would sit unprocessed and the first rule a project
43
+ * creates would mass-import months-old results — the opposite of what an
44
+ * operator writing a rule about FUTURE discoveries intends. Old results
45
+ * remain reachable on purpose through the rule's explicit "Run Now".
46
+ */
47
+ await queryRunner.query(
48
+ `UPDATE "NetworkDeviceDiscoveryScan" SET "autoImportProcessedAt" = now()`,
49
+ );
50
+ }
51
+
52
+ public async down(queryRunner: QueryRunner): Promise<void> {
53
+ await queryRunner.query(
54
+ `ALTER TABLE "NetworkDeviceDiscoveryScan" DROP COLUMN "autoImportProcessedAt"`,
55
+ );
56
+ await queryRunner.query(
57
+ `DROP TABLE IF EXISTS "NetworkDeviceAutoImportRule"`,
58
+ );
59
+ }
60
+ }
@@ -0,0 +1,26 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ /*
4
+ * Vendor-based auto-import conditions (issue #3378, phase 2): the probe now
5
+ * reports the full SNMP system group per discovered host (sysObjectId,
6
+ * sysLocation, sysContact, sysUpTimeSeconds ride inside the scan's existing
7
+ * discoveredDevices jsonb, so they need no column), and a rule can match on
8
+ * the sysObjectID — the vendor's registered enterprise OID.
9
+ */
10
+ export class AddSysObjectIdPatternToAutoImportRule1789200000000
11
+ implements MigrationInterface
12
+ {
13
+ public name: string = "AddSysObjectIdPatternToAutoImportRule1789200000000";
14
+
15
+ public async up(queryRunner: QueryRunner): Promise<void> {
16
+ await queryRunner.query(
17
+ `ALTER TABLE "NetworkDeviceAutoImportRule" ADD "sysObjectIdPattern" character varying(500)`,
18
+ );
19
+ }
20
+
21
+ public async down(queryRunner: QueryRunner): Promise<void> {
22
+ await queryRunner.query(
23
+ `ALTER TABLE "NetworkDeviceAutoImportRule" DROP COLUMN "sysObjectIdPattern"`,
24
+ );
25
+ }
26
+ }
@@ -0,0 +1,26 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ /*
4
+ * Vendor health template auto-apply (issue #3378, phase 3): a per-device
5
+ * opt-in that lets the inventory poll merge the matching vendor OID template
6
+ * into an empty Health OIDs list once the device's sysObjectID is known.
7
+ * Defaults false everywhere — existing devices keep the manual banner flow;
8
+ * the auto-import engine turns it on for the devices it creates.
9
+ */
10
+ export class AddAutoApplyVendorHealthTemplate1789300000000
11
+ implements MigrationInterface
12
+ {
13
+ public name: string = "AddAutoApplyVendorHealthTemplate1789300000000";
14
+
15
+ public async up(queryRunner: QueryRunner): Promise<void> {
16
+ await queryRunner.query(
17
+ `ALTER TABLE "NetworkDevice" ADD "autoApplyVendorHealthTemplate" boolean NOT NULL DEFAULT false`,
18
+ );
19
+ }
20
+
21
+ public async down(queryRunner: QueryRunner): Promise<void> {
22
+ await queryRunner.query(
23
+ `ALTER TABLE "NetworkDevice" DROP COLUMN "autoApplyVendorHealthTemplate"`,
24
+ );
25
+ }
26
+ }
@@ -543,6 +543,9 @@ import { AddDetectionRuleIncidentColumns1788600000000 } from "./1788600000000-Ad
543
543
  import { RemoveMarketingConversionUploadState1788700000000 } from "./1788700000000-RemoveMarketingConversionUploadState";
544
544
  import { DropMarketingConversionAddEnterpriseLicenseEmail1788800000000 } from "./1788800000000-DropMarketingConversionAddEnterpriseLicenseEmail";
545
545
  import { AddUserSlackAndMicrosoftTeams1789000000000 } from "./1789000000000-AddUserSlackAndMicrosoftTeams";
546
+ import { AddNetworkDeviceAutoImportRule1789100000000 } from "./1789100000000-AddNetworkDeviceAutoImportRule";
547
+ import { AddSysObjectIdPatternToAutoImportRule1789200000000 } from "./1789200000000-AddSysObjectIdPatternToAutoImportRule";
548
+ import { AddAutoApplyVendorHealthTemplate1789300000000 } from "./1789300000000-AddAutoApplyVendorHealthTemplate";
546
549
  import { AddUserTwoFactorBackupCode1789100000000 } from "./1789100000000-AddUserTwoFactorBackupCode";
547
550
  import { MigrationName1787142779538 } from "./1787142779538-MigrationName";
548
551
  import { MigrationName1787156982416 } from "./1787156982416-MigrationName";
@@ -1095,5 +1098,8 @@ export default [
1095
1098
  RemoveMarketingConversionUploadState1788700000000,
1096
1099
  DropMarketingConversionAddEnterpriseLicenseEmail1788800000000,
1097
1100
  AddUserSlackAndMicrosoftTeams1789000000000,
1101
+ AddNetworkDeviceAutoImportRule1789100000000,
1102
+ AddSysObjectIdPatternToAutoImportRule1789200000000,
1103
+ AddAutoApplyVendorHealthTemplate1789300000000,
1098
1104
  AddUserTwoFactorBackupCode1789100000000,
1099
1105
  ];
@@ -42,6 +42,7 @@ import NetworkDeviceOwnerTeamService from "./NetworkDeviceOwnerTeamService";
42
42
  import NetworkDeviceOwnerUserService from "./NetworkDeviceOwnerUserService";
43
43
  import NetworkDeviceOwnerRuleService from "./NetworkDeviceOwnerRuleService";
44
44
  import NetworkDeviceLabelRuleService from "./NetworkDeviceLabelRuleService";
45
+ import NetworkDeviceAutoImportRuleService from "./NetworkDeviceAutoImportRuleService";
45
46
  import NetworkDeviceDiscoveryScanService from "./NetworkDeviceDiscoveryScanService";
46
47
  import NetworkInterfaceService from "./NetworkInterfaceService";
47
48
  import NetworkSiteService from "./NetworkSiteService";
@@ -364,6 +365,7 @@ const services: Array<BaseService> = [
364
365
  NetworkDeviceOwnerUserService,
365
366
  NetworkDeviceOwnerRuleService,
366
367
  NetworkDeviceLabelRuleService,
368
+ NetworkDeviceAutoImportRuleService,
367
369
  NetworkDeviceDiscoveryScanService,
368
370
  NetworkInterfaceService,
369
371
  NetworkSiteService,