diff --git a/.github/workflows/offline-freeze.yml b/.github/workflows/offline-freeze.yml index 4c397fb1..99d80dda 100644 --- a/.github/workflows/offline-freeze.yml +++ b/.github/workflows/offline-freeze.yml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + name: Offline wheels freeze on: diff --git a/.github/workflows/test-databases.yml b/.github/workflows/test-databases.yml index da53c0cb..599f31fe 100644 --- a/.github/workflows/test-databases.yml +++ b/.github/workflows/test-databases.yml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + name: Database matrix on: diff --git a/CHANGELOG.md b/CHANGELOG.md index 18e7e915..ac717891 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [0.5.2] - Multi-database - 09/01/2026 +## [0.5.2] - Multi-database + k8s - 09/06/2026 Package version is **0.5.2** (`pyproject.toml`). Preferred LogstashAgent version is **0.5.2** (lockstep). @@ -61,6 +61,15 @@ SQLite does not scale under gunicorn/gevent. Operators can now run LogstashUI on - `LOGSTASHUI_TLS=false` now suppresses the Django-level HTTP→HTTPS redirect (`SECURE_SSL_REDIRECT`) in addition to disabling the Gunicorn TLS certificate. Previously, running the container with `-e LOGSTASHUI_TLS=false` still returned a `301` because `SECURE_SSL_REDIRECT` was gated on `DEBUG` only. Both knobs are now independent. - `ApiKey.save()` no longer re-hashes an already-hashed key. `make_password()` ran unconditionally on every save, so any update to an existing row silently rewrote the hash and invalidated the credential. Latent until now — nothing re-saved an `ApiKey` — but renaming or revoking a token does. - The pipeline editor's simulation **Target** picker no longer hides the embedded agent on first page load. Making the probe non-blocking left `list_simulation_targets()` requiring a successful probe it never performed, so the sticky embedded row lost a race against the background thread and the dropdown rendered empty until a later refresh. The row is now dropped only when a probe has *explicitly* reported the agent offline — never-probed is treated as unknown, not offline. Target rows also carry a `discovered` flag so callers can distinguish a confirmed agent from an unconfirmed one. +- Connection Manager – Cloud ID field bleed-through: Fixed a bug where switching from Cloud ID to URL connection type with a Cloud ID already entered would attempt to use the Cloud ID value to establish the connection instead of the URL. +- SNMP – Graceful "no data yet" error: Resolved an unhelpful error message shown to users who had successfully created a device in SNMP but for whom no data had yet been written to Elasticsearch. The experience is now clean and friendly. +- SNMP – Cancel icon color in Safari: Fixed a cross-browser rendering issue where cancel/delete icons (which should be pink) were rendering as green in Safari. +- Windows – Logging file handler: Updated the logging file handler configuration so that it works correctly on Windows (file rotation and path handling were broken on Windows previously). +- Pre-commit – Windows line endings: Fixed the add_license_headers.py script to prevent CRLF line endings from being injected when adding the NOTICE header to source files on Windows. Also retroactively corrected headers added to files that were previously missing them. + +# UI +- Modal close confirmation: Added a confirmation dialogue to modal close handlers for modals with significant user input (e.g. Connection, SNMP Device, Network, Profile modals). This prevents accidental data loss when a user clicks outside the modal. +- SNMP Device – IPv6 support: Relaxed the IP address validation on SNMP devices to accept IPv6 addresses in addition to IPv4. ### API access diff --git a/NOTICE.txt b/NOTICE.txt index 7d0a1692..4813e21d 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -2398,3 +2398,193 @@ Redistribution and use in source and binary forms, with or without modification, This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. + +-------------- psycopg -------------- + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + + +-------------- PyMySQL -------------- +Copyright (c) 2010, 2013 PyMySQL contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/bin/test_databases.sh b/bin/test_databases.sh index 63a08253..9dd98750 100755 --- a/bin/test_databases.sh +++ b/bin/test_databases.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" diff --git a/docker/docker-compose.db.yml b/docker/docker-compose.db.yml index d602fb6e..20c5c787 100644 --- a/docker/docker-compose.db.yml +++ b/docker/docker-compose.db.yml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + # Local/CI database matrix for LogstashUI. Not used by smoke compose. # Host ports avoid clashing with a developer’s own 5432/3306. name: logstashui-db-test diff --git a/docs/docs/logstashui/general/build.md b/docs/docs/logstashui/general/build.md index f4716468..153ae16a 100644 --- a/docs/docs/logstashui/general/build.md +++ b/docs/docs/logstashui/general/build.md @@ -69,6 +69,31 @@ uv run logstashui --- +## Contributing Setup (Pre-commit Hooks) + +After your first `uv sync`, install the git pre-commit hooks once: + +```bash +uv run pre-commit install +``` + +The hooks run automatically on every `git commit` and handle two things: + +- **License headers** — adds the Elastic license notice to any source file that doesn't have one yet +- **Dependency notices** — regenerates `NOTICE.txt` to reflect any new third-party packages + +### Windows developers + +Set git's line-ending mode to `input` **before your first commit**. This prevents git from converting LF to CRLF on checkout, which fights the repo's `.gitattributes` settings and produces phantom "modified" files: + +```powershell +git config --global core.autocrlf input +``` + +You only need to run this once — it applies to all your repos globally. + +--- + ## Building an sdist and wheel Compile Tailwind first (the `dist/` CSS path is not `node_modules`; repo-root `/dist/` is the packaging output): diff --git a/docs/docs/logstashui/kubernetes/examples/embedded-agent.yaml b/docs/docs/logstashui/kubernetes/examples/embedded-agent.yaml index 595f4a05..f2ba14ce 100644 --- a/docs/docs/logstashui/kubernetes/examples/embedded-agent.yaml +++ b/docs/docs/logstashui/kubernetes/examples/embedded-agent.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + # Optional embedded simulation agent (compose --profile embedded analog). # Apply a DB tree first (sqlite/ postgresql/ or mysql/), uncomment # LOGSTASH_AGENT_URL in ConfigMap/logstashui and LOGSTASHUI_AGENT_CSR_SECRET diff --git a/docs/docs/logstashui/kubernetes/examples/mysql/configmap.yaml b/docs/docs/logstashui/kubernetes/examples/mysql/configmap.yaml index 6cbe91d9..9e8f92a4 100644 --- a/docs/docs/logstashui/kubernetes/examples/mysql/configmap.yaml +++ b/docs/docs/logstashui/kubernetes/examples/mysql/configmap.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: ConfigMap metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/mysql/ingress.yaml b/docs/docs/logstashui/kubernetes/examples/mysql/ingress.yaml index 1cad21e4..a1bae431 100644 --- a/docs/docs/logstashui/kubernetes/examples/mysql/ingress.yaml +++ b/docs/docs/logstashui/kubernetes/examples/mysql/ingress.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + # Ingress-nginx: originate HTTPS to the pod and skip verify of the product leaf. # Do not set LOGSTASHUI_TLS=false on the container. apiVersion: networking.k8s.io/v1 diff --git a/docs/docs/logstashui/kubernetes/examples/mysql/namespace.yaml b/docs/docs/logstashui/kubernetes/examples/mysql/namespace.yaml index 4444b7c5..d2f1dc8a 100644 --- a/docs/docs/logstashui/kubernetes/examples/mysql/namespace.yaml +++ b/docs/docs/logstashui/kubernetes/examples/mysql/namespace.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: Namespace metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/mysql/secret.yaml b/docs/docs/logstashui/kubernetes/examples/mysql/secret.yaml index fc774a35..defc77c7 100644 --- a/docs/docs/logstashui/kubernetes/examples/mysql/secret.yaml +++ b/docs/docs/logstashui/kubernetes/examples/mysql/secret.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: Secret metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml b/docs/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml index 6f08755e..32bed1bc 100644 --- a/docs/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml +++ b/docs/docs/logstashui/kubernetes/examples/mysql/statefulset.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: Service metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml b/docs/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml index 305c5be2..671c5ecb 100644 --- a/docs/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml +++ b/docs/docs/logstashui/kubernetes/examples/postgresql/cnpg.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + # Optional. Requires the CloudNativePG operator (often in cnpg-system). # See ../../cnpg.md. After Ready, point LogstashUI at Secret logstashui-pg-app # instead of the HOST/USER/PASSWORD in configmap.yaml / secret.yaml. diff --git a/docs/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml b/docs/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml index d19d24cf..da3db7e7 100644 --- a/docs/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml +++ b/docs/docs/logstashui/kubernetes/examples/postgresql/configmap.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: ConfigMap metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml b/docs/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml index 1cad21e4..a1bae431 100644 --- a/docs/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml +++ b/docs/docs/logstashui/kubernetes/examples/postgresql/ingress.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + # Ingress-nginx: originate HTTPS to the pod and skip verify of the product leaf. # Do not set LOGSTASHUI_TLS=false on the container. apiVersion: networking.k8s.io/v1 diff --git a/docs/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml b/docs/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml index 4444b7c5..d2f1dc8a 100644 --- a/docs/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml +++ b/docs/docs/logstashui/kubernetes/examples/postgresql/namespace.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: Namespace metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/postgresql/secret.yaml b/docs/docs/logstashui/kubernetes/examples/postgresql/secret.yaml index fc774a35..defc77c7 100644 --- a/docs/docs/logstashui/kubernetes/examples/postgresql/secret.yaml +++ b/docs/docs/logstashui/kubernetes/examples/postgresql/secret.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: Secret metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml b/docs/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml index 6f08755e..32bed1bc 100644 --- a/docs/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml +++ b/docs/docs/logstashui/kubernetes/examples/postgresql/statefulset.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: Service metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml b/docs/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml index edb6b552..736a9230 100644 --- a/docs/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml +++ b/docs/docs/logstashui/kubernetes/examples/sqlite/configmap.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: ConfigMap metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml b/docs/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml index 1cad21e4..a1bae431 100644 --- a/docs/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml +++ b/docs/docs/logstashui/kubernetes/examples/sqlite/ingress.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + # Ingress-nginx: originate HTTPS to the pod and skip verify of the product leaf. # Do not set LOGSTASHUI_TLS=false on the container. apiVersion: networking.k8s.io/v1 diff --git a/docs/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml b/docs/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml index 4444b7c5..d2f1dc8a 100644 --- a/docs/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml +++ b/docs/docs/logstashui/kubernetes/examples/sqlite/namespace.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: Namespace metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/sqlite/secret.yaml b/docs/docs/logstashui/kubernetes/examples/sqlite/secret.yaml index 13e02d4c..ee80ea6b 100644 --- a/docs/docs/logstashui/kubernetes/examples/sqlite/secret.yaml +++ b/docs/docs/logstashui/kubernetes/examples/sqlite/secret.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: Secret metadata: diff --git a/docs/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml b/docs/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml index 6f08755e..32bed1bc 100644 --- a/docs/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml +++ b/docs/docs/logstashui/kubernetes/examples/sqlite/statefulset.yaml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + apiVersion: v1 kind: Service metadata: diff --git a/packaging/offline/compose.offline.yml b/packaging/offline/compose.offline.yml index 75293120..87e42bcd 100644 --- a/packaging/offline/compose.offline.yml +++ b/packaging/offline/compose.offline.yml @@ -1,3 +1,7 @@ +#Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +#or more contributor license agreements. Licensed under the Elastic License; +#you may not use this file except in compliance with the Elastic License. + # Air-gapped UI-only compose. No Agent, no embedded profile, no registry pull. # Load the image first: ./load.sh # Image: __IMAGE_NAME__ diff --git a/scripts/add_license_headers.py b/scripts/add_license_headers.py index 384bc7b7..aa299e75 100644 --- a/scripts/add_license_headers.py +++ b/scripts/add_license_headers.py @@ -172,7 +172,7 @@ def process_file(file_path, dry_run=False, verbose=False): return True else: try: - with open(file_path, 'w', encoding='utf-8') as f: + with open(file_path, 'w', encoding='utf-8', newline='\n') as f: f.write(new_content) if verbose: print(f"[MODIFIED] {file_path}") diff --git a/scripts/generate_notice.py b/scripts/generate_notice.py index f7fe611e..a3069a5c 100644 --- a/scripts/generate_notice.py +++ b/scripts/generate_notice.py @@ -468,7 +468,7 @@ def ensure_notice_header(): # Check if header is already present if not content.startswith("LogstashUI\nCopyright 2025-"): # Header missing or outdated, prepend it - with open(notice_path, "w", encoding="utf-8") as f: + with open(notice_path, "w", encoding="utf-8", newline='\n') as f: f.write(header) if content and not content.startswith("\n"): f.write("\n") @@ -486,12 +486,12 @@ def ensure_notice_header(): content, count=1 ) - with open(notice_path, "w", encoding="utf-8") as f: + with open(notice_path, "w", encoding="utf-8", newline='\n') as f: f.write(updated_content) print(f"Updated copyright year to {current_year}") else: # Create new file with header - with open(notice_path, "w", encoding="utf-8") as f: + with open(notice_path, "w", encoding="utf-8", newline='\n') as f: f.write(header) print("Created NOTICE.txt with header") @@ -531,7 +531,7 @@ def append_to_notice(package_name, license_text, license_name=None): metadata[package_name] = license_name or 'UNKNOWN' - with open(metadata_path, 'w', encoding='utf-8') as f: + with open(metadata_path, 'w', encoding='utf-8', newline='\n') as f: json.dump(metadata, f, indent=2, sort_keys=True) print(f"Added {package_name} to NOTICE.txt") @@ -739,7 +739,7 @@ def generate_dependency_tracking(all_deps, license_cache): class_width = max(max_class_len, len('Classification')) # Generate table - with open(tracking_path, 'w', encoding='utf-8') as f: + with open(tracking_path, 'w', encoding='utf-8', newline='\n') as f: # Header f.write(f"{'Dependency':<{name_width}} | {'Type':<{type_width}} | {'License':<{license_width}} | {'Classification':<{class_width}}\n") f.write(f"{'-' * name_width}-+-{'-' * type_width}-+-{'-' * license_width}-+-{'-' * class_width}\n") diff --git a/src/logstashui/LogstashUI/logging_config.py b/src/logstashui/LogstashUI/logging_config.py index 073688b1..1adf9127 100644 --- a/src/logstashui/LogstashUI/logging_config.py +++ b/src/logstashui/LogstashUI/logging_config.py @@ -6,11 +6,46 @@ from __future__ import annotations +import logging.handlers import os +import sys _ALLOWED = ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL") +class WindowsSafeRotatingFileHandler(logging.handlers.RotatingFileHandler): + """RotatingFileHandler that handles Windows file-locking during rotation gracefully. + + On Windows, os.rename() raises PermissionError (WinError 32) when another + thread still holds the log file open at the moment rotation is triggered. + Python's logging machinery re-raises this from emit(), producing a flood of + '--- Logging error ---' lines that can crash a running instance. + + This subclass overrides rotate() to catch PermissionError and skip the + current rotation cycle instead of propagating the error. The file continues + to be written to, and the next emit() that triggers shouldRollover() will + attempt rotation again. + """ + + def rotate(self, source: str, dest: str) -> None: + try: + super().rotate(source, dest) + except PermissionError: + # Another thread holds the file open; skip this rotation cycle. + # The next shouldRollover check will retry. + pass + + +# Resolved at import time so settings.py can reference it as a dotted class +# path string. On Windows we use the safe subclass above; on POSIX platforms +# os.rename() is atomic on open files so the stock handler is fine. +ROTATING_FILE_HANDLER_CLASS = ( + "LogstashUI.logging_config.WindowsSafeRotatingFileHandler" + if sys.platform == "win32" + else "logging.handlers.RotatingFileHandler" +) + + def resolve_log_level(name: str, *, default: str = "INFO") -> str: raw = (os.environ.get(name) or "").strip().upper() if not raw: diff --git a/src/logstashui/LogstashUI/settings.py b/src/logstashui/LogstashUI/settings.py index e0433a90..69547e49 100644 --- a/src/logstashui/LogstashUI/settings.py +++ b/src/logstashui/LogstashUI/settings.py @@ -28,7 +28,7 @@ warn_if_enabled, ) from .database import build_databases -from .logging_config import resolve_django_log_levels, resolve_log_level +from .logging_config import resolve_django_log_levels, resolve_log_level, ROTATING_FILE_HANDLER_CLASS from .paths import ( resolve_data_dir, resolve_docs_dir, @@ -395,11 +395,13 @@ def _get_version(): }, "file": { "level": LOGSTASHUI_LOG_LEVEL, - "class": "logging.handlers.RotatingFileHandler", + "class": ROTATING_FILE_HANDLER_CLASS, "filename": LOGS_DIR / "logstashui.log", "maxBytes": 1024 * 1024 * 10, # 10 MB "backupCount": 5, "formatter": "verbose", + "delay": True, + "encoding": "utf-8", }, }, "loggers": { diff --git a/src/logstashui/PipelineManager/forms.py b/src/logstashui/PipelineManager/forms.py index 9bff67df..74928ba0 100644 --- a/src/logstashui/PipelineManager/forms.py +++ b/src/logstashui/PipelineManager/forms.py @@ -136,16 +136,42 @@ def __init__(self, *args, **kwargs): def clean(self): cleaned_data = super().clean() connection_type = cleaned_data.get('connection_type') - + if connection_type == Connection.ConnectionType.AGENT: # For Agent connections, require either host or cloud_url if not cleaned_data.get('host') and not cleaned_data.get('cloud_url'): raise forms.ValidationError("Either Host or Cloud URL is required for Agent connections.") else: # CENTRALIZED - # For Centralized connections, require either cloud_id or cloud_url - if not cleaned_data.get('cloud_id') and not cleaned_data.get('host'): - raise forms.ValidationError("Either Cloud ID or host is required for centralized connections.") - + # Read the radio-button selections from raw POST data so we can zero + # out whichever fields the user hid before submitting. Hidden inputs + # are still included in the POST payload, so without this a stale + # cloud_id (or stale auth credential) silently wins even after the + # user has switched modes. + connection_mode = self.data.get('connection_mode', 'cloud') + auth_type = self.data.get('auth_type', 'basic') + + # --- Connection mode --- + if connection_mode == 'cloud': + # URL-mode fields should be ignored + cleaned_data['host'] = '' + cleaned_data['port'] = None + if not cleaned_data.get('cloud_id'): + raise forms.ValidationError("Cloud ID is required when using Cloud ID mode.") + else: # 'url' + # Cloud ID field should be ignored + cleaned_data['cloud_id'] = '' + if not cleaned_data.get('host'): + raise forms.ValidationError("Host is required when using Elastic Node URL mode.") + + # --- Auth type --- + if auth_type == 'basic': + # API key field should be ignored + cleaned_data['api_key'] = '' + else: # 'apiKey' + # Username / password fields should be ignored + cleaned_data['username'] = '' + cleaned_data['password'] = '' + return cleaned_data def save(self, commit=True): diff --git a/src/logstashui/PipelineManager/templates/components/pipeline_manager/connection_modal.html b/src/logstashui/PipelineManager/templates/components/pipeline_manager/connection_modal.html index f5c8f3a2..a8058ec8 100644 --- a/src/logstashui/PipelineManager/templates/components/pipeline_manager/connection_modal.html +++ b/src/logstashui/PipelineManager/templates/components/pipeline_manager/connection_modal.html @@ -5,8 +5,8 @@ --> -