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

x-pack/packetbeat: add licensing notices and information for Npcap #29303

Closed
wants to merge 26 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8e1bfe1
packetbeat: add npcap installer hooks
efd6 Nov 22, 2021
e58c832
packetbeat: use a remote registry
efd6 Nov 24, 2021
59a33e6
packetbeat: allow specification of Npcap install location
efd6 Nov 24, 2021
0be3fa5
packetbeat: fix error handling and make failure an option
efd6 Nov 25, 2021
9100816
add changelog line
efd6 Nov 25, 2021
ed25fa3
improve error reporting
efd6 Nov 29, 2021
f464744
restrict oem npcap installation to elastic licensed use
efd6 Nov 29, 2021
21d4931
add logic for installing from embedded byte artifact
efd6 Dec 1, 2021
dfc114b
make npcap installer code visible from x-pack
efd6 Dec 1, 2021
2b16d6c
allow installation of npcap from embedded npcap installer
efd6 Dec 2, 2021
4c1ceae
reload npcap dll on install
efd6 Dec 2, 2021
9432b72
make compilation succeed and handle un-bundled case
efd6 Dec 2, 2021
20d10c3
update docs for new approach and note limiting use to x-pack
efd6 Dec 2, 2021
4ce44a2
remove option to retain downloaded installer file
efd6 Dec 3, 2021
ad80f3a
only include Npcap config options on Windows when Elastic Licensed
efd6 Dec 9, 2021
a38af7c
back out remote provisioning of installer
efd6 Dec 9, 2021
6db9a67
be explicit about included files in installer
efd6 Dec 9, 2021
466f1fc
allow the tree to remain clean during packaging
efd6 Dec 9, 2021
3a36636
use config struct and allow user to block install
efd6 Dec 9, 2021
bc8149e
test config file contents
efd6 Dec 10, 2021
784353b
log pcap version for windows platforms
efd6 Jan 12, 2022
5222fc2
x-pack/packetbeat: add license notices
efd6 Dec 3, 2021
64ec3b5
remove license hold
efd6 Dec 15, 2021
636cfaa
experiment: always write notice but conditionally add npcap licenses
efd6 Dec 16, 2021
ac71149
Create PackageDir before WriteFile
andrewkroh Dec 16, 2021
a58e5e5
bump Npcap version
efd6 Jan 4, 2022
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
50 changes: 47 additions & 3 deletions dev-tools/packaging/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package dev_tools
import (
"archive/tar"
"archive/zip"
"bufio"
"bytes"
"compress/gzip"
"encoding/json"
Expand Down Expand Up @@ -169,7 +170,7 @@ func checkTar(t *testing.T, file string) {
}

func checkZip(t *testing.T, file string) {
p, err := readZip(file)
p, err := readZip(t, file, checkNpcapNotices)
if err != nil {
t.Error(err)
return
Expand All @@ -183,6 +184,34 @@ func checkZip(t *testing.T, file string) {
checkLicensesPresent(t, "", p)
}

var npcapConfigPattern = regexp.MustCompile("Windows Npcap installation settings")

func checkNpcapNotices(pkg, file string, contents io.Reader) error {
if !strings.Contains(pkg, "packetbeat") || !strings.Contains(pkg, "windows") {
return nil
}

wantNotices := strings.Contains(pkg, "windows")
efd6 marked this conversation as resolved.
Show resolved Hide resolved

// If the packetbeat README.md is made to be generated
// conditionally then it should also be checked here.
pkg = filepath.Base(pkg)
file, err := filepath.Rel(pkg[:len(pkg)-len(filepath.Ext(pkg))], file)
if err != nil {
return err
}
switch file {
case "packetbeat.yml", "packetbeat.reference.yml":
if npcapConfigPattern.MatchReader(bufio.NewReader(contents)) != wantNotices {
if wantNotices {
return fmt.Errorf("Npcap config section not found in config file %s in %s", file, pkg)
}
return fmt.Errorf("unexpected Npcap config section found in config file %s in %s", file, pkg)
}
}
return nil
}

func checkDocker(t *testing.T, file string) {
p, info, err := readDocker(file)
if err != nil {
Expand Down Expand Up @@ -623,7 +652,11 @@ func readTarContents(tarName string, data io.Reader) (*packageFile, error) {
return p, nil
}

func readZip(zipFile string) (*packageFile, error) {
// inspector is a file contents inspector. It vets the contents of the file
// within a package for a requirement and returns an error if it is not met.
type inspector func(pkg, file string, contents io.Reader) error

func readZip(t *testing.T, zipFile string, inspectors ...inspector) (*packageFile, error) {
r, err := zip.OpenReader(zipFile)
if err != nil {
return nil, err
Expand All @@ -636,6 +669,18 @@ func readZip(zipFile string) (*packageFile, error) {
File: f.Name,
Mode: f.Mode(),
}
for _, inspect := range inspectors {
r, err := f.Open()
if err != nil {
t.Errorf("failed to open %s in %s: %v", f.Name, zipFile, err)
break
}
err = inspect(zipFile, f.Name, r)
if err != nil {
t.Error(err)
}
r.Close()
}
}

return p, nil
Expand Down Expand Up @@ -740,7 +785,6 @@ func readDockerManifest(r io.Reader) (*dockerManifest, error) {
err = json.Unmarshal(data, &manifests)
if err != nil {
return nil, err

}

if len(manifests) != 1 {
Expand Down