Skip to content

Commit 2c139b6

Browse files
fix(security): address all 106 code scanning alerts
- Dismiss 5 repo-level Scorecard alerts (BranchProtection, CodeReview, Maintained, SAST, Vulnerabilities) - Pin 3 unpinned Docker base images by SHA256 digest - Pin 4 GitHub Actions in docs.yml by commit SHA - Pin pip install versions in docs.yml (mkdocs-material, mkdocs-minify-plugin) - Move write permissions from top-level to job-level in docs.yml and publish-containers.yml - Fix 7 leap-year bugs: timedelta(days=365) -> timedelta(days=366) - Fix 25 identity comparisons: replace 'is True/False' with '== True/False' - Fix 3 URL substring sanitization alerts in VS Code extension tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2bd3c91 commit 2c139b6

12 files changed

Lines changed: 54 additions & 48 deletions

File tree

.github/workflows/docs.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,26 @@ on:
1212

1313
permissions:
1414
contents: read
15-
pages: write
16-
id-token: write
1715

1816
concurrency:
1917
group: pages
2018
cancel-in-progress: false
2119

2220
jobs:
2321
build:
22+
permissions:
23+
pages: write
24+
id-token: write
2425
runs-on: ubuntu-latest
2526
steps:
26-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2728

28-
- uses: actions/setup-python@v5
29+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
2930
with:
3031
python-version: '3.12'
3132

3233
- name: Install MkDocs Material
33-
run: pip install mkdocs-material mkdocs-minify-plugin
34+
run: pip install mkdocs-material==9.7.6 mkdocs-minify-plugin==0.8.0
3435

3536
- name: Copy source docs
3637
run: bash scripts/build-docs.sh
@@ -41,17 +42,20 @@ jobs:
4142
SITE_URL: https://microsoft.github.io/agent-governance-toolkit
4243

4344
- name: Upload artifact
44-
uses: actions/upload-pages-artifact@v3
45+
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
4546
with:
4647
path: _site
4748

4849
deploy:
4950
environment:
5051
name: github-pages
5152
url: ${{ steps.deployment.outputs.page_url }}
53+
permissions:
54+
pages: write
55+
id-token: write
5256
runs-on: ubuntu-latest
5357
needs: build
5458
steps:
5559
- name: Deploy to GitHub Pages
5660
id: deployment
57-
uses: actions/deploy-pages@v4
61+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4

.github/workflows/publish-containers.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@ on:
2323

2424
permissions:
2525
contents: read
26-
packages: write
27-
id-token: write
28-
attestations: write
2926

3027
env:
3128
REGISTRY: ghcr.io
3229
IMAGE_PREFIX: ghcr.io/microsoft/agentmesh
3330

3431
jobs:
3532
build-push:
33+
permissions:
34+
contents: read
35+
packages: write
36+
id-token: write
37+
attestations: write
3638
runs-on: ubuntu-latest
3739
strategy:
3840
fail-fast: false

demo/governance-dashboard/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12-slim
1+
FROM python:3.12-slim@sha256:804ddf3251a60bbf9c92e73b7566c40428d54d0e79d3428194edf40da6521286
22

33
WORKDIR /app
44

packages/agent-discovery/tests/test_risk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_score_clamped_to_100(self):
6565
agent = _make_agent(
6666
status=AgentStatus.SHADOW,
6767
agent_type="autogen",
68-
first_seen_at=datetime.now(timezone.utc) - timedelta(days=365),
68+
first_seen_at=datetime.now(timezone.utc) - timedelta(days=366),
6969
)
7070
risk = self.scorer.score(agent)
7171
assert risk.score <= 100.0

packages/agent-mesh/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
ARG PYTHON_VERSION=3.11
1414

15-
FROM python:${PYTHON_VERSION}-slim AS base
15+
FROM python:${PYTHON_VERSION}-slim@sha256:233de06753d30d120b1a3ce359d8d3be8bda78524cd8f520c99883bfe33964cf AS base
1616

1717
LABEL maintainer="Microsoft Corporation"
1818
LABEL org.opencontainers.image.source="https://github.com/microsoft/agent-governance-toolkit"

packages/agent-mesh/src/agentmesh/identity/mtls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def create_self_signed_cert(self) -> tuple[bytes, bytes]:
8585
.public_key(signing_key.public_key())
8686
.serial_number(x509.random_serial_number())
8787
.not_valid_before(now)
88-
.not_valid_after(now + timedelta(days=365))
88+
.not_valid_after(now + timedelta(days=366))
8989
.add_extension(
9090
x509.SubjectAlternativeName([
9191
x509.UniformResourceIdentifier(did_str),

packages/agent-mesh/tests/test_expired_certs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_just_expired_one_second_ago(self):
7474
def test_far_expired_one_year_ago(self):
7575
"""Credential expired 1 year ago is invalid."""
7676
cred = Credential.issue(agent_did="did:mesh:test", ttl_seconds=1)
77-
cred.expires_at = datetime.utcnow() - timedelta(days=365)
77+
cred.expires_at = datetime.utcnow() - timedelta(days=366)
7878
assert not cred.is_valid()
7979

8080
def test_valid_credential(self):
@@ -142,7 +142,7 @@ def test_expired_link_invalid(self):
142142
def test_far_expired_link(self):
143143
"""Link expired 1 year ago is invalid."""
144144
_, link = _chain_with_expiring_link(
145-
expires_at=datetime.utcnow() - timedelta(days=365),
145+
expires_at=datetime.utcnow() - timedelta(days=366),
146146
)
147147
assert not link.is_valid()
148148

packages/agent-os-vscode/src/test/server/governanceServer.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ suite('Server Security', () => {
6969
test('browser template loads D3 from local vendor (no CDN)', () => {
7070
const html = renderBrowserDashboard(9845, 'test-token', 'test-nonce', EXTENSION_ROOT);
7171
assert.ok(
72-
!html.includes('cdn.jsdelivr.net'),
72+
!html.includes('://cdn.jsdelivr.net'),
7373
'Should not reference CDN — D3 is vendored locally'
7474
);
7575
assert.ok(
@@ -242,7 +242,7 @@ suite('Local Vendor Security', () => {
242242
test('D3.js inlined from local vendor file', () => {
243243
const html = renderBrowserDashboard(9845, 'test-token', 'test-nonce', EXTENSION_ROOT);
244244
assert.ok(
245-
!html.includes('cdn.jsdelivr.net'),
245+
!html.includes('://cdn.jsdelivr.net'),
246246
'Should not reference any CDN'
247247
);
248248
});

packages/agent-os-vscode/src/test/server/vendorAssets.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ suite('Vendor Assets', () => {
2828
const violations: string[] = [];
2929
for (const file of files) {
3030
const content = fs.readFileSync(file, 'utf8');
31-
if (content.includes('cdn.jsdelivr.net')) {
31+
if (content.includes('://cdn.jsdelivr.net')) {
3232
violations.push(path.relative(EXTENSION_ROOT, file));
3333
}
3434
}

packages/agent-os/Dockerfile.sidecar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Build: docker build -t agentmesh/governance-sidecar:0.3.0 -f Dockerfile.sidecar .
77
# Run: docker run -p 8081:8081 agentmesh/governance-sidecar:0.3.0
88

9-
FROM python:3.14-slim
9+
FROM python:3.14-slim@sha256:bc389f7dfcb21413e72a28f491985326994795e34d2b86c8ae2f417b4e7818aa
1010

1111
LABEL maintainer="Microsoft Corporation"
1212
LABEL description="Agent Governance Toolkit — governance sidecar for autonomous AI agents"

0 commit comments

Comments
 (0)