Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ All notable changes to `ichava/icon-sets-flag` follow [Keep a Changelog](https:/
token is not allowed to create pull requests in this organisation, so the sync failed at its last
step after refreshing the assets.

### Security

- **Every workflow declares a top-level `permissions: contents: read`** (S9), so its token no longer depends on the organisation's default. None of these jobs writes. `tests/Unit/WorkflowPermissionsTest.php` fails if a workflow loses the block.

## [0.1.0] - TBD

First release of `ichava/icon-sets-flag`. The repository is published as a single commit; the 0.1.x tags cut between 2026-10-23 and 2026-10-26 (v0.1.0 to v0.1.1) are folded into this release, and their notes are kept below under *Archived history*.
Expand Down
33 changes: 33 additions & 0 deletions tests/Unit/WorkflowPermissionsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

/**
* Every workflow declares a top-level `permissions:` block, so the token each job gets does not
* depend on the organisation's default. A job that needs more asks for it at job level.
*
* @return list<string>
*/
function workflow_files(): array
{
$dir = dirname(__DIR__, 2) . '/.github/workflows';

return array_values(array_merge(glob($dir . '/*.yml') ?: [], glob($dir . '/*.yaml') ?: []));
}

it(description: 'reads the workflow files it is meant to guard', closure: function () {
// Floor: the number of workflows today. A glob that stops matching must fail, not pass empty.
expect(count(workflow_files()))->toBeGreaterThanOrEqual(7);
});

it(description: 'declares a top-level permissions block in every workflow', closure: function () {
$missing = [];

foreach (workflow_files() as $file) {
if (! preg_match('/^permissions:/m', (string) file_get_contents($file))) {
$missing[] = basename($file);
}
}

expect($missing)->toBe([]);
});
Loading