Skip to content
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

WIP: Add Position() to Firmware interface #317

Closed
wants to merge 5 commits into from

Conversation

karlodwyer
Copy link

Original Issue here

@xaionaro asked on the opensource firmware slack for suggestions around implementing this idea. The approach suggested was to publish a PR and work it out form there, so he and I talked a bit about this.

Some things to note:

  • We understand it is not good to export a visitor PositionUpdater from uefi, but we are open for discussion on how to fix it.
  • This change and Assemble probably need more testing to give us more assurance that we aren't regressing anything.

@JulienVdG
Copy link
Collaborator

Hello, first I've not looked into the code yet, but regarding your point about PositionUpdater above you can place it in the visitor package along with other visitors.
There is already coupling between the two package anyway (assemble or table cannot work without knowing about each uefi type).
A visitor is not required to provide cli (again assemble is a good example, there is no RegisterCLI in assemble.go)
hope this helps.

@xaionaro
Copy link
Member

xaionaro commented May 15, 2020

Hello, first I've not looked into the code yet, but regarding your point about PositionUpdater above you can place it in the visitor package along with other visitors.

The problem is:
We want to get objects with updated offsets from uefi.Parse. So it is required to call (*PositionUpdater{}).Run() inside uefi.Parse. And if we put this visitor to visitors we get a circular dependency:
uefi -> visitor -> uefi.

This circular dependency could be broken if we will move types (like BIOSPadding) to a separate package (like ./pkg/uefi/types). In this case the new visitor could be moved into ./internal/visitors and will be used from both packages: ./pkg/uefi and ./pkg/visitors. But since it requires changes in the skeleton of the project it would be nice to understand if this approach is approved :)

Another obvious approach is just to duplicate the visitor between uefi and visitors (and make it private in uefi) =\

@codecov-io
Copy link

Codecov Report

Merging #317 into master will increase coverage by 2.26%.
The diff coverage is 36.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #317      +/-   ##
==========================================
+ Coverage   39.21%   41.47%   +2.26%     
==========================================
  Files          47       48       +1     
  Lines        3501     3597      +96     
==========================================
+ Hits         1373     1492     +119     
+ Misses       1912     1873      -39     
- Partials      216      232      +16     
Impacted Files Coverage Δ
pkg/uefi/biosregion.go 41.53% <0.00%> (+34.98%) ⬆️
pkg/uefi/file.go 24.83% <0.00%> (+7.61%) ⬆️
pkg/uefi/flash.go 27.06% <0.00%> (-0.84%) ⬇️
pkg/uefi/meregion.go 9.89% <0.00%> (-0.46%) ⬇️
pkg/uefi/nvram.go 59.29% <0.00%> (-0.85%) ⬇️
pkg/uefi/rawregion.go 19.04% <0.00%> (-2.01%) ⬇️
pkg/uefi/section.go 41.37% <0.00%> (+14.05%) ⬆️
pkg/uefi/update_positions.go 40.98% <40.98%> (ø)
pkg/uefi/uefi.go 62.13% <50.00%> (+1.08%) ⬆️
pkg/uefi/firmwarevolume.go 61.16% <100.00%> (+23.54%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d73b5b5...f55ff01. Read the comment docs.

Copy link
Member

@GanShun GanShun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting approach, however I'd much rather have the visitor in pkg/visitors.

The way I would avoid the cyclic dependency is to call updatePositions not from uefi.Parse, but from pkg/utk/utk.go, in the Run function right before other visitors are executed. This also ensures that if we are calling utk on an extracted directory, the positions are also updated. Right now I think it'll only work if you call utk on a bios image.

@@ -156,6 +167,11 @@ func (f *FlashImage) ApplyChildren(v Visitor) error {
return nil
}

// Position returns the absolution position of the node in the firmware image.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*absolute

return f.Apply(v)
}

// Visit applies the Table visitor to any Firmware type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*PositionUpdater

@@ -258,6 +261,11 @@ func (s *Section) ApplyChildren(v Visitor) error {
return nil
}

// Position returns the absolution position of the node in the firmware image.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolute*

@orangecms orangecms changed the base branch from master to main September 8, 2022 13:02
@rminnich
Copy link
Contributor

I am closing this, for lack of interest.

@orangecms
Copy link
Collaborator

I'm interested, see #321

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 65.97938% with 33 lines in your changes missing coverage. Please review.

Project coverage is 35.08%. Comparing base (978160d) to head (1c0079f).

Files with missing lines Patch % Lines
pkg/uefi/update_positions.go 85.24% 6 Missing and 3 partials ⚠️
pkg/uefi/biosregion.go 0.00% 4 Missing ⚠️
pkg/uefi/flash.go 0.00% 4 Missing ⚠️
pkg/uefi/meregion.go 0.00% 4 Missing ⚠️
pkg/uefi/nvram.go 0.00% 4 Missing ⚠️
pkg/uefi/file.go 0.00% 2 Missing ⚠️
pkg/uefi/rawregion.go 0.00% 2 Missing ⚠️
pkg/uefi/section.go 0.00% 2 Missing ⚠️
pkg/uefi/uefi.go 75.00% 1 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #317      +/-   ##
==========================================
+ Coverage   34.21%   35.08%   +0.86%     
==========================================
  Files         209      210       +1     
  Lines       14086    14182      +96     
==========================================
+ Hits         4820     4976     +156     
+ Misses       8377     8302      -75     
- Partials      889      904      +15     
Flag Coverage Δ
35.08% <65.97%> (+0.86%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rminnich
Copy link
Contributor

rminnich commented Oct 2, 2024

I don't think this one is going to get finished.

@rminnich rminnich closed this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants