AppResolver

1. Overview

Application identity resolver that maps process command names, executable paths, and argument vectors to human-readable application names and themed icons using desktop application metadata and conservative fallbacks.

File role: Implementation. The file contains 430 lines and belongs to the util/AppResolver.cpp path.

The companion file is util/AppResolver.hpp.


2. Component Responsibilities

  • Implement the behavior declared by the corresponding header or entry-point contract.
  • Build an index from installed Gio desktop applications
  • Generate normalized lookup aliases from executable names and command lines
  • Match exact aliases and known browser/process variants
  • Reject unreliable or synthetic process identities
  • Return a safe fallback label and icon when no desktop metadata matches
  • Special-case safe local-address connections

3. Dependencies and Integration

Project-level dependencies:

  • AppResolver.hpp
  • arpa/inet.h
  • giomm/appinfo.h
  • giomm/desktopappinfo.h
  • giomm/themedicon.h

System and library dependencies:

  • algorithm
  • cctype
  • filesystem
  • mutex
  • optional
  • unordered_map
  • unordered_set

4. Declared Types

DesktopIndex

Declares a struct.


5. Constants and Fixed Configuration

The file declares or uses the following fixed values:

constexpr const char* kGenericIcon = "application-x-executable";
constexpr const char* kUnknownProcessLabel = "(processo sconosciuto)";
constexpr const char* kSafeLocalProcessLabel = "Processo locale sicuro";
constexpr const char* kSafeLocalProcessIcon = "network-workgroup";

6. Functions and Methods

The file exposes or implements 1 detected function or method signatures.

1. build_index_locked

void build_index_locked()

Builds and configures the index locked user-interface or internal structure.


7. Filesystem, IPC, Network, and Command Interfaces

Relevant literal paths, endpoints, or resource locations include:

  • /bin/sh
  • /bin/bash

8. Runtime Flow

  1. Build an index from installed Gio desktop applications
  2. Generate normalized lookup aliases from executable names and command lines
  3. Match exact aliases and known browser/process variants
  4. Reject unreliable or synthetic process identities
  5. Return a safe fallback label and icon when no desktop metadata matches
  6. Special-case safe local-address connections

9. Concurrency and Main-Loop Behavior

  • Protects shared state with a mutex.

10. Runtime and Security Considerations

  • Avoids presenting untrusted process strings as authoritative application identities.
  • Classifies loopback and private local traffic separately.
  • Uses generic icons and labels for unknown identities rather than inventing attribution.
  • Socket lifecycle and framing errors are handled without performing GTK operations directly from the I/O thread.

11. Error Handling and Operational Notes

  • Exceptions are caught locally in one or more operations to prevent application-wide termination.
  • Boolean-returning operations use false to report recoverable failure.
  • Optional results distinguish unavailable data from valid empty values.

12. Source Integrity

Relative source path: util/AppResolver.cpp

SHA-256:

77803864edcf582c256938918c3796781218f29cb53de10fb9dc32168abf77e0

13. Licensing

The source header identifies this component as distributed under the GNU General Public License version 3. BastionGuard branding and trademarks remain subject to the notices stated in the source file.