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
24 changes: 20 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ jobs:

binary_scan:
name: GitHub Actions Test
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [windows-latest, ubuntu-latest]

steps:
- name: Checkout
Expand All @@ -75,10 +79,22 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }} # optional if you would like to generate the comment automatically in the PR
automatic-comment: true # optional if you would like to generate the comment automatically in the PR

- name: Set response of binary scan
if: steps.binary_scan.outcome=='success'
id: set_response
- name: Set response of binary scan on Windows
if: steps.binary_scan.outcome == 'success' && runner.os == 'Windows'
id: set_response_windows
run: |
Write-Output "Asset version URL: ${{ steps.binary_scan.outputs.asset-version-url }}"
Write-Output "Response: ${{ steps.binary_scan.outputs.response }}"
Write-Output "Error: ${{ steps.binary_scan.outputs.error }}"

- name: Set response of binary scan on Linux
if: steps.binary_scan.outcome == 'success' && runner.os == 'Linux'
id: set_response_linux
run: |
echo Asset version URL: ${{steps.binary_scan.outputs.asset-version-url}}
echo Response: "${{steps.binary_scan.outputs.response}}"
echo Error: "${{steps.binary_scan.outputs.error}}"
env:
ASSET_VERSION_URL: ${{ steps.binary_scan.outputs.asset-version-url }}
RESPONSE: ${{ steps.binary_scan.outputs.response }}
ERROR: ${{ steps.binary_scan.outputs.error }}
148 changes: 94 additions & 54 deletions DEV_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,53 @@ example, [`ci.yml`](./.github/workflows/ci.yml) demonstrates how to reference an
action in the same repository.

```yaml
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Binary Scan
id: binary_scan
uses: ./
with:
finite-state-client-id: ${{ secrets.CLIENT_ID }}
finite-state-secret: ${{ secrets.CLIENT_SECRET }}
finite-state-organization-context: ${{ secrets.ORGANIZATION_CONTEXT }}
asset-id: ${{env.ASSET_ID}}
version: ${{ github.sha }}
file-path: ./somefile.bin # Put the same path from the "Upload binary generated file" step here
github-token: ${{ secrets.GITHUB_TOKEN }} # optional if you would like to generate the comment automatically in the PR
automatic-comment: true # optional if you would like to generate the comment automatically in the PR

- name: Set response of binary scan
if: steps.binary_scan.outcome=='success'
id: set_response
run: |
echo Asset version URL: ${{steps.binary_scan.outputs.asset-version-url}}
echo Response: "${{steps.binary_scan.outputs.response}}"
echo Error: "${{steps.binary_scan.outputs.error}}"
binary_scan:
name: GitHub Actions Test
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [windows-latest, ubuntu-latest]

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Binary Scan
id: binary_scan
uses: ./
with:
finite-state-client-id: ${{ secrets.CLIENT_ID }}
finite-state-secret: ${{ secrets.CLIENT_SECRET }}
finite-state-organization-context: ${{ secrets.ORGANIZATION_CONTEXT }}
asset-id: ${{env.ASSET_ID}}
version: ${{ github.sha }}
file-path: ./src/lib/utils/example_binary/esp-at.bin # Put the same path from the "Upload binary generated file" step here
github-token: ${{ secrets.GITHUB_TOKEN }} # optional if you would like to generate the comment automatically in the PR
automatic-comment: true # optional if you would like to generate the comment automatically in the PR

- name: Set response of binary scan on Windows
if: steps.binary_scan.outcome == 'success' && runner.os == 'Windows'
id: set_response_windows
run: |
Write-Output "Asset version URL: ${{ steps.binary_scan.outputs.asset-version-url }}"
Write-Output "Response: ${{ steps.binary_scan.outputs.response }}"
Write-Output "Error: ${{ steps.binary_scan.outputs.error }}"

- name: Set response of binary scan on Linux
if: steps.binary_scan.outcome == 'success' && runner.os == 'Linux'
id: set_response_linux
run: |
echo Asset version URL: ${{steps.binary_scan.outputs.asset-version-url}}
echo Response: "${{steps.binary_scan.outputs.response}}"
echo Error: "${{steps.binary_scan.outputs.error}}"
env:
ASSET_VERSION_URL: ${{ steps.binary_scan.outputs.asset-version-url }}
RESPONSE: ${{ steps.binary_scan.outputs.response }}
ERROR: ${{ steps.binary_scan.outputs.error }}
```

## Usage
Expand All @@ -135,31 +155,51 @@ To include the action in a workflow in another repository, you can use the
hash.

