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

Reposupport #69

Merged
merged 26 commits into from
Jul 7, 2022
Merged

Reposupport #69

merged 26 commits into from
Jul 7, 2022

Conversation

Atul-source
Copy link
Contributor

@Atul-source Atul-source commented Jun 6, 2022

This PR is for issue #18

Before you could only have a single repository defined for all eBPF programs in the global config. This change enables the ability to define an eBPF repository per program.

models/l3afd.go Outdated
MapArgs L3afDNFArgs `json:"map_args"` // Config BPF Map of arguments
ConfigArgs L3afDNFArgs `json:"config_args"` // Map of arguments to config command
MonitorMaps []L3afDNFMetricsMap `json:"monitor_maps"` // Metrics BPF maps
DownloadUrl string `json:"ebpf_program_repo_name"` // Download url for Program
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we rename the variable to something more related to eBPF Package repository, for ex. EPRUrl. Also, can we have the json tag as ebpf_package_repo_url

models/l3afd.go Outdated
MapArgs L3afDNFArgs `json:"map_args"` // Config BPF Map of arguments
ConfigArgs L3afDNFArgs `json:"config_args"` // Map of arguments to config command
MonitorMaps []L3afDNFMetricsMap `json:"monitor_maps"` // Metrics BPF maps
DownloadUrl string `json:"ebpf_program_repo_name"` // Download url for Program
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we rename the variable to something more related to eBPF Package repository, for ex. EPRUrl. Also, can we have the json tag as ebpf_package_repo_url

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed variables names

Copy link
Collaborator

@dthaler dthaler left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! Changes look good so far.

https://github.com/l3af-project/l3afd/blob/main/docs/CONTRIBUTING.md#guidelines-for-pull-requests says:

Describe the tests that you ran to verify your changes and add/update test cases
Update relevant docs, especially if you've changed APIs

and also

PRs are expected to have 100% test coverage for added code. This can be verified with a coverage build. If your PR cannot have 100% coverage for some reason please clearly explain why when you open it.

What about documentation changes for this?
What about tests that verify that local files work? (PR #66 added some tests, but since this PR is separate I assume that PR doesn't cover tests for this PR)

kf/bpf.go Outdated
Comment on lines 527 to 528
// "file://" ---> has size 7
// "Http://" ---> has size 7
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// "file://" ---> has size 7
// "Http://" ---> has size 7
// "file://" ---> has size 7
// "http://" ---> has size 7

@sanfern
Copy link
Contributor

sanfern commented Jun 8, 2022

@@ -15,6 +15,7 @@ The payload will look more like this standard JSON:
"name": "ratelimiting",
"seq_id": 1,
"artifact": "l3af_ratelimiting.tar.gz",
"ebpf_package_repo_url": "http://www.exampleebpf.com/l3af_ratelimiting.tar.gz"
Copy link
Contributor

@jniesz jniesz Jun 14, 2022

Choose a reason for hiding this comment

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

Let's put example URL of domain we own, such as l3af.io and use https as an example

kf/bpf.go Outdated
buf := &bytes.Buffer{}
// "file://" ---> has size 7
// "http://" ---> has size 7
if len(b.Program.EPRUrl) >= 7 {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should just use url.parse to determine the scheme (http, https, file, ...). File should have three slashes "file:///"

Copy link
Contributor

@jniesz jniesz left a comment

Choose a reason for hiding this comment

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

Left some comments for changes

kf/bpf.go Outdated
}
}
} else {
kfRepoURL, err := url.Parse(conf.KFRepoURL)
Copy link
Contributor

Choose a reason for hiding this comment

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

Future PR we should rename this to eBPFRepoURL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will do a separate PR for a change of KFRepoURL --> eBPFRepoURL

kf/bpf.go Outdated
if strings.Contains(header.Name, "..") {
return fmt.Errorf("zipped file contians filepath (%s) that includes (..)", header.Name)
}
if strings.Contains(header.Name, "..") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a similar check as the zip filename check above with filepath.Clean() ? It probably also makes breaking out this code, so as we add support for new compression algorithms the filename checking logic remains the same and can be managed in single place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we check for somewhere else using the helper function it is giving security issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

breaking out into a separate function vs. having similar code 2+ more times seems to make sense, not sure why this is alerting if we make this change. We can discuss more on call

a0p0ie5 and others added 12 commits June 18, 2022 10:59
Signed-off-by: a0p0ie5 <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Co-authored-by: Dave Thaler <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Co-authored-by: Dave Thaler <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Co-authored-by: jniesz <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Copy link
Contributor

@jniesz jniesz left a comment

Choose a reason for hiding this comment

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

LGTM

@dthaler
Copy link
Collaborator

dthaler commented Jun 22, 2022

Changes look good, but needs a test added per https://github.com/l3af-project/l3afd/blob/main/docs/CONTRIBUTING.md#guidelines-for-pull-requests which says:

Describe the tests that you ran to verify your changes and add/update test cases
Update relevant docs, especially if you've changed APIs

and also

PRs are expected to have 100% test coverage for added code. This can be verified with a coverage build. If your PR cannot have 100% coverage for some reason please clearly explain why when you open it.

a0p0ie5 added 7 commits June 23, 2022 11:49
Signed-off-by: a0p0ie5 <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
Signed-off-by: a0p0ie5 <[email protected]>
@dthaler dthaler merged commit 3c8f904 into l3af-project:main Jul 7, 2022
@Atul-source Atul-source deleted the reposupport branch August 18, 2022 06:56
@jniesz jniesz added the feat New Feature label Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants