Skip to content

Commit

Permalink
Merge branch 'master' into raid-to-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano authored Apr 3, 2018
2 parents 657c210 + 74b24d0 commit dcdfa7d
Show file tree
Hide file tree
Showing 29 changed files with 582 additions and 893 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Set `namespace` as default metricset in Aerospike module. {pull}6669[6669]
- Set `service` as default metricset in Windows module. {pull}6675[6675]
- Set all metricsets as default metricsets in uwsgi module. {pull}6688[6688]
- Mark system.raid metricset as beta. {pull}6710[6710]
- Mark kubernetes.event metricset as beta. {pull}6715[6715]
- Set all metricsets as default metricsets in couchbase module. {pull}6683[6683]

*Packetbeat*

Expand Down
232 changes: 34 additions & 198 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1171,204 +1171,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

--------------------------------------------------------------------
Dependency: github.com/juju/ratelimit
Revision: 5b9ff866471762aa2ab2dced63c9fb6f53921342
License type (autodetected): LGPL-3.0
./vendor/github.com/juju/ratelimit/LICENSE:
--------------------------------------------------------------------
All files in this repository are licensed as follows. If you contribute
to this repository, it is assumed that you license your contribution
under the same license unless you state otherwise.

All files Copyright (C) 2015 Canonical Ltd. unless otherwise specified in the file.

This software is licensed under the LGPLv3, included below.

As a special exception to the GNU Lesser General Public License version 3
("LGPL3"), the copyright holders of this Library give you permission to
convey to a third party a Combined Work that links statically or dynamically
to this Library without providing any Minimal Corresponding Source or
Minimal Application Code as set out in 4d or providing the installation
information set out in section 4e, provided that you comply with the other
provisions of LGPL3 and provided that you meet, for the Application the
terms and conditions of the license(s) which apply to the Application.

Except as stated in this special exception, the provisions of LGPL3 will
continue to comply in full to this Library. If you modify this Library, you
may apply this exception to your version of this Library, but you are not
obliged to do so. If you do not wish to do so, delete this exception
statement from your version. This exception does not (and cannot) modify any
license terms which apply to the Application, with which you must still
comply.


GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.


This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.

3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license
document.

4. Combined Works.

You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.

c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.

d) Do one of the following:

0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.

1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.

e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)

5. Combined Libraries.

You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.

6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

--------------------------------------------------------------------
Dependency: github.com/klauspost/compress
Revision: 14c9a76e3c95e47f8ccce949bba2c1101a8b85e6
Expand Down Expand Up @@ -2572,6 +2374,40 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------
Dependency: golang.org/x/time
Revision: 26559e0f760e39c24d730d3224364aef164ee23f
License type (autodetected): BSD-3-Clause
./vendor/golang.org/x/time/LICENSE:
--------------------------------------------------------------------
Copyright (c) 2009 The Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------
Dependency: golang.org/x/tools
Version: release-branch.go1.9
Expand Down
38 changes: 24 additions & 14 deletions auditbeat/module/file_integrity/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package file_integrity

import (
"errors"
"math"
"os"
"path/filepath"
"sync/atomic"
"time"

"github.com/juju/ratelimit"
"golang.org/x/time/rate"

"github.com/elastic/beats/libbeat/logp"
)
Expand All @@ -21,7 +20,7 @@ var scannerID uint32
type scanner struct {
fileCount uint64
byteCount uint64
tokenBucket *ratelimit.Bucket
tokenBucket *rate.Limiter

done <-chan struct{}
eventC chan Event
Expand Down Expand Up @@ -55,10 +54,10 @@ func (s *scanner) Start(done <-chan struct{}) (<-chan Event, error) {
s.config.ScanRatePerSec,
s.config.MaxFileSize)

s.tokenBucket = ratelimit.NewBucketWithRate(
float64(s.config.ScanRateBytesPerSec)/2., // Fill Rate
int64(s.config.MaxFileSizeBytes)) // Max Capacity
s.tokenBucket.TakeAvailable(math.MaxInt64)
s.tokenBucket = rate.NewLimiter(
rate.Limit(s.config.ScanRateBytesPerSec), // Fill Rate
int(s.config.MaxFileSizeBytes)) // Max Capacity
s.tokenBucket.ReserveN(time.Now(), int(s.config.MaxFileSizeBytes))
}