```yaml
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Finite State Binary Scan
id: binary_scan
uses: FiniteStateInc/binary-scan@v2.0.1
with:
finite-state-client-id: ${{ secrets.CLIENT_ID }}
finite-state-secret: ${{ secrets.CLIENT_SECRET }}
finite-state-organization-context: ${{ secrets.ORGANIZATION_CONTEXT }}
asset-id: ${{env.ASSET_ID}}
version: ${{ github.sha }}
file-path: ./somefile.bin # Put the same path from the "Upload binary generated file" step here
github-token: ${{ secrets.GITHUB_TOKEN }} # optional if you would like to generate the comment automatically in the PR
automatic-comment: true # optional if you would like to generate the comment automatically in the PR

- name: Set response of binary scan
if: steps.binary_scan.outcome=='success'
id: set_response
run: |
echo Asset version URL: ${{steps.binary_scan.outputs.asset-version-url}}
echo Response: "${{steps.binary_scan.outputs.response}}"
echo Error: "${{steps.binary_scan.outputs.error}}"
binary_scan:
name: GitHub Actions Test
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [windows-latest, ubuntu-latest]

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Binary Scan
id: binary_scan
uses: FiniteStateInc/binary-scan@v3.0.0
with:
finite-state-client-id: ${{ secrets.CLIENT_ID }}
finite-state-secret: ${{ secrets.CLIENT_SECRET }}
finite-state-organization-context: ${{ secrets.ORGANIZATION_CONTEXT }}
asset-id: ${{env.ASSET_ID}}
version: ${{ github.sha }}
file-path: ./src/lib/utils/example_binary/esp-at.bin # Put the same path from the "Upload binary generated file" step here
github-token: ${{ secrets.GITHUB_TOKEN }} # optional if you would like to generate the comment automatically in the PR
automatic-comment: true # optional if you would like to generate the comment automatically in the PR

- name: Set response of binary scan on Windows
if: steps.binary_scan.outcome == 'success' && runner.os == 'Windows'
id: set_response_windows
run: |
Write-Output "Asset version URL: ${{ steps.binary_scan.outputs.asset-version-url }}"
Write-Output "Response: ${{ steps.binary_scan.outputs.response }}"
Write-Output "Error: ${{ steps.binary_scan.outputs.error }}"

- name: Set response of binary scan on Linux
if: steps.binary_scan.outcome == 'success' && runner.os == 'Linux'
id: set_response_linux
run: |
echo Asset version URL: ${{steps.binary_scan.outputs.asset-version-url}}
echo Response: "${{steps.binary_scan.outputs.response}}"
echo Error: "${{steps.binary_scan.outputs.error}}"
env:
ASSET_VERSION_URL: ${{ steps.binary_scan.outputs.asset-version-url }}
RESPONSE: ${{ steps.binary_scan.outputs.response }}
ERROR: ${{ steps.binary_scan.outputs.error }}
```
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ starting point if you encounter any errors during the action's run.

## Extended Feature Example (Optional)

> [!WARNING]
>
> Warning: To use the exact YAML code provided below, you must run it on
> `ubuntu-latest`. If you want to run it on a different runner os, you will need
> to adapt the code accordingly.

In this section, we provide a code snippet for integrating this action into your
existing workflow. Primarily, it uploads the file to the Finite State Platform
for analysis. Once that process is complete, it automatically add a comment to
Expand Down
8 changes: 4 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "binary-scan-github",
"description": "Binary Scan Github Action",
"version": "2.0.1",
"version": "3.0.0",
"author": "christianpfarher@finitestate.io",
"private": false,
"homepage": "https://github.com/FiniteStateInc/binary-scan",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export function sanitizeFilePath(filePath: string): string {

export function sanitizeInput(input: any) {
if (input === null || input === undefined) {
return input // Return null or undefined as-is
return input // Return null or boolean undefined as-is
}

if (typeof input === 'number') {
return input // Return number as-is
if (typeof input === 'number' || typeof input === 'boolean') {
return input // Return number or boolean as-is
}

if (typeof input !== 'string') {
Expand Down
3 changes: 1 addition & 2 deletions src/upload_binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export async function uploadBinary(): Promise<
quickScan,
uploadMethod: UploadMethod.GITHUB_INTEGRATION
}

core.info('Starting - Authentication')
let token: string | undefined
try {
Expand Down Expand Up @@ -117,7 +116,7 @@ export async function uploadBinary(): Promise<
assetId: params.assetId,
version: assetVersion as string
})
core.setOutput('asset-version-url', response)
core.setOutput('asset-version-url', assetVersionUrl)
core.info(`Asset version URL: ${assetVersionUrl}`)

if (!automaticComment) {
Expand Down