In toto

From paulpas/agent-skill-router · View interactive version

In toto is an AI agent skill from the GitHub repository paulpas/agent-skill-router. "in-toto in Supply Chain Security - cloud native architecture, patterns" pitfalls, and best practices

How to use this skill

Skill file

in-toto in Cloud-Native Engineering

Purpose and Use Cases

What Problem Does It Solve?

When to Use

Key Use Cases

Architecture Design Patterns

Core Components

In-toto Layout
{
  "_type": "layout",
  "expires": "2025-12-31T23:59:59Z",
  "keys": {
    "alice-key-id": {
      "keytype": "rsa",
      "keyid_hash_algorithms": ["sha256"],
      "keyval": {
        "public": "-----BEGIN PUBLIC KEY-----..."
      }
    }
  },
  "roles": [
    {
      "name": "root",
      "threshold": 1,
      "keyids": ["alice-key-id"]
    },
    {
      "name": "staging",
      "threshold": 2,
      "keyids": ["alice-key-id", "bob-key-id"]
    },
    {
      "name": "production",
      "threshold": 3,
      "keyids": ["alice-key-id", "bob-key-id", "carol-key-id"]
    }
  ],
  "steps": [
    {
      "name": "build",
      "expected_artifact": "app-image.tar.gz",
      "expected_command": ["make", "build"],
      "pubkeys": ["alice-key-id"],
      "threshold": 1
    },
    {
      "name": "test",
      "expected_artifact": "app-image.tar.gz",
      "expected_command": ["make", "test"],
      "pubkeys": ["bob-key-id"],
      "threshold": 1
    }
  ],
  "inspect": [
    {
      "name": "verify-integrity",
      "command": ["in-toto-run", "--", "sha256sum", "app-image.tar.gz"],
      "expected_materials": [["MATCH", "app-image.tar.gz", "WITH", "PATH", "app-image.tar.gz"]],
      "expected_products": []
    }
  ]
}
Link Metadata
{
  "_type": "link",
  "name": "build",
  "material": {
    "source-code.tar.gz": {
      "sha256": "abc123..."
    }
  },
  "product": {
    "app-image.tar.gz": {
      "sha256": "def456..."
    }
  },
  "command": ["make", "build"],
  "byproducts": {},
  "duration": 42
}
Verification Tool (in-toto-verifier)

Component Interactions

Builder (Alice)
    ↓ (builds artifact + creates link)
