| Versioning Policy | NotebookLM
Securefix Action is GitHub Actions to fix code securely.
Securefix Action allows you to fix code securely without sharing a GitHub App private key with strong permissions such as contents:write across GitHub Actions workflows.
You don't need to allow external services to access your code.
It elevates the security of your workflows to the next level.
Furthermore, it's easy to use. You don't need to host a server application. It achieves a server/client architecture using GitHub Actions by unique approach.
See also Release Notes.
Sometimes you want to fix code in CI:
In case of public repositories, we strongly recommend autofix.ci. autofix.ci allows you to fix code in CI of pull requests including pull requests from fork repositories securely. autofix.ci is easy to use, and it's free in public repositories. We love it.
autofix.ci is also available in private repositories, but perhaps it's a bit hard to use it in your private repositories for your business.
We think autofix.ci is valuable in private repositories too, but perhaps you can't use it.
If you use fix code in CI, you need to use an access token with contents:write permission.
But if the token is abused, malicious code can be committed.
For instance, an attacker can create a malicious commit to a pull request, and he may be able to approve and merge the pull request.
It's so dangerous.
To prevent such a threat, you should protect personal access tokens and GitHub Apps having strong permissions securely.
One solution is the Client/Server Model. Clients are GitHub Actions workflows that want to fix code. They send a request to the server, then the server fix code. You don't need to pass an access token with strong permissions to clients (GitHub Actions Workflows).
Then how do you build the server? For instance, you would be able to build the server using AWS Lambda, Google Cloud Function, or k8s, and so on. But we don't want to host such a server application.
So we build a server using GitHub Actions workflow by unique approach. You don't need to host a server application.
Securefix Action adopts the Client/Server Model. It uses following GitHub Apps, repositories, and workflows:
label:created eventSecurefix Action uses label event to trigger a server workflow.
Generally repository_dispatch events are used to trigger workflows by API, but they require the permission actions:write.
actions:write permissions is strong and dangerous, so we don't want to grant the permission.
So we looked for alternative events from all events, and we found label event.
Even if the permission is abused, the risk is low.
bar.yaml to client' repository and create a pull requestDeactivate Webhook.
Permissions:
contents:write: To create commitsactions:read: To download GitHub Actions Artifacts to fix codepull_requests:write: To notify problems on the server side to pull requestsworkflows:write: Optional. This is required if you want to fix GitHub Actions workflowsmembers:read: Optional. This is required if you want to request reviews to teamsprojects:write: Optional. This is required if you want to add pull requests to GitHub Organization ProjectsInstalled Repositories: Install the app into the server repository and client repositories.
Deactivate Webhook.
Permissions:
issues:write: To create labelsInstalled Repositories: Install the app into the server repository and client repositories.
Add GitHub App's private keys and ID to Repository Secrets and Variables
DEMO_CLIENT_APP_IDDEMO_CLIENT_PRIVATE_KEYDEMO_SERVER_APP_IDDEMO_SERVER_PRIVATE_KEY[!WARNING] In the getting started, we add private keys to Repository Secrets simply. But when you use Securefix Action actually, you must manage the Server GitHub App's private key and the server workflow securely. Only the server workflow must be able to access the server app's private key. See also
How to manage a server GitHub App and a server workflow.
If you change a variable name and a secret name, please fix the workflow.
server_repositorybar.yaml to client' repository and create a pull requestbar.yaml to client repository (Example)bar.yaml:
names:
- bar
Then workflows are run and bar.yaml is fixed automatically:
--- a/bar.yaml
+++ b/bar.yaml
@@ -1,2 +1,2 @@
names:
-- bar
+ - bar
Securefix Action >= v0.2.0 #123
By default, Securefix Action pushes a commit to the repository and branch where the action is run. But actually there are usecases that you want to push a commit to other repository and branch.
workflow_dispatchSecurefix Action can push a commit to the other repository and branch securely. Allowing to push any repository and branch without any restriction is dangerous, so by default changing the repository and branch isn't allowed, meaning the action fails. You can push a commit from only allowed repositories and branches to only allowed repositories and branches. From Securefix Action v0.3.0, the source branch must be protected.
When pushing a commit to the other repository and branch, you can also create a pull request.
Securefix Action is a single JavaScript Action.
It has an input action, which accepts the following values:
client: Client Actionserver: Server Action
validate-config: Validate the configuration file of the server sideThe server action is a single action that consolidates the prepare, commit, and notify actions.
In most cases, you can simply use the server action.
If you need more flexibility, you can use the individual prepare, commit, and notify actions instead.
For example, you can insert your own validation logic between prepare and commit, or implement custom notification handling instead of using the default notify action.
As of Securefix Action v0.2.0, Securefix Action is released using release-js-action. About available versions, please see the document.
- You don't need to pass a GitHub App private key having strong permissions to GitHub Actions workflows on the client side
- You don't need to allow external services to access your code
- You can define custom validation before creating a commit
- Commits are verified (signed)
Client workflows can use a Client GitHub App, but it has only issues:write permission.
Even if the app is abused, the risk is low.
Server action creates a commit to the same repository and branch with the GitHub Actions Artifact.
So it doesn't allow attackers to create a malicious commit to a different repository or a different branch.
You must protect a server GitHub App and a server workflow from attacks securely. There are several ideas:
You can insert custom validation between prepare action and commit action.
You can use prepare action's outputs.
- uses: csm-actions/securefix-action@latest
id: prepare
with:
action: prepare
app_id: ${{ vars.DEMO_SERVER_APP_ID }}
app_private_key: ${{ secrets.DEMO_SERVER_PRIVATE_KEY }}
# Custom Validation
- if: fromJson(steps.prepare.outputs.pull_request).user.login != 'suzuki-shunsuke'
run: |
exit 1
- uses: csm-actions/securefix-action@latest
with:
action: commit
outputs: ${{ toJson(steps.prepare.outputs) }}
- uses: csm-actions/securefix-action@latest
if: failure()
with:
action: notify
outputs: ${{ toJson(steps.prepare.outputs) }}
By default, the client workflow name must be securefix for security.
Otherwise, the prepare action fails.
You can change the workflow name or remove the restriction using prepare action's workflow_name input.
By default, Serverfix Action doesn't allow you to fix workflow files for security.
By default, the server action fails if fixed files include workflow files.
You can allow it by setting prepare action's allow_workflow_fix to true.
If you use Server Action in many client repositories and face GitHub API limiting, you can avoid the rate limiting by creating new GitHub Apps and a server repository and splitting clients:
Reference:
TypeScript
99.0%
| Versioning Policy | NotebookLM
Securefix Action is GitHub Actions to fix code securely.
Securefix Action allows you to fix code securely without sharing a GitHub App private key with strong permissions such as contents:write across GitHub Actions workflows.
You don't need to allow external services to access your code.
It elevates the security of your workflows to the next level.
Furthermore, it's easy to use. You don't need to host a server application. It achieves a server/client architecture using GitHub Actions by unique approach.
See also Release Notes.
Sometimes you want to fix code in CI:
In case of public repositories, we strongly recommend autofix.ci. autofix.ci allows you to fix code in CI of pull requests including pull requests from fork repositories securely. autofix.ci is easy to use, and it's free in public repositories. We love it.
autofix.ci is also available in private repositories, but perhaps it's a bit hard to use it in your private repositories for your business.
We think autofix.ci is valuable in private repositories too, but perhaps you can't use it.
If you use fix code in CI, you need to use an access token with contents:write permission.
But if the token is abused, malicious code can be committed.
For instance, an attacker can create a malicious commit to a pull request, and he may be able to approve and merge the pull request.
It's so dangerous.
To prevent such a threat, you should protect personal access tokens and GitHub Apps having strong permissions securely.
One solution is the Client/Server Model. Clients are GitHub Actions workflows that want to fix code. They send a request to the server, then the server fix code. You don't need to pass an access token with strong permissions to clients (GitHub Actions Workflows).
Then how do you build the server? For instance, you would be able to build the server using AWS Lambda, Google Cloud Function, or k8s, and so on. But we don't want to host such a server application.
So we build a server using GitHub Actions workflow by unique approach. You don't need to host a server application.
Securefix Action adopts the Client/Server Model. It uses following GitHub Apps, repositories, and workflows:
label:created eventSecurefix Action uses label event to trigger a server workflow.
Generally repository_dispatch events are used to trigger workflows by API, but they require the permission actions:write.
actions:write permissions is strong and dangerous, so we don't want to grant the permission.
So we looked for alternative events from all events, and we found label event.
Even if the permission is abused, the risk is low.
bar.yaml to client' repository and create a pull requestDeactivate Webhook.
Permissions:
contents:write: To create commitsactions:read: To download GitHub Actions Artifacts to fix codepull_requests:write: To notify problems on the server side to pull requestsworkflows:write: Optional. This is required if you want to fix GitHub Actions workflowsmembers:read: Optional. This is required if you want to request reviews to teamsprojects:write: Optional. This is required if you want to add pull requests to GitHub Organization ProjectsInstalled Repositories: Install the app into the server repository and client repositories.
Deactivate Webhook.
Permissions:
issues:write: To create labelsInstalled Repositories: Install the app into the server repository and client repositories.
Add GitHub App's private keys and ID to Repository Secrets and Variables
DEMO_CLIENT_APP_IDDEMO_CLIENT_PRIVATE_KEYDEMO_SERVER_APP_IDDEMO_SERVER_PRIVATE_KEY[!WARNING] In the getting started, we add private keys to Repository Secrets simply. But when you use Securefix Action actually, you must manage the Server GitHub App's private key and the server workflow securely. Only the server workflow must be able to access the server app's private key. See also
How to manage a server GitHub App and a server workflow.
If you change a variable name and a secret name, please fix the workflow.
server_repositorybar.yaml to client' repository and create a pull requestbar.yaml to client repository (Example)bar.yaml:
names:
- bar
Then workflows are run and bar.yaml is fixed automatically:
--- a/bar.yaml
+++ b/bar.yaml
@@ -1,2 +1,2 @@
names:
-- bar
+ - bar
Securefix Action >= v0.2.0 #123
By default, Securefix Action pushes a commit to the repository and branch where the action is run. But actually there are usecases that you want to push a commit to other repository and branch.
workflow_dispatchSecurefix Action can push a commit to the other repository and branch securely. Allowing to push any repository and branch without any restriction is dangerous, so by default changing the repository and branch isn't allowed, meaning the action fails. You can push a commit from only allowed repositories and branches to only allowed repositories and branches. From Securefix Action v0.3.0, the source branch must be protected.
When pushing a commit to the other repository and branch, you can also create a pull request.
Securefix Action is a single JavaScript Action.
It has an input action, which accepts the following values:
client: Client Actionserver: Server Action
validate-config: Validate the configuration file of the server sideThe server action is a single action that consolidates the prepare, commit, and notify actions.
In most cases, you can simply use the server action.
If you need more flexibility, you can use the individual prepare, commit, and notify actions instead.
For example, you can insert your own validation logic between prepare and commit, or implement custom notification handling instead of using the default notify action.
As of Securefix Action v0.2.0, Securefix Action is released using release-js-action. About available versions, please see the document.
- You don't need to pass a GitHub App private key having strong permissions to GitHub Actions workflows on the client side
- You don't need to allow external services to access your code
- You can define custom validation before creating a commit
- Commits are verified (signed)
Client workflows can use a Client GitHub App, but it has only issues:write permission.
Even if the app is abused, the risk is low.
Server action creates a commit to the same repository and branch with the GitHub Actions Artifact.
So it doesn't allow attackers to create a malicious commit to a different repository or a different branch.
You must protect a server GitHub App and a server workflow from attacks securely. There are several ideas:
You can insert custom validation between prepare action and commit action.
You can use prepare action's outputs.
- uses: csm-actions/securefix-action@latest
id: prepare
with:
action: prepare
app_id: ${{ vars.DEMO_SERVER_APP_ID }}
app_private_key: ${{ secrets.DEMO_SERVER_PRIVATE_KEY }}
# Custom Validation
- if: fromJson(steps.prepare.outputs.pull_request).user.login != 'suzuki-shunsuke'
run: |
exit 1
- uses: csm-actions/securefix-action@latest
with:
action: commit
outputs: ${{ toJson(steps.prepare.outputs) }}
- uses: csm-actions/securefix-action@latest
if: failure()
with:
action: notify
outputs: ${{ toJson(steps.prepare.outputs) }}
By default, the client workflow name must be securefix for security.
Otherwise, the prepare action fails.
You can change the workflow name or remove the restriction using prepare action's workflow_name input.
By default, Serverfix Action doesn't allow you to fix workflow files for security.
By default, the server action fails if fixed files include workflow files.
You can allow it by setting prepare action's allow_workflow_fix to true.
If you use Server Action in many client repositories and face GitHub API limiting, you can avoid the rate limiting by creating new GitHub Apps and a server repository and splitting clients:
Reference:
TypeScript
99.0%