Skip to content

Commit

Permalink
Support new SETFCAP parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
usimd committed Nov 20, 2022
1 parent a3ed412 commit 612f32a
Show file tree
Hide file tree
Showing 9 changed files with 1,087 additions and 1,278 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ tries to make sure the stage is respected and its changes are included in the fi
# buster, bullseye, and testing.
release: bullseye

# Setting to `1` will prevent pi-gen from dropping the "capabilities" feature.
# Generating the root filesystem with capabilities enabled and running it from a
# filesystem that does not support capabilities (like NFS) can cause issues. Only
# enable this if you understand what it is.
setfcap: ''

# List of stage name to execute in given order. Relative and absolute paths to
# custom stage directories are allowed here. Note that by default pi-gen exports
# images in stage2 (lite), stage4 and stage5. You probably want to hook in custom
Expand Down
16 changes: 16 additions & 0 deletions __test__/configure.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {configure} from '../src/configure'
import * as config from '../src/pi-gen-config'
import * as core from '@actions/core'

describe('Configure', () => {
const OLD_ENV = process.env
Expand Down Expand Up @@ -31,4 +32,19 @@ describe('Configure', () => {
})
)
})

it('masks sensitive user input', async () => {
jest.spyOn(core, 'info').mockImplementation()
jest.spyOn(config, 'validateConfig').mockReturnValue(Promise.resolve())

process.env['INPUT_IMAGE-NAME'] = 'test'
process.env['INPUT_ENABLE-NOOBS'] = 'false'
process.env['INPUT_EXPORT-LAST-STAGE-ONLY'] = 'true'
process.env['INPUT_PASSWORD'] = 'secretpassword'
process.env['INPUT_WPA-PASSWORD'] = 'secretpassword'

await configure()

expect(core.info).toBeCalledWith(expect.not.stringContaining('secretpassword'))
})
})
1 change: 1 addition & 0 deletions __test__/pi-gen-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ describe('PiGenConfig', () => {
['wpaEssid', '0'.repeat(33)],
['wpaPassword', '12345'],
['wpaPassword', '0'.repeat(64)],
['setfcap', '0'],
['stageList', []],
['stageList', ['foo']],
['stageList', [tmp.fileSync().name]],
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ inputs:
description: Use qcow2 images to reduce space and runtime requirements.
required: false
default: 1
setfcap:
description: |
Setting to `1` will prevent pi-gen from dropping the "capabilities" feature. Generating the root filesystem with capabilities enabled and running
it from a filesystem that does not support capabilities (like NFS) can cause issues. Only enable this if you understand what it is.
required: false
default: ''
stage-list:
description: |
List of stage name to execute in given order. Relative and absolute paths to custom stage directories are allowed here.
Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module.exports = {
coverageThreshold: {
global: {
statements: 96,
branches: 78,
branches: 79,
functions: 96,
lines: 96
lines: 97
}
},
clearMocks: true,
Expand Down
Loading

0 comments on commit 612f32a

Please sign in to comment.