go s.scan()
Expand Down Expand Up @@ -155,13 +154,24 @@ func (s *scanner) throttle(fileSize uint64) {
return
}

wait := s.tokenBucket.Take(int64(fileSize))
if wait > 0 {
timer := time.NewTimer(wait)
select {
case <-timer.C:
case <-s.done:
}
reservation := s.tokenBucket.ReserveN(time.Now(), int(fileSize))
if !reservation.OK() {
// This would happen if the file size was greater than the token
// buckets burst rate, but that can't happen because we don't hash files
// larger than the burst rate (scan_max_file_size).
return
}

delay := reservation.Delay()
if delay == 0 {
return
}

timer := time.NewTimer(delay)
defer timer.Stop()
select {
case <-s.done:
case <-timer.C:
}
}

Expand Down
20 changes: 15 additions & 5 deletions dev-tools/generate_notice.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def read_versions(vendor):
return libs


def gather_dependencies(vendor_dirs):
def gather_dependencies(vendor_dirs, overrides=None):
dependencies = {} # lib_path -> [array of lib]
for vendor in vendor_dirs:
libs = read_versions(vendor)
Expand All @@ -66,7 +66,9 @@ def gather_dependencies(vendor_dirs):
lib["license_summary"] = detect_license_summary(lib["license_contents"])
if lib["license_summary"] == "UNKNOWN":
print("WARNING: Unknown license for: {}".format(lib_path))

revision = overrides.get(lib_path, {}).get("revision")
if revision:
lib["revision"] = revision
if lib_path not in dependencies:
dependencies[lib_path] = [lib]
else:
Expand Down Expand Up @@ -137,8 +139,8 @@ def get_url(repo):
return "https://github.com/{}/{}".format(words[1], words[2])


def create_notice(filename, beat, copyright, vendor_dirs, csvfile):
dependencies = gather_dependencies(vendor_dirs)
def create_notice(filename, beat, copyright, vendor_dirs, csvfile, overrides=None):
dependencies = gather_dependencies(vendor_dirs, overrides=overrides)
if not csvfile:
with open(filename, "w+") as f:
write_notice_file(f, beat, copyright, dependencies)
Expand Down Expand Up @@ -250,6 +252,9 @@ def detect_license_summary(content):
help="Output to a csv file")
parser.add_argument("-e", "--excludes", default=["dev-tools", "build"],
help="List of top directories to exclude")
# no need to be generic for now, no other transitive dependency information available
parser.add_argument("--beats-origin", type=argparse.FileType('r'),
help="path to beats vendor.json")
parser.add_argument("-s", "--skip-notice", default=[],
help="List of NOTICE files to skip")
args = parser.parse_args()
Expand Down Expand Up @@ -277,7 +282,12 @@ def detect_license_summary(content):
if exclude in dirs:
dirs.remove(exclude)

overrides = {} # revision overrides only for now
if args.beats_origin:
govendor = json.load(args.beats_origin)
overrides = {package['path']: package for package in govendor["package"]}

print("Get the licenses available from {}".format(vendor_dirs))
create_notice(notice, args.beat, args.copyright, vendor_dirs, args.csvfile)
create_notice(notice, args.beat, args.copyright, vendor_dirs, args.csvfile, overrides=overrides)

print("Available at {}".format(notice))
1 change: 1 addition & 0 deletions libbeat/docs/communitybeats.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Logstash or Elasticsearch.
https://github.com/jarpy/factbeat[factbeat]:: Collects facts from https://puppetlabs.com/facter[Facter].
https://github.com/FStelzer/flowbeat[flowbeat]:: Collects, parses, and indexes http://www.sflow.org/index.php[sflow] samples.
https://github.com/GeneralElectric/GABeat[gabeat]:: Collects data from Google Analytics Realtime API.
https://github.com/GoogleCloudPlatform/gcsbeat[gcsbeat]:: Reads data from https://cloud.google.com/storage/[Google Cloud Storage] buckets.
https://github.com/jlevesy/githubbeat[githubbeat]:: Easily monitors GitHub repository activity.
https://github.com/hpcugent/gpfsbeat[gpfsbeat]:: Collects GPFS metric and quota information.
https://github.com/ullaakut/hackerbeat[hackerbeat]:: Indexes the top stories of HackerNews into an ElasticSearch instance.
Expand Down
Loading

0 comments on commit dcdfa7d

Please sign in to comment.