vios-error-security · git:20260603.14e198c · 2026-06-03 · sha256 45993b1dd5732fc4

vios-error-security git:20260603.14e198cA

Immutable. This exact content is served forever at /api/v1/blob/45993b1dd5732fc4.

---
description: Error handling and security rules for VIOS C++ code
globs: "**/*.cpp,**/*.h,**/*.hpp"
alwaysApply: false
---

# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Error Handling

- Log via `logger.h` using `LOG(error)` / `LOG(info)` (or appropriate `LOG(level)` macros), not `std::cerr` or `printf`
- Prefer return codes / `std::optional` / callbacks over exceptions in hot paths
- Media pipeline errors must degrade gracefully (reconnect, skip frame)

# Threading

- GStreamer pipeline callbacks run on GStreamer threads -- do not block them
- civetweb HTTP/WebSocket handlers must be non-blocking
- Protect shared state with `std::mutex` / `std::shared_mutex`; document lock ordering

# Security

- Validate all external inputs at REST API boundaries via `SchemaValidator`
- Never log credentials, tokens, or PII
- Do not bypass `UserAuthHandler`
- Run `/security-review` before committing any change