-
Notifications
You must be signed in to change notification settings - Fork 12
add boot transparency support #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
danbia
wants to merge
41
commits into
usbarmory:development
Choose a base branch
from
danbia:boot-transparency
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
b2dbdbf
add boot transparency support
danbia d31a7ff
update documentation
danbia 2f42c9d
tyding
danbia 8623013
address PR comments
danbia bd2b1ed
replace online/offline nomenclature
danbia 40b0cbd
move back transparency code to a dedicated pkg, add btCmd under cmd/a…
danbia fd40723
tyding
danbia 117a3dc
add to bt validation artifacts hash check
danbia b2f1ea2
improves godoc and comments
danbia 8602fe6
tyding
danbia 10733ef
fix per-entry path construction
danbia fa75081
remove uneccessary const type + improve godoc comments
danbia 9169926
tyding
danbia 83de386
uses idiomatic errors where applicable
danbia 6e41fb7
use path.Join to assemble configuration paths
danbia dca10be
better usage of BtStatus type
danbia a9b37f2
move configuration loading to transparency.go
danbia 2227596
better code organization in cmd/linux and add configuration methods
danbia 3fca8d7
improves configuration path construction
danbia 13cfbf8
define BootEntry type for better code organization
danbia ead2d21
tyding
danbia d293f00
more idiomatic code re-organization
danbia 2afa5f2
more consistent proof hash validation names
danbia 07720d1
fix code repetition in load config
danbia b7bad2a
add support for external pkg usage
danbia 967e784
automatically detect if operating externally to a UEFI bootloader
danbia 518e7be
tyding
danbia 6f43b79
tyding
danbia 299e394
add protections against invalid hash and root fs
danbia 33f0ce0
add test files for transparency pkg
danbia a182d68
fix Offline vs Online tests
danbia ae5685b
returns error if online mode is selected and network is unavailable
danbia 9ea8cae
improve cmd help consistency
danbia a67ce20
limit returns in the bt config function
danbia bc17134
documentation tyiding
danbia b67c30e
moves btValidate function to auth.go
danbia cc56a74
better usage of const to store test values
danbia efb36e8
avoid func definition on *BootEntry -> use BootEntry
danbia 6a2fee3
moves entirely btValidate function to auth.go btValidateLinux
danbia 7a0b4ed
tyding
danbia 107027d
function renaming hasValidHash -> validHash
danbia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // Copyright (c) The go-boot authors. All Rights Reserved. | ||
| // | ||
| // Use of this source code is governed by the license | ||
| // that can be found in the LICENSE file. | ||
|
|
||
| package cmd | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "io/fs" | ||
| "net" | ||
| "regexp" | ||
| "strings" | ||
|
|
||
| "github.com/usbarmory/boot-transparency/artifact" | ||
| "github.com/usbarmory/go-boot/shell" | ||
| "github.com/usbarmory/go-boot/transparency" | ||
| "github.com/usbarmory/go-boot/uapi" | ||
| ) | ||
|
|
||
| var btConfig transparency.Config | ||
|
|
||
| func init() { | ||
| shell.Add(shell.Cmd{ | ||
| Name: "bt", | ||
| Args: 1, | ||
| Pattern: regexp.MustCompile(`^(?:bt)( none| offline| online)?$`), | ||
| Syntax: "(none|offline|online)?", | ||
| Help: "show/change boot-transparency status", | ||
| Fn: btCmd, | ||
| }) | ||
| } | ||
|
|
||
| func btCmd(_ *shell.Interface, arg []string) (res string, err error) { | ||
| if len(arg[0]) > 0 { | ||
| switch strings.TrimSpace(arg[0]) { | ||
| case "none": | ||
| btConfig.Status = transparency.None | ||
| case "offline": | ||
| btConfig.Status = transparency.Offline | ||
| case "online": | ||
| if net.SocketFunc == nil { | ||
| return "", errors.New("network unavailable") | ||
| } | ||
| btConfig.Status = transparency.Online | ||
| } | ||
| } | ||
|
|
||
| switch btConfig.Status { | ||
| case transparency.None: | ||
| res = fmt.Sprintf("boot-transparency is disabled\n") | ||
| case transparency.Offline, transparency.Online: | ||
| res = fmt.Sprintf("boot-transparency is enabled in %s mode\n", btConfig.Status.Resolve()) | ||
| } | ||
|
|
||
| return | ||
| } | ||
|
|
||
| func btValidateLinux(entry *uapi.Entry, root fs.FS) (err error) { | ||
| if entry == nil || len(entry.Linux) == 0 { | ||
| return errors.New("invalid kernel entry") | ||
| } | ||
|
|
||
| btConfig.UefiRoot = root | ||
|
|
||
| btEntry := transparency.BootEntry{ | ||
| transparency.Artifact{ | ||
| Category: artifact.LinuxKernel, | ||
| Hash: transparency.Hash(&entry.Linux), | ||
| }, | ||
| transparency.Artifact{ | ||
| Category: artifact.Initrd, | ||
| Hash: transparency.Hash(&entry.Initrd), | ||
| }, | ||
| } | ||
|
|
||
| return btEntry.Validate(&btConfig) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.