From 6daea521c341ea1b011cf163b1533f7c7daf1419 Mon Sep 17 00:00:00 2001 From: Patrick Pacher Date: Fri, 29 Mar 2024 09:35:18 +0100 Subject: [PATCH 1/6] Fix netquery textql parser when dealing with IP addresses --- desktop/angular/.eslintrc.json | 51 +++++++++++++++++++ .../src/app/shared/netquery/textql/lexer.ts | 19 ++++--- 2 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 desktop/angular/.eslintrc.json diff --git a/desktop/angular/.eslintrc.json b/desktop/angular/.eslintrc.json new file mode 100644 index 00000000..4a0b4c0e --- /dev/null +++ b/desktop/angular/.eslintrc.json @@ -0,0 +1,51 @@ +{ + "root": true, + "ignorePatterns": [ + "projects/**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@angular-eslint/recommended", + "plugin:@angular-eslint/template/process-inline-templates" + ], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "app", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "app", + "style": "kebab-case" + } + ], + "@typescript-eslint/no-explicit-any": "off" + } + }, + { + "files": [ + "*.html" + ], + "extends": [ + "plugin:@angular-eslint/template/recommended", + "plugin:@angular-eslint/template/accessibility" + ], + "rules": { + "@angular-eslint/template/click-events-have-key-events": "off", + "@angular-eslint/template/interactive-supports-focus": "off" + } + } + ] +} diff --git a/desktop/angular/src/app/shared/netquery/textql/lexer.ts b/desktop/angular/src/app/shared/netquery/textql/lexer.ts index 008cbd6e..a3f2fe93 100644 --- a/desktop/angular/src/app/shared/netquery/textql/lexer.ts +++ b/desktop/angular/src/app/shared/netquery/textql/lexer.ts @@ -43,7 +43,7 @@ export class Lexer { } /** reads a number token */ - private readNumber(): Token { + private readNumber(): Token | null { const start = this._input.pos; let has_dot = false; @@ -59,9 +59,10 @@ export class Lexer { return isDigit(ch); }); - if (!this._input.eof() && isIdentChar(this._input.peek())) { - this._input.revert(number.length + 1); - this._input.croak("invalid number character") + if (!this._input.eof() && !isWhitespace(this._input.peek())) { + this._input.revert(number.length); + + return null; } return { @@ -182,13 +183,11 @@ export class Lexer { return this.readString('\'', true); } - try { - if (isDigit(ch)) { - return this.readNumber(); + if (isDigit(ch)) { + const number = this.readNumber(); + if (number !== null) { + return number; } - } catch (err) { - // we ignore that error here as it may only happen for unqoted strings - // that start with a number. } if (ch === ':') { From 3e2b9a9c2972ac13d630474e52e7be4069fc678b Mon Sep 17 00:00:00 2001 From: Patrick Pacher Date: Fri, 29 Mar 2024 09:36:26 +0100 Subject: [PATCH 2/6] Add remote_ip to full-text search and fix focus in netquery component --- .../src/app/shared/netquery/netquery.component.html | 8 ++++---- .../angular/src/app/shared/netquery/netquery.component.ts | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/desktop/angular/src/app/shared/netquery/netquery.component.html b/desktop/angular/src/app/shared/netquery/netquery.component.html index 8a05984b..6b5dfbf0 100644 --- a/desktop/angular/src/app/shared/netquery/netquery.component.html +++ b/desktop/angular/src/app/shared/netquery/netquery.component.html @@ -14,9 +14,9 @@ - +
@@ -129,7 +129,7 @@ Quick Settings
    -
  • {{ qds.name }}
  • @@ -350,7 +350,7 @@ d="M11 3a1 1 0 10-2 0v1a1 1 0 102 0V3zM15.657 5.757a1 1 0 00-1.414-1.414l-.707.707a1 1 0 001.414 1.414l.707-.707zM18 10a1 1 0 01-1 1h-1a1 1 0 110-2h1a1 1 0 011 1zM5.05 6.464A1 1 0 106.464 5.05l-.707-.707a1 1 0 00-1.414 1.414l.707.707zM5 10a1 1 0 01-1 1H3a1 1 0 110-2h1a1 1 0 011 1zM8 16v-1h4v1a2 2 0 11-4 0zM12 14c.015-.34.208-.646.477-.859a4 4 0 10-4.954 0c.27.213.462.519.476.859h4.002z" /> Pro Tip: - +
diff --git a/desktop/angular/src/app/shared/netquery/netquery.component.ts b/desktop/angular/src/app/shared/netquery/netquery.component.ts index d4befb47..a09d18eb 100644 --- a/desktop/angular/src/app/shared/netquery/netquery.component.ts +++ b/desktop/angular/src/app/shared/netquery/netquery.component.ts @@ -39,6 +39,7 @@ const freeTextSearchFields: (keyof Partial)[] = [ 'as_owner', 'path', 'profile_name', + 'remote_ip' ] const groupByKeys: (keyof Partial)[] = [ From 3d88b3fd3b84b6dade5f0bd62d6fb5c1761fda70 Mon Sep 17 00:00:00 2001 From: Patrick Pacher Date: Fri, 29 Mar 2024 09:36:41 +0100 Subject: [PATCH 3/6] Fix focus in sfng-select component --- desktop/angular/projects/safing/ui/src/lib/select/select.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/angular/projects/safing/ui/src/lib/select/select.html b/desktop/angular/projects/safing/ui/src/lib/select/select.html index bccf19af..c3d144eb 100644 --- a/desktop/angular/projects/safing/ui/src/lib/select/select.html +++ b/desktop/angular/projects/safing/ui/src/lib/select/select.html @@ -1,5 +1,5 @@ -