ma-agents 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/skills/.ma-agents.json +99 -99
- package/.roo/rules/00-ma-agents.md +13 -0
- package/.roo/skills/.ma-agents.json +241 -0
- package/.roo/skills/MANIFEST.yaml +254 -0
- package/.roo/skills/ai-audit-trail/SKILL.md +23 -0
- package/.roo/skills/auto-bug-detection/SKILL.md +169 -0
- package/.roo/skills/cmake-best-practices/SKILL.md +64 -0
- package/.roo/skills/cmake-best-practices/examples/cmake.md +59 -0
- package/.roo/skills/code-documentation/SKILL.md +57 -0
- package/.roo/skills/code-documentation/examples/cpp.md +29 -0
- package/.roo/skills/code-documentation/examples/csharp.md +28 -0
- package/.roo/skills/code-documentation/examples/javascript_typescript.md +28 -0
- package/.roo/skills/code-documentation/examples/python.md +57 -0
- package/.roo/skills/code-review/SKILL.md +43 -0
- package/.roo/skills/commit-message/SKILL.md +79 -0
- package/.roo/skills/cpp-best-practices/SKILL.md +234 -0
- package/.roo/skills/cpp-best-practices/examples/modern-idioms.md +189 -0
- package/.roo/skills/cpp-best-practices/examples/naming-and-organization.md +102 -0
- package/.roo/skills/cpp-concurrency-safety/SKILL.md +60 -0
- package/.roo/skills/cpp-concurrency-safety/examples/concurrency.md +73 -0
- package/.roo/skills/cpp-const-correctness/SKILL.md +63 -0
- package/.roo/skills/cpp-const-correctness/examples/const_correctness.md +54 -0
- package/.roo/skills/cpp-memory-handling/SKILL.md +42 -0
- package/.roo/skills/cpp-memory-handling/examples/modern-cpp.md +49 -0
- package/.roo/skills/cpp-memory-handling/examples/smart-pointers.md +46 -0
- package/.roo/skills/cpp-modern-composition/SKILL.md +64 -0
- package/.roo/skills/cpp-modern-composition/examples/composition.md +51 -0
- package/.roo/skills/cpp-robust-interfaces/SKILL.md +55 -0
- package/.roo/skills/cpp-robust-interfaces/examples/interfaces.md +56 -0
- package/.roo/skills/create-hardened-docker-skill/SKILL.md +637 -0
- package/.roo/skills/create-hardened-docker-skill/scripts/create-all.sh +489 -0
- package/.roo/skills/csharp-best-practices/SKILL.md +278 -0
- package/.roo/skills/docker-hardening-verification/SKILL.md +28 -0
- package/.roo/skills/docker-hardening-verification/scripts/verify-hardening.sh +39 -0
- package/.roo/skills/docker-image-signing/SKILL.md +28 -0
- package/.roo/skills/docker-image-signing/scripts/sign-image.sh +33 -0
- package/.roo/skills/document-revision-history/SKILL.md +104 -0
- package/.roo/skills/git-workflow-skill/SKILL.md +194 -0
- package/.roo/skills/git-workflow-skill/hooks/commit-msg +61 -0
- package/.roo/skills/git-workflow-skill/hooks/pre-commit +38 -0
- package/.roo/skills/git-workflow-skill/hooks/prepare-commit-msg +56 -0
- package/.roo/skills/git-workflow-skill/scripts/finish-feature.sh +192 -0
- package/.roo/skills/git-workflow-skill/scripts/install-hooks.sh +55 -0
- package/.roo/skills/git-workflow-skill/scripts/start-feature.sh +110 -0
- package/.roo/skills/git-workflow-skill/scripts/validate-workflow.sh +229 -0
- package/.roo/skills/js-ts-dependency-mgmt/SKILL.md +49 -0
- package/.roo/skills/js-ts-dependency-mgmt/examples/dependency_mgmt.md +60 -0
- package/.roo/skills/js-ts-security-skill/SKILL.md +64 -0
- package/.roo/skills/js-ts-security-skill/scripts/verify-security.sh +136 -0
- package/.roo/skills/logging-best-practices/SKILL.md +50 -0
- package/.roo/skills/logging-best-practices/examples/cpp.md +36 -0
- package/.roo/skills/logging-best-practices/examples/csharp.md +49 -0
- package/.roo/skills/logging-best-practices/examples/javascript.md +77 -0
- package/.roo/skills/logging-best-practices/examples/python.md +57 -0
- package/.roo/skills/logging-best-practices/references/logging-standards.md +29 -0
- package/.roo/skills/open-presentation/SKILL.md +35 -0
- package/.roo/skills/opentelemetry-best-practices/SKILL.md +34 -0
- package/.roo/skills/opentelemetry-best-practices/examples/go.md +32 -0
- package/.roo/skills/opentelemetry-best-practices/examples/javascript.md +58 -0
- package/.roo/skills/opentelemetry-best-practices/examples/python.md +37 -0
- package/.roo/skills/opentelemetry-best-practices/references/otel-standards.md +37 -0
- package/.roo/skills/python-best-practices/SKILL.md +385 -0
- package/.roo/skills/python-dependency-mgmt/SKILL.md +42 -0
- package/.roo/skills/python-dependency-mgmt/examples/dependency_mgmt.md +67 -0
- package/.roo/skills/python-security-skill/SKILL.md +56 -0
- package/.roo/skills/python-security-skill/examples/security.md +56 -0
- package/.roo/skills/self-signed-cert/SKILL.md +42 -0
- package/.roo/skills/self-signed-cert/scripts/generate-cert.ps1 +45 -0
- package/.roo/skills/self-signed-cert/scripts/generate-cert.sh +43 -0
- package/.roo/skills/skill-creator/SKILL.md +196 -0
- package/.roo/skills/skill-creator/references/output-patterns.md +82 -0
- package/.roo/skills/skill-creator/references/workflows.md +28 -0
- package/.roo/skills/skill-creator/scripts/init_skill.py +208 -0
- package/.roo/skills/skill-creator/scripts/package_skill.py +99 -0
- package/.roo/skills/skill-creator/scripts/quick_validate.py +113 -0
- package/.roo/skills/story-status-lookup/SKILL.md +78 -0
- package/.roo/skills/test-accompanied-development/SKILL.md +50 -0
- package/.roo/skills/test-generator/SKILL.md +65 -0
- package/.roo/skills/vercel-react-best-practices/SKILL.md +109 -0
- package/.roo/skills/verify-hardened-docker-skill/SKILL.md +442 -0
- package/.roo/skills/verify-hardened-docker-skill/scripts/verify-docker-hardening.sh +439 -0
- package/README.md +2 -1
- package/lib/agents.js +23 -0
- package/package.json +4 -3
- package/test/roo-code-agent.test.js +166 -0
- package/test/roo-code-injection.test.js +172 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: C# Best Practices
|
|
3
|
+
description: Comprehensive C# coding standards covering modern C# (C# 10-12), async/await, LINQ, dependency injection basics, nullable reference types, and testing conventions.
|
|
4
|
+
---
|
|
5
|
+
# C# Best Practices
|
|
6
|
+
|
|
7
|
+
Coding standards for modern C# (C# 10+) across .NET 6 through .NET 8+. This skill covers language-level patterns. Framework-specific patterns (ASP.NET Core middleware, EF Core, Blazor) belong in future skills.
|
|
8
|
+
|
|
9
|
+
## 1. Naming Conventions
|
|
10
|
+
|
|
11
|
+
**Rule:** Use consistent naming to maximize code readability and tooling support.
|
|
12
|
+
|
|
13
|
+
| Element | Convention | Example |
|
|
14
|
+
|---------|-----------|---------|
|
|
15
|
+
| Namespace | PascalCase, match folder | `MyApp.Services` |
|
|
16
|
+
| Class / Struct / Record | PascalCase | `CustomerService` |
|
|
17
|
+
| Interface | `I` + PascalCase | `ICustomerService` |
|
|
18
|
+
| Method | PascalCase | `GetCustomerAsync` |
|
|
19
|
+
| Property | PascalCase | `FirstName` |
|
|
20
|
+
| Local variable | camelCase | `customerCount` |
|
|
21
|
+
| Parameter | camelCase | `customerId` |
|
|
22
|
+
| Private field | `_` + camelCase | `_logger` |
|
|
23
|
+
| Constant | PascalCase | `MaxRetryCount` |
|
|
24
|
+
| Enum type | PascalCase singular | `OrderStatus` |
|
|
25
|
+
| Enum member | PascalCase | `OrderStatus.Pending` |
|
|
26
|
+
| Async method | suffix `Async` | `SaveAsync` |
|
|
27
|
+
|
|
28
|
+
## 2. Code Organization
|
|
29
|
+
|
|
30
|
+
**Rule:** One type per file; namespace matches folder path.
|
|
31
|
+
|
|
32
|
+
- File-scoped namespace declaration (C# 10+): `namespace MyApp.Services;` — no extra indentation level.
|
|
33
|
+
- Organize types in the order: constants, fields, constructors, properties, methods (public first, then private).
|
|
34
|
+
- Use `global using` directives in a dedicated `GlobalUsings.cs` file to eliminate repetitive `using` statements project-wide.
|
|
35
|
+
- Prefer `record` types for immutable data containers; use `record struct` for small value-type data.
|
|
36
|
+
|
|
37
|
+
## 3. Nullable Reference Types
|
|
38
|
+
|
|
39
|
+
**Rule:** Enable NRT project-wide and treat warnings as errors.
|
|
40
|
+
|
|
41
|
+
```xml
|
|
42
|
+
<Nullable>enable</Nullable>
|
|
43
|
+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- Never use `!` (null-forgiving) to silence warnings without a documented reason.
|
|
47
|
+
- Use `string?` for intentionally nullable references; non-nullable types must be initialized before use.
|
|
48
|
+
- Initialize fields in the constructor or use `required` members (C# 11+) to enforce initialization at the call site.
|
|
49
|
+
|
|
50
|
+
```csharp
|
|
51
|
+
public class Order
|
|
52
|
+
{
|
|
53
|
+
public required string CustomerId { get; init; }
|
|
54
|
+
public string? Notes { get; init; }
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 4. Modern C# Language Features
|
|
59
|
+
|
|
60
|
+
### 4.1 Primary Constructors (C# 12)
|
|
61
|
+
|
|
62
|
+
Use primary constructors for classes and structs that primarily capture injected dependencies.
|
|
63
|
+
|
|
64
|
+
```csharp
|
|
65
|
+
public class OrderService(IOrderRepository repository, ILogger<OrderService> logger)
|
|
66
|
+
{
|
|
67
|
+
public async Task<Order?> GetAsync(int id, CancellationToken ct)
|
|
68
|
+
{
|
|
69
|
+
logger.LogInformation("Getting order {Id}", id);
|
|
70
|
+
return await repository.FindAsync(id, ct);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 4.2 Collection Expressions (C# 12)
|
|
76
|
+
|
|
77
|
+
Prefer collection expressions over explicit constructors for collection initialization.
|
|
78
|
+
|
|
79
|
+
```csharp
|
|
80
|
+
// Preferred
|
|
81
|
+
int[] ids = [1, 2, 3];
|
|
82
|
+
List<string> names = ["Alice", "Bob"];
|
|
83
|
+
|
|
84
|
+
// Also valid for spread
|
|
85
|
+
int[] combined = [..ids, 4, 5];
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 4.3 Raw String Literals (C# 11)
|
|
89
|
+
|
|
90
|
+
Use raw string literals for JSON, SQL, or multi-line strings to avoid escaping.
|
|
91
|
+
|
|
92
|
+
```csharp
|
|
93
|
+
var json = """
|
|
94
|
+
{
|
|
95
|
+
"name": "Alice",
|
|
96
|
+
"age": 30
|
|
97
|
+
}
|
|
98
|
+
""";
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 4.4 Pattern Matching
|
|
102
|
+
|
|
103
|
+
Use pattern matching to simplify type checks and conditional logic.
|
|
104
|
+
|
|
105
|
+
```csharp
|
|
106
|
+
// Type patterns
|
|
107
|
+
string Describe(object obj) => obj switch
|
|
108
|
+
{
|
|
109
|
+
int n when n > 0 => "positive integer",
|
|
110
|
+
int n => "non-positive integer",
|
|
111
|
+
string s => $"string: {s}",
|
|
112
|
+
null => "null",
|
|
113
|
+
_ => "other"
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// List patterns (C# 11)
|
|
117
|
+
bool IsFirstTwo(int[] arr) => arr is [var first, var second, ..];
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 4.5 Records and Record Structs
|
|
121
|
+
|
|
122
|
+
Use `record` for immutable reference-type DTOs and value objects. Use `readonly record struct` for small immutable value types that benefit from stack allocation.
|
|
123
|
+
|
|
124
|
+
```csharp
|
|
125
|
+
// Reference-type record (class semantics, heap allocated)
|
|
126
|
+
public record Address(string Street, string City, string PostalCode);
|
|
127
|
+
|
|
128
|
+
// with-expressions for non-destructive mutation
|
|
129
|
+
var updated = original with { City = "New York" };
|
|
130
|
+
|
|
131
|
+
// Value-type record (struct semantics, stack allocated)
|
|
132
|
+
public readonly record struct Point(double X, double Y);
|
|
133
|
+
|
|
134
|
+
// Mutable record struct — only when mutation is explicitly needed
|
|
135
|
+
public record struct Range(int Start, int End);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Choose `readonly record struct` over `record` when: the data is small (2-4 fields), frequently allocated in hot paths, and value semantics (equality by value, copied on assignment) are correct.
|
|
139
|
+
|
|
140
|
+
### 4.6 File-Scoped Types (C# 11)
|
|
141
|
+
|
|
142
|
+
Use the `file` access modifier to restrict a type's visibility to the single file where it is declared. This is useful for implementation detail types that should not leak into other files.
|
|
143
|
+
|
|
144
|
+
```csharp
|
|
145
|
+
// Only visible within this .cs file — cannot be used from any other file
|
|
146
|
+
file class OrderValidator
|
|
147
|
+
{
|
|
148
|
+
public bool IsValid(Order order) => order.CustomerId is not null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Also applies to records, structs, interfaces, delegates
|
|
152
|
+
file record struct ValidationResult(bool IsValid, string? Error);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Use `file`-scoped types for: helper classes private to a single implementation file, source generators' internal scaffolding, and avoiding name collisions across files without polluting `internal` scope.
|
|
156
|
+
|
|
157
|
+
## 5. Async/Await
|
|
158
|
+
|
|
159
|
+
**Rule:** Use async all the way up the call stack; never block on async code.
|
|
160
|
+
|
|
161
|
+
- Prefer `async Task` / `async Task<T>` over returning naked `Task`.
|
|
162
|
+
- Never use `async void` except for event handlers; use `async Task` instead.
|
|
163
|
+
- Always propagate `CancellationToken` from public API boundaries down to I/O calls.
|
|
164
|
+
- Prefer `ConfigureAwait(false)` in library code where the calling context does not matter.
|
|
165
|
+
- Use `ValueTask<T>` when a method frequently returns a synchronous result (hot-path optimization); default to `Task<T>` for simplicity.
|
|
166
|
+
|
|
167
|
+
```csharp
|
|
168
|
+
// Correct — async all the way, CancellationToken propagated, ConfigureAwait in library code
|
|
169
|
+
public async Task<Order?> FindOrderAsync(int id, CancellationToken ct = default)
|
|
170
|
+
{
|
|
171
|
+
return await _repository.GetByIdAsync(id, ct).ConfigureAwait(false);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Correct — multiple I/O operations with cancellation
|
|
175
|
+
public async Task<IReadOnlyList<Order>> GetActiveOrdersAsync(CancellationToken ct = default)
|
|
176
|
+
{
|
|
177
|
+
var orders = await _repository.ListAsync(ct).ConfigureAwait(false);
|
|
178
|
+
return orders.Where(o => o.IsActive).ToList();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Wrong — blocks the thread pool, risks deadlock
|
|
182
|
+
public Order? FindOrder(int id) => FindOrderAsync(id).Result;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## 6. LINQ
|
|
186
|
+
|
|
187
|
+
**Rule:** Prefer method syntax; be aware of deferred execution.
|
|
188
|
+
|
|
189
|
+
- Use method syntax (`Where`, `Select`, `FirstOrDefault`) over query syntax for consistency with the rest of the codebase.
|
|
190
|
+
- LINQ queries execute lazily — materialize with `.ToList()`, `.ToArray()`, or `.ToDictionary()` when the result will be enumerated more than once or when you need a stable snapshot.
|
|
191
|
+
- Avoid LINQ inside tight loops on large collections; profile before assuming LINQ is a bottleneck.
|
|
192
|
+
- For in-memory filtering on large datasets, consider `AsSpan()` or `ArrayPool<T>` instead of repeated LINQ queries.
|
|
193
|
+
|
|
194
|
+
```csharp
|
|
195
|
+
// Materialize when enumerating multiple times
|
|
196
|
+
var activeOrders = orders.Where(o => o.IsActive).ToList();
|
|
197
|
+
|
|
198
|
+
// Avoid multiple enumeration of IEnumerable
|
|
199
|
+
foreach (var order in activeOrders) { /* ... */ }
|
|
200
|
+
int count = activeOrders.Count;
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## 7. Error Handling
|
|
204
|
+
|
|
205
|
+
**Rule:** Use structured exception handling; reserve exceptions for truly exceptional conditions.
|
|
206
|
+
|
|
207
|
+
- Define a domain exception hierarchy derived from a base exception: `AppException : Exception`.
|
|
208
|
+
- Use the Result pattern for expected failure cases (validation, not-found) where exceptions are expensive overhead.
|
|
209
|
+
- For HTTP APIs, structure error responses using ProblemDetails (RFC 9457) — the language-level concern is ensuring your exceptions carry enough data to produce one; the middleware that converts them belongs in a future `csharp-aspnet-patterns` skill.
|
|
210
|
+
- Never swallow exceptions silently; always log or rethrow.
|
|
211
|
+
|
|
212
|
+
```csharp
|
|
213
|
+
// Result pattern for expected failures
|
|
214
|
+
public record Result<T>(T? Value, string? Error)
|
|
215
|
+
{
|
|
216
|
+
public bool IsSuccess => Error is null;
|
|
217
|
+
public static Result<T> Ok(T value) => new(value, null);
|
|
218
|
+
public static Result<T> Fail(string error) => new(default, error);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Exception hierarchy
|
|
222
|
+
public class AppException(string message) : Exception(message);
|
|
223
|
+
public class NotFoundException(string entity, object id)
|
|
224
|
+
: AppException($"{entity} with id '{id}' was not found.");
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## 8. Dependency Injection
|
|
228
|
+
|
|
229
|
+
**Rule:** Favor constructor injection; choose service lifetimes deliberately.
|
|
230
|
+
|
|
231
|
+
- Constructor injection is the standard pattern — inject only what the type needs.
|
|
232
|
+
- **Singleton:** One instance for the application lifetime. Use for stateless services and configuration.
|
|
233
|
+
- **Scoped:** One instance per request (web) or operation scope. Use for database contexts and unit-of-work patterns.
|
|
234
|
+
- **Transient:** New instance per resolution. Use for lightweight, stateless utilities.
|
|
235
|
+
- Never inject a Scoped or Transient service into a Singleton — this causes captive dependency bugs.
|
|
236
|
+
|
|
237
|
+
```csharp
|
|
238
|
+
// Registration via IServiceCollection (Microsoft.Extensions.DependencyInjection)
|
|
239
|
+
// Works in console apps, workers, ASP.NET Core, and any .NET host
|
|
240
|
+
IServiceCollection services = new ServiceCollection();
|
|
241
|
+
services.AddSingleton<IConfigService, ConfigService>();
|
|
242
|
+
services.AddScoped<IOrderService, OrderService>();
|
|
243
|
+
services.AddTransient<IEmailFormatter, EmailFormatter>();
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## 9. Testing
|
|
247
|
+
|
|
248
|
+
**Rule:** Follow Arrange-Act-Assert; use framework-agnostic patterns.
|
|
249
|
+
|
|
250
|
+
- Name tests: `MethodName_StateUnderTest_ExpectedBehavior`.
|
|
251
|
+
- Arrange all preconditions, act on the system under test, assert the single observable outcome.
|
|
252
|
+
- Major test frameworks: xUnit (most popular for .NET), NUnit, MSTest — choose based on team preference.
|
|
253
|
+
- Popular assertion libraries: FluentAssertions, Shouldly. Popular mock libraries: NSubstitute, Moq.
|
|
254
|
+
- Avoid test logic that depends on execution order; each test must be independent.
|
|
255
|
+
|
|
256
|
+
```csharp
|
|
257
|
+
// xUnit example (patterns apply to NUnit/MSTest)
|
|
258
|
+
public class OrderServiceTests
|
|
259
|
+
{
|
|
260
|
+
[Fact]
|
|
261
|
+
public async Task GetAsync_ExistingId_ReturnsOrder()
|
|
262
|
+
{
|
|
263
|
+
// Arrange
|
|
264
|
+
var repository = Substitute.For<IOrderRepository>();
|
|
265
|
+
var logger = Substitute.For<ILogger<OrderService>>();
|
|
266
|
+
repository.FindAsync(1, Arg.Any<CancellationToken>())
|
|
267
|
+
.Returns(new Order { Id = 1 });
|
|
268
|
+
var sut = new OrderService(repository, logger);
|
|
269
|
+
|
|
270
|
+
// Act
|
|
271
|
+
var result = await sut.GetAsync(1, CancellationToken.None);
|
|
272
|
+
|
|
273
|
+
// Assert
|
|
274
|
+
result.Should().NotBeNull();
|
|
275
|
+
result!.Id.Should().Be(1);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Docker Hardening Verification
|
|
3
|
+
description: Audits Docker images for security best practices, least privilege, and OpenShift compliance.
|
|
4
|
+
---
|
|
5
|
+
# Docker Hardening Verification
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
Audit Docker images to ensure they follow security best practices, specifically focusing on non-root execution and least privilege principles required for hardened clusters like OpenShift.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
1. **Inspect Image**: Use `docker inspect` or `podman inspect` to check metadata.
|
|
12
|
+
2. **Verify User**:
|
|
13
|
+
- Ensure `USER` is defined and is NOT `root` or `0`.
|
|
14
|
+
- Recommended: Use a high-numbered UID (e.g., `1001`).
|
|
15
|
+
3. **Check Permissions**:
|
|
16
|
+
- Ensure sensitive directories are not world-writable.
|
|
17
|
+
- Check for `setuid`/`setgid` bits on binaries.
|
|
18
|
+
4. **OpenShift Compliance**:
|
|
19
|
+
- Verify that the image doesn't require specific UIDs if it's meant to run with an arbitrary assigned UID (OpenShift's default).
|
|
20
|
+
- Check if the `/etc/passwd` entry handles arbitrary UIDs (e.g., by using `nss_wrapper` or similar).
|
|
21
|
+
|
|
22
|
+
## Rules
|
|
23
|
+
- Fail the audit if `USER root` is detected.
|
|
24
|
+
- Flag a warning if many unnecessary packages/tools are present.
|
|
25
|
+
- Ensure only necessary ports are exposed.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
Run `scripts/verify-hardening.sh <image_name>`
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# verify-hardening.sh - Part of ma-agents docker-hardening-verification skill
|
|
3
|
+
|
|
4
|
+
IMAGE=$1
|
|
5
|
+
|
|
6
|
+
if [ -z "$IMAGE" ]; then
|
|
7
|
+
echo "Usage: $0 <image_name>"
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
echo "Auditing image: $IMAGE"
|
|
12
|
+
|
|
13
|
+
# 1. Check User
|
|
14
|
+
USER_VAL=$(docker inspect --format='{{.Config.User}}' "$IMAGE")
|
|
15
|
+
|
|
16
|
+
if [ -z "$USER_VAL" ] || [ "$USER_VAL" == "root" ] || [ "$USER_VAL" == "0" ]; then
|
|
17
|
+
echo "[FAIL] Image runs as root! Definining a non-root USER is mandatory for hardened clusters."
|
|
18
|
+
else
|
|
19
|
+
echo "[PASS] Image runs as user: $USER_VAL"
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# 2. Check for sensitive capabilities (simplified check)
|
|
23
|
+
CAPS=$(docker inspect --format='{{.Config.CapAdd}}' "$IMAGE")
|
|
24
|
+
if [ "$CAPS" != "<nil>" ] && [ -n "$CAPS" ]; then
|
|
25
|
+
echo "[WARNING] Image has explicitly added capabilities: $CAPS"
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# 3. Check for exposed ports
|
|
29
|
+
PORTS=$(docker inspect --format='{{range $p, $conf := .Config.ExposedPorts}}{{$p}} {{end}}' "$IMAGE")
|
|
30
|
+
echo "[INFO] Exposed ports: ${PORTS:-none}"
|
|
31
|
+
|
|
32
|
+
# 4. OpenShift specific check (arbitrary UID support)
|
|
33
|
+
# This is a heuristic check looking for common entrypoint patterns
|
|
34
|
+
ENTRYPOINT=$(docker inspect --format='{{.Config.Entrypoint}}' "$IMAGE")
|
|
35
|
+
if [[ "$ENTRYPOINT" == *"bash"* ]]; then
|
|
36
|
+
echo "[INFO] Entrypoint uses bash, manual check for UID mapping recommended."
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
echo "Summary: Audit complete for $IMAGE"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Docker Image Signing
|
|
3
|
+
description: Automates the signing of Docker images using certificates and Cosign/Notary.
|
|
4
|
+
---
|
|
5
|
+
# Docker Image Signing
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
Ensure the integrity and authenticity of Docker images by signing them with a cryptographic key/certificate. This prevents unauthorized image substitution and ensures only trusted images are deployed.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
1. **Tool Selection**: Use `cosign` (recommended) or `notary`.
|
|
12
|
+
2. **Environment Check**: Verify that the signing tool and Docker/Podman are installed.
|
|
13
|
+
3. **Signing Process**:
|
|
14
|
+
- Load the provided certificate/key.
|
|
15
|
+
- Run the signing command against the target image (using its SHA256 digest for immutability).
|
|
16
|
+
4. **Verification**: Always run a verification check immediately after signing.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- NEVER sign images by tag alone; use the immutable digest (e.g., `image@sha256:...`).
|
|
20
|
+
- Private keys must be handled as secrets and never stored in the clear.
|
|
21
|
+
- Ensure the certificate provided is valid and not expired.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
Run the provided script in `scripts/sign-image.sh` with:
|
|
25
|
+
- `IMAGE`: The image reference with digest.
|
|
26
|
+
- `CERT`: Path to the certificate file.
|
|
27
|
+
- `KEY`: Path to the private key file.
|
|
28
|
+
- `PASSPHRASE`: (Optional) Key passphrase.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# sign-image.sh - Part of ma-agents docker-image-signing skill
|
|
3
|
+
|
|
4
|
+
IMAGE=$1
|
|
5
|
+
CERT=$2
|
|
6
|
+
KEY=$3
|
|
7
|
+
PASSPHRASE=$4
|
|
8
|
+
|
|
9
|
+
if [ -z "$IMAGE" ] || [ -z "$CERT" ] || [ -z "$KEY" ]; then
|
|
10
|
+
echo "Usage: $0 <image_digest> <cert_file> <key_file> [passphrase]"
|
|
11
|
+
exit 1
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
echo "Signing image: $IMAGE"
|
|
15
|
+
|
|
16
|
+
# Check for cosign
|
|
17
|
+
if command -v cosign &> /dev/null; then
|
|
18
|
+
echo "Using Cosign for signing..."
|
|
19
|
+
if [ -n "$PASSPHRASE" ]; then
|
|
20
|
+
export COSIGN_PASSWORD=$PASSPHRASE
|
|
21
|
+
fi
|
|
22
|
+
cosign sign --key "$KEY" --cert "$CERT" "$IMAGE"
|
|
23
|
+
else
|
|
24
|
+
echo "Error: cosign not found. Please install cosign to use this skill."
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
if [ $? -eq 0 ]; then
|
|
29
|
+
echo "Successfully signed $IMAGE"
|
|
30
|
+
else
|
|
31
|
+
echo "Failed to sign $IMAGE"
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Document Revision History
|
|
3
|
+
description: Manages a revision history table at the beginning of generated documents, tracking changes per version.
|
|
4
|
+
---
|
|
5
|
+
# Document Revision History
|
|
6
|
+
|
|
7
|
+
Manage a revision history table at the beginning of every generated or updated document. This ensures traceability of changes across document versions.
|
|
8
|
+
|
|
9
|
+
## Policy
|
|
10
|
+
|
|
11
|
+
### 1. Revision History Table Required
|
|
12
|
+
|
|
13
|
+
Every document generated or updated by the agent MUST include a **Revision History** table immediately after the document title (before the Table of Contents or Section 1).
|
|
14
|
+
|
|
15
|
+
### 2. Table Format
|
|
16
|
+
|
|
17
|
+
Use the following markdown table format:
|
|
18
|
+
|
|
19
|
+
```markdown
|
|
20
|
+
| Version | Date | Author | Changes |
|
|
21
|
+
|---------|------|--------|---------|
|
|
22
|
+
| 1.0 | 2026-03-02 | Agent (Claude) | Initial document generation |
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 3. Column Definitions
|
|
26
|
+
|
|
27
|
+
| Column | Description |
|
|
28
|
+
|--------|-------------|
|
|
29
|
+
| **Version** | Document version number (e.g., 1.0, 1.1, 2.0). Use semantic versioning: major version for structural changes, minor for content updates |
|
|
30
|
+
| **Date** | Date of the change in `YYYY-MM-DD` format |
|
|
31
|
+
| **Author** | Who made the change — use `Agent (<model>)` for AI-generated content, or the user's name for user-directed changes |
|
|
32
|
+
| **Changes** | Brief summary of ALL changes made in this version. One line per version — consolidate multiple changes into a single descriptive entry |
|
|
33
|
+
|
|
34
|
+
### 4. Rules for New Documents
|
|
35
|
+
|
|
36
|
+
When **generating a new document** for the first time:
|
|
37
|
+
- Add the revision history table immediately after the document title
|
|
38
|
+
- Set version to `1.0`
|
|
39
|
+
- Set date to today's date
|
|
40
|
+
- Set author to `Agent (<model>)` where `<model>` is the AI model name
|
|
41
|
+
- Set changes to `Initial document generation`
|
|
42
|
+
|
|
43
|
+
### 5. Rules for Updated Documents
|
|
44
|
+
|
|
45
|
+
When **updating an existing document**:
|
|
46
|
+
- Read the existing revision history table
|
|
47
|
+
- Determine the new version number:
|
|
48
|
+
- **Minor increment** (e.g., 1.0 → 1.1): Content updates, corrections, additions to existing sections
|
|
49
|
+
- **Major increment** (e.g., 1.1 → 2.0): Structural changes, section reorganization, significant rewrites
|
|
50
|
+
- Add a **single new row** summarizing ALL changes made in this update session
|
|
51
|
+
- Do NOT create multiple rows for changes made in the same session — consolidate them into one line
|
|
52
|
+
- Preserve all previous revision history entries
|
|
53
|
+
|
|
54
|
+
### 6. Changes Column Guidelines
|
|
55
|
+
|
|
56
|
+
Write concise but descriptive change summaries:
|
|
57
|
+
|
|
58
|
+
**Good examples:**
|
|
59
|
+
- `Added Sections 7-8 (impacts, analysis), expanded interface requirements to cover categories a-g`
|
|
60
|
+
- `Updated capability requirements based on user feedback, added 3 new interfaces`
|
|
61
|
+
- `Fixed traceability matrix, corrected section numbering`
|
|
62
|
+
|
|
63
|
+
**Bad examples:**
|
|
64
|
+
- `Updated document` (too vague)
|
|
65
|
+
- `Changed section 3.2.1 requirement SRS-CAP-001 description from X to Y, then changed 3.2.2...` (too granular — summarize)
|
|
66
|
+
|
|
67
|
+
### 7. Placement
|
|
68
|
+
|
|
69
|
+
The revision history table MUST appear in this order within the document:
|
|
70
|
+
|
|
71
|
+
```markdown
|
|
72
|
+
# Document Title
|
|
73
|
+
|
|
74
|
+
| Version | Date | Author | Changes |
|
|
75
|
+
|---------|------|--------|---------|
|
|
76
|
+
| 1.0 | 2026-03-02 | Agent (Claude) | Initial document generation |
|
|
77
|
+
|
|
78
|
+
> MIL-STD-498 or other document metadata...
|
|
79
|
+
|
|
80
|
+
## Table of Contents (if applicable)
|
|
81
|
+
|
|
82
|
+
## 1. Scope
|
|
83
|
+
...
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 8. Multi-Author Sessions
|
|
87
|
+
|
|
88
|
+
If the user provides their name or the changes are user-directed corrections:
|
|
89
|
+
- Use the user's name as author
|
|
90
|
+
- If both the agent and user contribute in the same session, use `{user_name} / Agent (<model>)`
|
|
91
|
+
|
|
92
|
+
## Example
|
|
93
|
+
|
|
94
|
+
A document updated twice would have:
|
|
95
|
+
|
|
96
|
+
```markdown
|
|
97
|
+
# Software Requirements Specification (SRS)
|
|
98
|
+
|
|
99
|
+
| Version | Date | Author | Changes |
|
|
100
|
+
|---------|------|--------|---------|
|
|
101
|
+
| 1.0 | 2026-03-01 | Agent (Claude) | Initial document generation from SSDD and PRD artifacts |
|
|
102
|
+
| 1.1 | 2026-03-02 | Joseph / Agent (Claude) | Added 4 interface requirements per user feedback, corrected capability traceability to SSDD |
|
|
103
|
+
| 2.0 | 2026-03-15 | Agent (Claude) | Major rewrite: restructured CSCI decomposition after SSDD v2.0, updated all requirement IDs |
|
|
104
|
+
```
|