# camptocamp/puppet-windows_securityoptions architecture

> Architecture diagram of the GitHub repository camptocamp/puppet-windows_securityoptions, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/camptocamp/puppet-windows_securityoptions
- Repository: https://github.com/camptocamp/puppet-windows_securityoptions

## Overview

##### Project Type and Purpose
- This is an open-source Puppet module (puppet-windows_securityoptions) for managing Windows Local Security Policy settings via Microsoft’s secedit.exe.
- It defines custom Puppet resource types (`so_privilegerights`, `so_registryvalue`, `so_systemaccess` and their “fragment” variants) and corresponding providers that shell out to `secedit.exe`.
- It includes shared Ruby libraries for mapping between the “short” and “long” secedit names and merges multiple fragments into a single policy application.

##### File Structure Analysis
- Top-level:
- metadata.json, Gemfile, Rakefile, README.md, REFERENCE.md, CHANGELOG.md
- CI/config files: .travis.yml, .gitlab-ci.yml, appveyor.yml, etc.
- data/common.yaml, hiera.yaml (Hiera integration)
- lib/puppet/type – Puppet type definitions
- lib/puppet/provider – Provider classes implementing resource syncing via secedit.exe
- lib/puppet_x/securityoptions – Shared helper code and `secedit_mapping.json`
- spec/ – Unit tests for types, providers, and helper code

##### Key Architectural Insights from README
- All providers subclass a common “windows_securityoptions” base.
- On the first resource instantiation, the module runs `secedit.exe /export` and writes `secedit_exports.txt` to the Puppet cache.
- Providers consult the JSON mapping file to validate and translate names.
- Fragment types collect partial settings; a final merged resource applies them all in one secedit call.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Puppet Agent & Catalog
    Agent["Puppet Agent\n(runs catalog)"]:::external
    Agent -->|"reads catalog"| TypesGroup

    %% Hiera Data Source
    subgraph "Hiera Data Source"
        Hiera["Hiera\n(data/common.yaml,\nhiera.yaml)"]:::hiera
    end
    Agent -->|"lookup parameters"| Hiera
    Hiera -->|"provides data"| TypesGroup

    %% DSL Types
    subgraph "Puppet DSL Types" 
        direction TB
        SoPriv["so_privilegerights"]:::dsl
        SoPrivFrag["so_privilegerights_fragment"]:::dsl
        SoReg["so_registryvalue"]:::dsl
        SoSys["so_systemaccess"]:::dsl
    end
    TypesGroup((" ")) --> SoPriv
    TypesGroup --> SoPrivFrag
    TypesGroup --> SoReg
    TypesGroup --> SoSys

    %% Provider Layer
    subgraph "Provider Layer"
        direction TB
        BaseProv["windows_securityoptions\n(base)"]:::provider
        ProvPriv["so_privilegerights\nprovider"]:::provider
        ProvReg["so_registryvalue\nprovider"]:::provider
        ProvSys["so_systemaccess\nprovider"]:::provider
    end
    SoPriv --> ProvPriv
    SoPrivFrag --> ProvPriv
    SoReg --> ProvReg
    SoSys --> ProvSys
    ProvPriv --> BaseProv
    ProvReg --> BaseProv
    ProvSys --> BaseProv

    %% Shared Helpers
    subgraph "Shared Helper Module"
        direction TB
        MappingJSON["secedit_mapping.json"]:::helper
        MappingRB["secedit_mapping.rb"]:::helper
        SampleOut["securityoptionsoutput.txt"]:::helper
    end
    BaseProv -->|"reads mapping"| MappingJSON
    BaseProv -->|"uses helper"| MappingRB
    BaseProv -->|"sample export"| SampleOut

    %% External & Cache
    subgraph "External & Cache Artifacts"
        direction TB
        SecExe["secedit.exe"]:::external
        CacheFile["secedit_exports.txt"]:::external
        SecPolicy["Windows Local Security Policy"]:::external
    end
    BaseProv -->|"on first run calls export"| SecExe
    SecExe -->|"writes"| CacheFile
    BaseProv -->|"reads cache"| CacheFile
    BaseProv -->|"merge fragments\n& generate config"| CacheFile
    BaseProv -->|"calls configure"| SecExe
    SecExe -->|"applies policy"| SecPolicy

    %% Click Events for component mapping
    click SoPriv "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet/type/so_privilegerights.rb"
    click SoPrivFrag "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet/type/so_privilegerights_fragment.rb"
    click SoReg "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet/type/so_registryvalue.rb"
    click SoSys "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet/type/so_systemaccess.rb"
    click BaseProv "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet/provider/windows_securityoptions.rb"
    click ProvPriv "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet/provider/so_privilegerights/so_privilegerights.rb"
    click ProvReg "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet/provider/so_registryvalue/so_registryvalue.rb"
    click ProvSys "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet/provider/so_systemaccess/so_systemaccess.rb"
    click MappingJSON "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet_x/securityoptions/secedit_mapping.json"
    click MappingRB "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet_x/securityoptions/secedit_mapping.rb"
    click SampleOut "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/lib/puppet_x/securityoptions/securityoptionsoutput.txt"
    click Hiera "https://github.com/camptocamp/puppet-windows_securityoptions/blob/master/data/common.yaml"

    %% Styles
    classDef dsl fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef provider fill:#d4edda,stroke:#333,stroke-width:1px
    classDef helper fill:#d1ecf1,stroke:#333,stroke-width:1px
    classDef external fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef hiera fill:#e2e3e5,stroke:#333,stroke-width:1px

    %% Invisible group node
    class TypesGroup invisible
    class TypesGroup fill:none,stroke:none

    style TypesGroup fill:none,stroke:none,opacity:0
```