Link Metadata
    ↓ (signed with Alice's key)
In-toto Layout
    ↓ (defines verification policy)
Verifier (CI/CD)
    ↓ (validates all steps)
Artifact Release

Data Flow Patterns

Build Pipeline Flow
1. Developer pushes code
2. CI system triggers build
3. Build step creates link with materials/products
4. Link signed by build role key
5. Next step reads link as input material
6. Repeat for each pipeline step
7. Final artifact verified against layout
8. Signed metadata included with release
Verification Flow
1. Download artifact + in-toto metadata
2. Load layout policy
3. Verify all link signatures
4. Verify link chain: products of step N = materials of step N+1
5. Execute inspections
6. Report verification result

Design Principles

Non-Repudiation
Least Privilege
Verifiability

Integration Approaches

Integration with Other CNCF Projects

Grafeas Integration
# Grafeas Note for in-toto policy
apiVersion: grafeas.io/v1
kind: Note
metadata:
  name: projects/myproject/notes/in-toto-policy
spec:
  in_toto: {
    "step": {
      "name": "build",
      "threshold": 1
    }
  }
Tekton Chains Integration
apiVersion: chains.tekton.dev/v1beta1
kind: Configuration
metadata:
  name: chains
spec:
  artifacts:
    in_toto:
      predicate_type: in-toto.io/Link
      enabled: true
      keyless:
        subject: "https://tkn.dev/chains"
Cosign Integration
# Sign in-toto metadata with cosign
cosign sign-blob --output-signature=link.sig link.json

# Verify in-toto policy
cosign verify-blob --signature=link.sig \
  --certificate=link.pem \
  --certificate-identity=build@example.com \
  link.json
Kyverno Integration
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: require-in-toto
spec:
  rules:
    - name: check-in-toto
      match:
        any:
          - resources:
              kinds:
                - Pod
      validate:
        message: "Container images must have in-toto attestation"
        deny:
          conditions:
            - key: "{{ request.object.spec.containers[].image }}"
              operator: AnyNotIn
              value: "{{ 'images' | length(@) > 0 }}"

API Patterns

Layout API
Link API

Configuration Patterns

Layout Configuration
{
  "expires": "2025-12-31T00:00:00Z",
  "keys": {},
  "roles": {
    "root": {
      "threshold": 1,
      "keyids": []
    }
  },
  "steps": [
    {
      "name": "checkout",
      "pubkeys": [],
      "threshold": 1,
      "expected_artifacts": [],
      "expected_command": []
    }
  ]
}
Key Generation
# Generate in-toto key
in-toto-keygen -t ed25519 -u alice

# Export public key
cat alice.pub

# Import public key into layout
in-toto-sign -f layout.json -p alice.pub

Extension Mechanisms

Custom Predicate Types
Verification Integrations

Common Pitfalls and How to Avoid Them

Configuration Issues

Expired Layout

Problem: Layout file expires and verification fails.

Solution:

Missing Keys

Problem: Keys used in layout not available for verification.

Solution:

Incorrect Thresholds

Problem: Threshold too high causes legitimate failures, too low reduces security.

Solution:

Performance Issues

Large Metadata Files

Problem: Many links create large metadata files.

Solutions:

Verification Slowdown

Problem: Complex layouts with many steps slow verification.

Solutions:

Operational Challenges

Key Compromise Recovery

Problem: Key compromise requires layout update and re-signing.

Solutions:

Build Tool Integration

Problem: Existing build tools don't naturally produce in-toto links.

Solutions:

Cross-Platform Compatibility

Problem: in-toto metadata format varies between implementations.

Solutions:

Security Pitfalls

Weakened Signature Requirements

Problem: Reducing thresholds during emergencies creates security gaps.

Solutions:

Insecure Key Storage

Problem: Private keys stored in source control or accessible locations.

Solutions:

Incomplete Supply Chain Coverage

Problem: Only some steps covered, allowing bypass through uncovered steps.

Solutions:

Coding Practices

Idiomatic Configuration

Layout File Structure
{
  "_type": "layout",
  "spec_version": "1.0",
  "expires": "2025-12-31T23:59:59Z",
  "keys": {
    "keyid1": {
      "keytype": "ed25519",
      "keyval": {
        "public": "publickeybase64"
      }
    }
  },
  "roles": {
    "root": {
      "threshold": 1,
      "keyids": ["keyid1"]
    }
  },
  "steps": [],
  "inspect": []
}

API Usage Patterns

Layout Creation
# ✅ GOOD — in-toto layout creation via CLI
# Generate in-toto layout using in-toto-tool
in-toto-record start --name build --expected-products app.tar.gz

# Create initial layout file
cat > layout.json << 'EOF'
{
  "_type": "layout",
  "spec_version": "1.0",
  "expires": "2025-12-31T23:59:59Z",
  "keys": {},
  "roles": {
    "root": { "threshold": 1, "keyids": [] }
  },
  "steps": [],
  "inspect": []
}
EOF

# Add steps to layout
in-toto-layout --add-step build --pubkey alice.pub --threshold 1

# Sign layout with root key
in-toto-sign -f layout.json -k root.key
Link Generation
// Go example
link := link.Link{
    Name:      "build",
    Materials: materials,
    Products:  products,
    Command:   command,
}

link.Sign(privateKey)

Observability Best Practices

Logging Verification
Metrics Collection

Development Workflow

Layout Development
  1. Define supply chain steps
  2. Generate initial layout
  3. Test with sample builds
  4. Add signatures
  5. Verify with sample artifacts
  6. Deploy to CI/CD
  7. Monitor verification results
CI/CD Integration

Fundamentals

Essential Concepts

In-toto Metadata Format
Verification Process

Terminology Glossary

| Term | Definition |

|------|------------|

| Layout | Root policy file defining supply chain verification rules |

| Link | Metadata record for a single supply chain step execution |

| Material | Input artifact to a supply chain step |

| Product | Output artifact from a supply chain step |

| Step | A discrete action in the software supply chain |

| Inspection | Post-build verification command |

| Threshold | Number of signatures required for validity |

| Key ID | Unique identifier for a cryptographic key |

| Signature | Cryptographic proof of authorship |

| Metadata | Information about software artifacts and their history |

Data Models and Types

Layout Schema
{
  "_type": "layout",
  "spec_version": "string",
  "expires": "string (ISO 8601)",
  "keys": {
    "keyid": {
      "keytype": "string",
      "keyval": {
        "public": "string"
      }
    }
  },
  "roles": {
    "rolename": {
      "threshold": "number",
      "keyids": ["string"]
    }
  },
  "steps": [
    {
      "name": "string",
      "pubkeys": ["string"],
      "threshold": "number",
      "expected_materials": [],
      "expected_products": []
    }
  ],
  "inspect": [
    {
      "name": "string",
      "command": ["string"],
      "expected_materials": [],
      "expected_products": []
    }
  ]
}
Link Schema
{
  "_type": "link",
  "name": "string",
  "material": {
    "artifact_path": {
      "sha256": "string"
    }
  },
  "product": {
    "artifact_path": {
      "sha256": "string"
    }
  },
  "command": ["string"],
  "byproducts": {},
  "duration": "number"
}

Lifecycle Management

Layout Lifecycle
  1. Creation: Initial layout with minimal roles
  2. Signing: Root key signs initial layout
  3. Distribution: Layout distributed to all verifiers
  4. Rotation: Periodic key and layout updates
  5. Revocation: Compromised keys removed from layout
  6. Expiration: Layout expires and must be renewed
Link Lifecycle
  1. Creation: Build step generates link
  2. Signing: Step key signs link
  3. Storage: Link stored with artifact
  4. Aggregation: Multiple links combined
  5. Verification: Link verified against layout
  6. Archival: Old links archived or deleted

State Management

Layout State
Link State

Scaling and Deployment Patterns

Horizontal Scaling

Multiple Verifiers
Link Aggregation

High Availability

Verification Service Redundancy
Layout Distribution

Production Deployments

CI/CD Pipeline Integration
  1. Generate links during build
  2. Sign links with appropriate keys
  3. Store links with artifacts
  4. Verify before deployment
  5. Fail pipeline on verification failure
Deployment Gate
# GitHub Actions example
- name: Verify in-toto
  uses: in-toto/verify-action@v1
  with:
    layout: layout.json
    artifact: app.tar.gz

Upgrade Strategies

Layout Evolution
  1. Create new layout with updated rules
  2. Sign with new keys
  3. Deploy new layout alongside old
  4. Monitor verification results
  5. Switch to new layout
  6. Archive old layout
Key Rotation
  1. Generate new keys
  2. Update layout with new keys
  3. Sign layout with old keys
  4. Distribute updated layout
  5. Stop using old keys
  6. Securely delete old keys

Resource Management

Storage Optimization
Memory Constraints

Additional Resources

Official Documentation

CNCF References

Tools and Libraries

Tutorials and Guides

Community Resources

Related Standards

OpenTelemetry Integration

Troubleshooting

Common Issues

  1. Deployment Failures
  1. Performance Issues
  1. Configuration Errors
  1. Integration Problems

Getting Help

Examples

Basic Configuration

# Basic configuration example
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{project_name}}-config
  namespace: default
data:
  # Configuration goes here
  config.yaml: |
    # Base configuration
    # Add your settings here

Kubernetes Deployment

# Kubernetes deployment for {{project_name}}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{project_name}}
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{project_name}}
  template:
    metadata:
      labels:
        app: {{project_name}}
    spec:
      containers:
      - name: {{project_name}}
        image: {{project_name}}:latest
        ports:
        - containerPort: 8080
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"

Kubernetes Service

# Kubernetes service for {{project_name}}
apiVersion: v1
kind: Service
metadata:
  name: {{project_name}}
  namespace: default
spec:
  selector:
    app: {{project_name}}
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
  type: ClusterIP

When to Use

Use this skill when:


Core Workflow

  1. Assess Requirements — Understand the use case, scale, integration needs, and existing infrastructure. Checkpoint: Document requirements, constraints, and success criteria.
  1. Design Architecture — Plan component interactions, data flow, and deployment strategy using cloud-native best practices. Checkpoint: Verify the architecture addresses all requirements and follows CNCF conventions.
  1. Implement & Configure — Create manifests, configurations, and deployment scripts. Include resource limits, health checks, and observability hooks. Checkpoint: Validate all YAML against schema and test in a staging environment.
  1. Deploy & Monitor — Apply manifests to the cluster, verify component health, and confirm observability is working. Checkpoint: Confirm all pods/services are running, probes passing, and metrics/alerts configured.

Constraints

MUST DO

MUST NOT DO

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.