Commit Graph

1360 Commits

Author SHA1 Message Date
Martin Angers
8eee0b35f3
Add validations for agent options' command-line flags section. (#7979) 2022-10-03 08:29:41 -04:00
gillespi314
2a6895b015
Log user email upon successful SSO login (#8012) 2022-09-29 09:25:45 -05:00
Martin Angers
8023193ea8
Fix integration logger test (#8014) 2022-09-28 16:35:54 -04:00
Sharvil Shah
b13683952d
add index to orbit_node_key (#7990)
Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
2022-09-28 02:25:07 +05:30
Sharvil Shah
cfb3c7ae9f
switch orbit enroll logic to use osquery_host_id (#7984) 2022-09-28 01:29:25 +05:30
gillespi314
749ff9ec2b
Add logging to capture user email upon successful login (#7927)
* Log user email upon successful login

* Add user email to logger context

* Use logging.With Extras for login email
2022-09-27 16:32:46 -03:00
Martin Angers
142e298631
Update osquery validations from 5.4.0 to 5.5.1 (#7960) 2022-09-27 08:35:57 -04:00
Roberto Dip
b9927eade4
make orbit and device ping paths unversioned (#7933) 2022-09-26 14:39:56 -03:00
Roberto Dip
a509bdd0ac
add backwards compatiblity to orbit enrollment via the API (#7921) 2022-09-26 11:44:09 -03:00
Roberto Dip
2fcb27ed3f
add headers denoting capabilities between fleet server / desktop / orbit (#7833)
This adds a new mechanism to allow us to handle compatibility issues between Orbit, Fleet Server and Fleet Desktop.

The general idea is to _always_ send a custom header of the form:

```
fleet-capabilities-header = "X-Fleet-Capabilities:" capabilities
capabilities              = capability * (,)
capability                = string
```

Both from the server to the clients (Orbit, Fleet Desktop) and vice-versa. For an example, see: 8c0bbdd291

Also, the following applies:

- Backwards compat: if the header is not present, assume that orbit/fleet doesn't have the capability
- The current capabilities endpoint will be removed

### Motivation

This solution is trying to solve the following problems:

- We have three independent processes communicating with each other (Fleet Desktop, Orbit and Fleet Server). Each process can be updated independently, and therefore we need a way for each process to know what features are supported by its peers.
- We originally implemented a dedicated API endpoint in the server that returned a list of the capabilities (or "features") enabled, we found this, and any other server-only solution (like API versioning) to be insufficient because:
  - There are cases in which the server also needs to know which features are supported by its clients
  - Clients needed to poll for changes to detect if the capabilities supported by the server change, by sending the capabilities on each request we have a much cleaner way to handling different responses.
- We are also introducing an unauthenticated endpoint to get the server features, this gives us flexibility if we need to implement different authentication mechanisms, and was one of the pitfalls of the first implementation.

Related to https://github.com/fleetdm/fleet/issues/7929
2022-09-26 07:53:53 -03:00
Juan Fernandez
d7ca8fcd66
Reverted changes made to Fleet Desktop - should not use the lightweight 'desktop' endpoint (#7919)
Reverted changes made to Fleet Desktop. Desktop should not use the lightweight 'desktop' endpoint
2022-09-23 15:18:19 -04:00
Sharvil Shah
7d4e2e2b4b
Orbit remote management for flags (#7246)
Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
2022-09-24 00:30:23 +05:30
Martin Angers
5477acb688
Add low_disk_space_count property to GET /host_summary (#7872) 2022-09-21 15:56:17 -04:00
Martin Angers
db24cf32fa
Add new low_disk_space URL parameter to the GET /hosts endpoint (and GET /hosts/count) (#7853) 2022-09-21 15:16:31 -04:00
gillespi314
34688f531a
Refactor webhooks cron to new schedule package (#7840) 2022-09-20 14:26:36 -05:00
Martin Angers
478b4d3f69
Validate team and appconfig payloads, with dry-run and force modes (#7731) 2022-09-19 13:53:44 -04:00
gillespi314
6a3d9959fc
Refactor vulnerabilities cron to scheduler package (#7650) 2022-09-16 10:08:51 -05:00
Juan Fernandez
4ef883b311
Feature 6946: Fleet Desktop should use minimal api end-point for data (#7536)
Updated desktop client to use new EE desktop endpoint.
2022-09-15 12:12:50 -04:00
Zach Wasserman
486b67caca
Add initial support for kubequery (#6863)
Configuration and fixes for the Fleet server and frontend to add support
for https://github.com/Uptycs/kubequery.

Co-authored-by: Michal Nicpon <michal@fleetdm.com>
2022-09-15 10:02:17 -06:00
Juan Fernandez
765031d962
Bug 6717: Duplicate calls on vulnerability third party integrations. (#7698)
If the same vulnerability was present in more than one software, then duplicated third party integration calls were being issued.
2022-09-13 10:41:52 -04:00
Tomas Touceda
8457e55b53
Bump go to 1.19.1 (#7690)
* Bump go to 1.19.1

* Bump remaining go-version to the 1.19.1

* Add extra paths for test-go

* Oops, putting the right path in the right place

* gofmt file

* gofmt ALL THE THINGS

* Moar changes

* Actually, go.mod doesn't like minor versions
2022-09-12 20:32:43 -03:00
Juan Fernandez
b60d535d4a
Feature 7084: Add new EE endpoint for Fleet Desktop (#7530)
Added new EE endpoint, that is meant to be used by Fleet Desktop only. The new endpoint will return the number of failed policies.
2022-09-12 15:37:38 -04:00
Juan Fernandez
14d0499c4b
Bug 7682: Fixed issue with migration not running on MariaDB (#7701)
Update migration to account for different FK name under MariaDB.
2022-09-12 15:36:55 -04:00
Juan Fernandez
98e4d6e0bc
Feature 7394: Use MSRC parser to generate security bulletin artifacts (#7491)
Generate security artifacts using the MSRC parser.
2022-09-12 15:17:13 -04:00
Frank Sievertsen
dd8cf37a85
#7624 accept empty bearer authorization token. (#7685)
* Fix #7624 accept empty bearer authorization token.

* add changes file
2022-09-12 16:09:41 +02:00
Martin Angers
988f50fa34
Document all keys in config and team YAML documents (#7449)
- Add a new "Configuration for contributors" doc page. Move settings that are not recommended for production use
- Remove settings modified in the `config` YAML document from the deploying/configuration doc page
- Document all keys in `config` and `teams` YAML documents
- Add comments to several `.go` files and remove unused struct
2022-09-08 17:57:38 -04:00
Roberto Dip
740aafd817
Revert token rotation (#7628)
This reverts all changes related to token rotation.
2022-09-08 15:04:02 -03:00
gillespi314
abc131575b
Bring patch commits to main (#7647) 2022-09-08 12:20:07 -05:00
Roberto Dip
2deabc23d0
fix panic when reading team features from the database (#7633)
This fixes an unreleased bug I introduced in eeefe2, as the config colum in the teams table is nulleable, it unmarshalls into nil and we can't dereference the variable
2022-09-08 13:33:10 +00:00
Roberto Dip
9174c7c711
token rotation for Fleet Desktop (#7517)
See https://github.com/fleetdm/fleet/issues/6348 for a very detailed rundown

Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
2022-09-06 20:25:29 -03:00
Juan Fernandez
b6d084deec
Feature 7559: Include 3rd party severity scores in the vulnerability web-hook payload (#7581)
Premium users should receive vulnerability scores as part of the web-hook payload.
2022-09-06 15:12:17 -04:00
Juan Fernandez
e86aa9d99b
Bug 7465: Bump out of date migrations (#7478)
Bump out of date migrations
2022-09-06 10:58:10 -04:00
Martin Angers
aa0102d6b6
Remove aggregate host counts from GET /hosts responses (#7510) 2022-09-06 10:34:06 -04:00
gillespi314
26753ef62b
Add issues count to GET /labels/{id}/hosts response (#7381) 2022-09-02 09:13:53 -05:00
Michal Nicpon
0709d1bc5c
improve vuln cpe matching on macos (#6985)
* add cpe translations
* fix matching on target_sw
2022-09-01 10:02:07 -06:00
Roberto Dip
9dfd903c3a
set defaults for team spec configs related to features (#7476)
This adjusts functions related to applying team specs to make sure the `features` key works as expected, this is:

1. Create Team flow
    1. if no features are provided, we copy whatever features are set in the global config
    2. otherwise, we generate a new config merging whatever is provided with the defaults for new installs.
2. Edit Team flow: we always generate a new config merging whatever is provided with the defaults for new installs.
2022-08-31 17:30:46 -03:00
Juan Fernandez
2699c22143
Feature 7077: Add MSRC feed parser (#7424)
Added parser for MSRC
2022-08-30 16:39:50 -04:00
Juan Fernandez
87717df1da
Bug 7441: Upgrading to 4.19.0 might fail due to migration (#7446)
* Make Change software vendor width mig. more robust

If there are two or more entries in the software table with the same name, version, source, release and arch but different vendors then the migration used for increasing the vendor width will fail.
2022-08-30 11:20:48 -04:00
gillespi314
8157359f84
Ingest Windows host display version for hosts table (#7403) 2022-08-30 10:16:48 -05:00
Roberto Dip
eeefe2fab9
enable controlled rollout of features by teams (#7408) 2022-08-30 08:13:09 -03:00
Martin Angers
f602ea3446
Provide Munki issues for MacOS hosts (#7280) 2022-08-29 14:40:16 -04:00
Juan Fernandez
3048a07fd1
Feature 7076: Ingest installed windows updates (#7138)
* Ingest installed Windows updates and store them in the windows_updates table. 
* Added config option for enabling/disabling Windows update ingestion and Windows OS vuln. detection.
2022-08-26 14:55:03 -04:00
Roberto Dip
9a1d2066bb
deprecate host_settings in favor of features (#7358)
Related to #7312, this makes use of the changes introduced in #7353 to rename host_settings to features while keeping backwards compatibility.
2022-08-25 13:41:50 -03:00
Roberto Dip
c943e0665a
add a mechanism to deprecate AppConfig settings w/ backwards-compat (#7353)
Related to https://github.com/fleetdm/fleet/issues/7312, the motivation behind these changes is to introduce a way to deprecate configurations in `AppConfig`, while still preserving backwards compatibility.

From the Epic:

> NOTE: `host_settings` is now replaced by `features`. We should still support `host_settings` as an alias to `features` for backwards compatibility, but in our communications, we should use and recommend features as the canonical way forward.
2022-08-24 18:40:09 -03:00
Juan Fernandez
0fab2fe0eb
Feature 6538: Remove cpe_id from the software_cve table (#6587)
* Don't insert dummy values for non-match CPEs, exclude OVAL platforms when getting software iterator.
* Removed CPEID from SoftwareVulnerability type and software_cve.cpe_id column.
* Removed GeneratedCPEID property
2022-08-24 13:10:58 -04:00
Juan Fernandez
7b612aa030
Bug 7320: Fixed dulp. vulns. on software details. (#7342)
* Bug 7320: Fixed dulp. vulns. on software details.

The software details page was showing duplicated vulnerabilities if the software was being used by many hosts.
2022-08-24 09:45:20 -04:00
Martin Angers
dfd7d3f244
Add activity types for applied team spec and edited agent options (#7355) 2022-08-24 08:32:45 -04:00
Roberto Dip
fe9cdb7017
fix flaky TestIntegrationsSandbox/TestInstallerHeadCheck (#7345)
this adjusts the TestInstallerHeadCheck check to use `DoRaw` instead of `Do`, which sends a body with null when nil is passed for the params parameter.
2022-08-23 09:58:10 -03:00
gillespi314
7fb109e6b3
Handle errors for duplicate os records (#7294) 2022-08-22 14:34:00 -05:00
Juan Fernandez
e6aba8caaa
Bug with Vendor Width migration (#7339)
Updated migration used to increate the width of 'software.vendor' to
address issue found when running migration in aurora: "ALGORITHM=INPLACE is not
supported. Reason: cannot silently convert NULL values, as required in
this SQL_MODE. Try ALGORITHM=COPY."
2022-08-22 13:01:18 -04:00
Juan Fernandez
2932ea0899
Bug 7332: Include software without CPE entries (#7334)
When listing software for performing vuln. detection include software without CPE entries.
2022-08-22 11:45:17 -04:00
Juan Fernandez
4013cbbdfc
Feature 6975: Populate vendor column in software inventory (#7297)
- Populate 'software.vendor' when ingesting software from Windows hosts.
- Increate width of 'software.vendor'.
2022-08-18 18:02:56 -04:00
Zachary Winnerman
2103de275a
improve error handling in vulnerabilities cron (#7276)
* improve error handling in vulnerabilities cron

* fix tests

* Use errHandler and go mod tidy

* Add dep that got removed by mod tidy

* add dsl to tools

* Add changes file

Co-authored-by: Michal Nicpon <michal@fleetdm.com>
Co-authored-by: Tomas Touceda <chiiph@gmail.com>
2022-08-18 16:53:58 -03:00
Roberto Dip
8acf14ab43
adjust installers endpoint to avoid AJAX downloads (#7226)
Related to #7206, this delegates the handling of the download to the browser
2022-08-16 12:54:41 -03:00
Martin Angers
94d1ebb822
Set refetch_requested to true for newly enrolled hosts (#7225) 2022-08-16 08:33:15 -04:00
Roberto Dip
05ddeade90
add back-end implementation for SSO JIT provisioning (#7182)
Related to #7053, this uses the SSO config added in #7140 to enable JIT provisioning for premium instances.
2022-08-15 14:42:33 -03:00
Martin Angers
b891e0d7f7
Add mdm solution payload to GET /hosts response when filtering by mdm_id (#7198) 2022-08-15 12:57:25 -04:00
gillespi314
90f57f4849
Enhance API endpoints with host operating systems info (#7154) 2022-08-12 14:23:25 -05:00
Juan Fernandez
8dccc42027
Bug 5983: Performance issues when listing software (#6879)
Improve performance when listing software by using the software_host_counts aggregate table.
2022-08-10 17:43:22 -04:00
Martin Angers
c8cdddf0ea
Update /macadmins endpoints to include MDM name and aggregate count (#7137) 2022-08-10 15:15:01 -04:00
Roberto Dip
fc8c15c0d1
add application config setting to enable JIT provisioning (#7140)
As part of #7053, this adds a config setting to enable JIT provisioning.
2022-08-10 15:15:35 -03:00
gillespi314
e2194be61c
Add schedule package and refactor cron jobs for cleanups, aggregations, and usage statistics (#6618) 2022-08-10 11:00:56 -05:00
Martin Angers
9755eb2e27
Support async saving of scheduled query statistics (#7012) 2022-08-10 10:01:05 -04:00
gillespi314
3a88afaf98
Add new database tables and queries for host operating systems (#6920) 2022-08-09 13:34:41 -05:00
Lucas Manuel Rodriguez
6dcff28be0
Move specs parsing functionality to a new pkg/spec package (#7050) 2022-08-05 19:07:32 -03:00
Roberto Dip
2b8743e240
send enroll secret in query for installers (#7064)
This changes how the enroll secret is sent to the server, as they might contain /, which was causing problems with our router.
2022-08-04 18:39:38 -03:00
Juan Fernandez
966bfbf85e
Feature 6487: Deprecate cpe_id from software_cve table (#6562)
Part 2/3 of the removal of the cpe_id column from the software_cve table in favor of using the newly added software_id coumn.
2022-08-04 09:24:44 -04:00
Martin Angers
012869f971
Fleet Premium: de-anonymize usage stats (#7013) 2022-08-03 14:44:34 -04:00
Martin Angers
c1d38598e2
Prevent removing team enroll secrets when applying team specs without new secrets (#6890) 2022-08-02 09:51:03 -04:00
Gabriel Hernandez
f61a17bd9b
add google analytics to sandbox instances (#6941)
* add google analytics to sandbox instances

* Add serverType variable to frontend handler

* update version of html-webpack-plugin

Co-authored-by: Lucas Rodriguez <lucas@fleetdm.com>
2022-08-01 11:27:12 +01:00
Roberto Dip
90b723e45a
consolidate sandbox env flags (#6917)
Related to #6894, this entirely replaces FLEET_DEMO with the server config added in #6597

As part of this, I also implemented a small refactor to the integration test suite to allow setting a custom config when the server is initialized.
2022-07-27 16:47:39 -03:00
RachelElysia
52673b6ed2
Sentence case error (#6845) 2022-07-25 13:14:05 -04:00
Juan Fernandez
af80406b59
Bug 6777: Make the regexp used for detecting the oval platform major, min versions more permissive (#6800)
When getting the major/minor version for OVAL processing, handle the LTS post-fix for Ubuntu platforms
2022-07-21 12:55:07 -04:00
gillespi314
0312454f4c
Modify host battery health returned by GET /hosts/:id (#6782) 2022-07-20 21:16:03 -05:00
gillespi314
cc34585a47
Add statistics for number of hosts that have not submitted results for distributed queries (#6495) 2022-07-20 20:54:10 -05:00
Michal Nicpon
e3e17f3389
Fix double quote usage in sql query (#6707) 2022-07-20 10:10:03 -06:00
Michal Nicpon
d4be5ad2a1
add upgrade tests (#6596)
* add upgrade tests

* fix lint issues

go.mod

* remove req.cnf

* revert unrelated changes

* make version configurable in test

* fix golangci-lint ruleguard issue

Related to https://github.com/go-critic/go-critic/issues/1152
Need to have github.com/quasilyte/go-ruleguard/dsl

* fix lint issues

* fix

* clean up docker-compose.yml

* fix http request

* add readme

* fix lint issues

* address feedback

* fix

* add platform

* address feedback

* run go fmt
2022-07-19 15:11:51 -06:00
Zach Wasserman
710c304d94
Apply password requirements to admin-created users (#6667)
This was requested by a customer.
2022-07-19 09:47:25 -07:00
Lucas Manuel Rodriguez
de1717291d
Set authz checked when rate limiting device endpoints (#6702)
* Set authz checked when rate limiting device endpoints

* Unexport var and attempt to fix flaky test
2022-07-18 14:22:49 -03:00
Eng Zer Jun
1ab171faf3
test: use T.Setenv to set env vars in tests (#6714)
This commit replaces `os.Setenv` with `t.Setenv` in tests. The
environment variable is automatically restored to its original value
when the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.Setenv
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-07-18 14:22:28 -03:00
Roberto Dip
69f8f2a73b
add API endpoints to retrieve pre-built installers (#6672)
Rel: #6365, this adds a new endpoint to check and download pre-built installers.
2022-07-18 13:44:30 -03:00
Juan Fernandez
5b90d11c85
Bug 6508: Don't show non-CVE entries (#6686)
Only include vulnerabilities (CVEs) in Fleet UI and API
2022-07-18 09:23:32 -04:00
Roberto Dip
faa3e136d3
improve installerstore tool w/ better errors and bucket creation (#6685)
This improves the installerstore CLI tool with:

- The ability to create tests buckets for local development (otherwise you have to interact with another CLI or the MinIO UI)
- Improved error handling and messaging.
2022-07-15 12:20:24 -03:00
Noah Talerman
8a9e828d6e
In fleetctl expired license message, update doc link (#6486)
- Update message to include correct link: https://fleetdm.com/docs/using-fleet/faq#how-do-i-downgrade-from-fleet-premium-to-fleet-free
2022-07-14 17:55:57 -04:00
Roberto Dip
6ce70b416d
add a new tool to upload installers to blob storage (#6661)
Related to #6365 this adds a new tool to upload pre-built Orbit installers to a storage blob. It uses the same file conventions that the Fleet server expects, making it useful for local testing and infra envs alike.\

Usage and details in the README
2022-07-14 16:11:52 -03:00
Roberto Dip
86366b2ed8
add a new S3 datastore to retrieve pre-built packages (#6631)
Related to #6365, this extends the datastore/s3 package to retrieve installers from S3 according to the conventions listed in the parent issue. This also includes:

- A minor refactor to decouple Carves-related functionality from the core S3 functionality
- Set-up to run tests using minio (only enabled via the FILE_STORAGE_TEST env flag)
2022-07-14 14:14:24 -03:00
Roberto Dip
7e68ee2253
add configuration to retrieve installers from S3 (#6630)
Related to #6365, this adds relevant configuration to the packaging key to retrieve installers from S3.
2022-07-13 09:34:25 -03:00
Roberto Dip
6faee84f57
allow to configure a default global enroll secret (#6609)
Related to #6365 this adds a new config to set a global enroll token that will be used by the server.
2022-07-12 19:12:10 -03:00
Tomas Touceda
7f8099db57
Add sandbox fleet serve config (#6619)
* Add sandbox fleet serve config

* Update docs

* Maybe fix lint issues

* Add lint dep
2022-07-12 18:21:15 -03:00
Tomas Touceda
af0cf9b703
Add rate limits for device authed endpoints (#6529)
* Add rate limits for device authed endpoints

* Fix lint

* Add missing test

* Fix test

* Increase the quota for desktop endpoints

* Add comment about quota
2022-07-11 10:49:05 -03:00
Roberto Dip
1ed8efacfa
increase the length of host_batteries.health (#6560)
Rel to #6559, this increases the size of host_batteries.health for cases like "Check Battery" that exceed 10 chars
2022-07-08 21:06:50 +00:00
Juan Fernandez
ab8cde6371
Feature 6454: Add software_id column to software_cve table (#6489)
Added software_id to software_cve in preparation for the removal of the cpe_id column.
2022-07-07 10:22:10 -04:00
Lucas Manuel Rodriguez
700bb9aa98
Fix Datastore.HostByIdentifier to set SeenTime (#6484)
* Fix Datastore.HostByIdentifier to set SeenTime

* Add changes file
2022-07-05 08:08:43 -03:00
Zach Wasserman
03734a37aa
Add server support for Fleet Sandbox demo login (#6387)
* Add server support for Fleet Sandbox demo login

This adds an endpoint `/api/latest/fleet/demologin` that provides a
redirect for the fleetdm.com portion of Fleet Sandbox to automatically
log in a user. The username and password must be provided as form
values. The endpoint is only enabled if `FLEET_DEMO=1` is set in the
server environment.

This was tested locally with the following HTML served by `python3 -m
http.server`, and the Fleet server running with `FLEET_DEMO=1
./build/fleet serve --dev`:

```
<!DOCTYPE html>
  <body>
    <form
      method="post"
      action="https://localhost:8080/api/latest/fleet/demologin"
      id="demologin"
    >
      <input type="hidden" name="email" value="admin@example.com" />
      <input type="hidden" name="password" value="admin123123#" />
      <input type="submit"/>
    </form>
    <script type="text/javascript">
      document.forms["demologin"].submit();
    </script>
  </body>
</html>

```

For Fleet sandbox purposes, the `action` should be set to the correct
hostname for the sandbox instance, while the `email` and `password`
should be set to the same credentials that were provided when creating
the instance.

* lucas comments

* Add integration tests

* Fix status codes and add comments

Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
2022-07-01 16:52:55 -03:00
Zach Wasserman
db22f68c88
Separate health checks for MySQL and Redis (#6468)
This required a bit of refactoring of some mocking due to how the code
generation does not handle having the same function in different types.
2022-07-01 08:08:03 -03:00
Martin Angers
b9930930f5
Document the device-authenticated endpoints in API for Contributors (#6406) 2022-06-29 08:12:20 -04:00
Roberto Dip
b2d07e56b5
report error analytics (#6341)
Related to #5898, this reports an anonymized summary of errors stored in Redis into the analytics payload.

For each error stored, this includes:

- A `count` attribute with the number of occurrences of the error
- A `loc` attribute with the 3 topmost lines in the stack trace. Note that stack traces only contain package name + line number (example: github.com/fleetdm/fleet/server.go:12

This also includes a minor refactor around error types.
2022-06-28 16:31:14 -03:00
Martin Angers
539be8ee09
Add battery info in host details response (#6394) 2022-06-28 14:11:49 -04:00
Juan Fernandez
79bf51b03c
Feature 6242: Use oval to detect vulnerabilities on Fedora hosts (#6330)
* Feature 6242: Scan Fedora hosts using OVAL definitions
2022-06-24 11:02:51 -04:00
Juan Fernandez
9d01ba33c6
Feature 6096: Scan RHEL/CentOS hosts using OVAL definitions (#6241)
Extended the OVAL parser/analyzer so that we can scan RHEL based systems.
2022-06-23 16:44:45 -04:00
gillespi314
15de4f3e65
Update Fleet host detail query so os_version for Ubuntu hosts reflects accurate patch number in point release (#6360) 2022-06-23 15:24:18 -05:00
Lucas Manuel Rodriguez
fc7650c4f8
Fix mock tests set test name (#6345)
* Set mock test on live query mocked tests

* Use MySQL 5.7 as default in docker-compose.yml
2022-06-23 11:34:52 -03:00
Martin Angers
8f66a50f2b
Add hosts enrolled by operating system to anonymous usage stats (#6329) 2022-06-22 16:38:11 -04:00
Roberto Dip
2948e112f6
ensure software_host_counts is cleaned when software is deleted (#6270)
Related to #5982, this ensures we clean up software_host_counts rows referencing software that is not longer present in the software table.
2022-06-22 17:35:53 -03:00
Martin Angers
dc9e158153
Add weekly active users count in anonymous usage stats (#6317) 2022-06-22 15:20:57 -04:00
Lucas Manuel Rodriguez
9b210fc6bd
Add support for CA root certificate to Fleet Desktop (fleetctl package's --fleet-certificate flag) (#6312)
* Orbit to pass the value of `--fleet-certificate` to Fleet Desktop

* Add changes for testing
2022-06-21 16:25:36 -03:00
Roberto Dip
4a867d53dc
use a single context for background jobs and HTTP handlers (#6313) 2022-06-21 15:09:00 -03:00
Martin Angers
7bfe93f5d7
Include an error code as query string in /sso/callback response in case of failure (#6286) 2022-06-21 09:04:50 -04:00
Roberto Dip
984605f630
store count alongside unique error instances in Redis (#6232)
Related to #4972, this adds a new key, error:<hash>:count to Redis in order to keep track of how many times each instance of an error occurred.
2022-06-21 08:43:53 -03:00
Martin Angers
1d60d6fdc2
Add test for no host in failing policy trigger (#6279) 2022-06-20 11:41:45 -04:00
Aaron
75f093e802
Use nanoseconds for campaign IDs (#6216)
Fixes #4806 by adding resolution to the generated IDs.
2022-06-14 15:46:09 +00:00
gillespi314
ed4ae18602
Handle transparency url for downgraded license (#6207) 2022-06-13 16:03:51 -05:00
Martin Angers
81f0e0ccfa
Track active hosts count and enforce limit (#6099) 2022-06-13 16:29:32 -04:00
Roberto Dip
19c5e3545b
add a dedicated endpoint that redirects to fleet_desktop.transparency_url (#6204)
As part of https://github.com/fleetdm/fleet/issues/5947, and in order to have a simplified workflow in Fleet Desktop, we defined https://github.com/fleetdm/fleet/issues/6200 to add a new endpoint that redirects to the transparency url as defined in the config (for premium users only)

```
~/projects/fleet $ curl -v -s https://localhost:8080/api/latest/fleet/device/bf34ab98-23b0-48bc-8e82-8c0143cba11c/transparency
* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 307
< content-type: application/json; charset=utf-8
< location: https://fleetdm.com/transparency
< content-length: 0
< date: Mon, 13 Jun 2022 18:09:29 GMT
<
* Connection #0 to host localhost left intact
```
2022-06-13 16:07:08 -03:00
Martin Angers
7f9bb6431e
Update team integrations to reference global integrations (part of failing policies automation support) (#6156) 2022-06-13 10:04:47 -04:00
Eng Zer Jun
abe33f1d8d
test: use T.TempDir to create temporary test directory (#6080)
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-06-13 10:20:38 -03:00
Lucas Manuel Rodriguez
11af33e9a1
Allow troubleshooting of mocked live query store (#6197) 2022-06-13 10:18:03 -03:00
Lucas Manuel Rodriguez
515454e47f
Fix no such table errors for mdm & munki_info in vanilla osquery macOS hosts (#6170)
* Add discovery queries for mdm and munki_info

* Add changes file

* Amend discovery table tests
2022-06-13 08:52:33 -03:00
Lucas Manuel Rodriguez
4cfeaa1580
Do not use golangci action for better reproducibility (use make lint-go) (#6175)
* Do not use golangci action for better reproducibility

* Add fix to trigger build

* Fix all reported issues

* fix more lint errors

* Add missing import

* Remove unused method

* Remove change not necessary
2022-06-10 18:52:24 -03:00
gillespi314
44f902218c
Improve live query UX (#5749) 2022-06-10 13:29:45 -05:00
gillespi314
a3ab5646f5
Add new fleet_desktop property to config object (#6151) 2022-06-10 10:39:02 -05:00
Roberto Dip
3bcd4e4ca6
Revert "pin api version in DeviceClient.ListDevicePolicies (#6139)" (#6163)
This reverts commit 4d184ef583.
2022-06-09 20:35:40 -03:00
Tomas Touceda
a15101601c
Use the improved users query everywhere (#6126)
* Use the improved users query everywhere

* Filter out users without a home dir
2022-06-09 17:18:28 -03:00
Lucas Manuel Rodriguez
3dd89bc0a1
Fix flaky test TestVulnerabilityDataStream (#6162) 2022-06-09 10:36:37 -03:00
Tomas Touceda
fc215610a4
Allow users to customize detail queries for troubleshooting purposes (#6150)
* Allow users to customize detail queries for troubleshooting purposes

* Address review comments
2022-06-09 10:33:49 -03:00
Roberto Dip
a6cf9b3d8d
add endpoint in devices API to query for api features (#6152)
Related to #6063, this adds a new device API to get an object with boolean values that we can use as feature flags to manage backwards compatibility in Fleet Desktop.
2022-06-09 10:17:55 -03:00
Michal Nicpon
bac168e3fd
fix mem usage cve sync (#6131) 2022-06-08 13:15:44 -06:00
Lucas Manuel Rodriguez
99833a3b92
Rearrange migrations (#6140)
Co-authored-by: Juan Fernandez <juan@fleetdm.com>
2022-06-08 16:03:23 -03:00
Juan Fernandez
337734fce1
Bug: Issue while parsing dpkg objects with inline names (#6146)
* Bug: Issue while parsing dpkg objects with inline names

Dpkg objects can also define their names inline, not only using variable references.
2022-06-08 14:29:58 -04:00
Roberto Dip
4d184ef583
pin api version in DeviceClient.ListDevicePolicies (#6139) 2022-06-08 11:34:40 -03:00
Juan Fernandez
ef73039559
Improve vulnerability detection for Ubuntu (#6102)
Feature: Improve our capability to detect vulnerable software on Ubuntu hosts

To improve the capability of detecting vulnerable software on Ubuntu, we are now using OVAL definitions to detect vulnerable software on Ubuntu hosts. If data sync is enabled (disable_data_sync=false) OVAL definitions are automatically kept up to date (they are 'refreshed' once per day) - there's also the option to manually download the OVAL definitions using the 'fleetctl vulnerability-data-stream' command. Downloaded definitions are then parsed into an intermediary format and then used to identify vulnerable software on Ubuntu hosts. Finally, any 'recent' detected vulnerabilities are sent to any third-party integrations.
2022-06-07 21:09:47 -04:00
Martin Angers
0b5fcd8e27
Add support for custom headers in fleetctl (#6118) 2022-06-07 16:00:09 -04:00
Roberto Dip
19f995d3b5
only include policies in device endpoints for premium users (#6077)
This removes policy information from `GET /api/_version_/fleet/device/{token}` from non-premium Fleet instances.

Starting the server with `./build/fleet serve --dev --dev_license`

```bash
$ curl -s https://localhost:8080/api/latest/fleet/device/1804e808-171f-4dda-9bec-f695b2f2371a | jq '.host.policies // "not present"'
[
  {
    "id": 3,
    "name": "Antivirus healthy (Linux)",
    "query": "SELECT score FROM (SELECT case when COUNT(*) = 2 then 1 ELSE 0 END AS score FROM processes WHERE (name = 'clamd') OR (name = 'freshclam')) WHERE score == 1;",
    "description": "Checks that both ClamAV's daemon and its updater service (freshclam) are running.",
    "author_id": 1,
    "author_name": "Roberto",
    "author_email": "test@example.com",
    "team_id": null,
    "resolution": "Ensure ClamAV and Freshclam are installed and running.",
    "platform": "darwin,linux",
    "created_at": "2022-05-23T20:53:36Z",
    "updated_at": "2022-06-03T13:17:42Z",
    "response": ""
  }
]
```

Starting the server with `./build/fleet serve --dev`

```bash
$ curl -s https://localhost:8080/api/latest/fleet/device/1804e808-171f-4dda-9bec-f695b2f2371a | jq '.host.policies // "not present"'
"not present"
```
2022-06-07 13:27:13 -03:00
Martin Angers
a23e0c41ff
Support failing policies integrations (#5973) 2022-06-06 10:41:51 -04:00
Michal Nicpon
1044182b7b
fix epss probability (#6083) 2022-06-03 11:37:47 -06:00
Roberto Dip
842ebbb2ae
add Go client to consume device endpoints (#5987)
This adds a new API client named DeviceClient to server/service, meant to consume device endpoints and be used from Fleet Desktop.

Some of the logic to make requests and parse responses was very repetitive, so I introduced a private baseClient type and moved some of the logic of the existent Client there.

Related to #5685 and #5697
2022-06-01 20:05:05 -03:00
Michal Nicpon
30a864c8d2
Sync CVE scores periodically (#5838) 2022-06-01 10:06:57 -06:00
Roberto Dip
eb8defdcbe
add premium, device authed endpoint to retrieve policies (#5967)
This adds a new device authenticated endpoint, `/api/_version_/fleet/device/{token}/policies` to retrieve the device policies.

An example request / response looks like:

```bash
curl  https://localhost:8080/api/latest/fleet/device/1804e808-171f-4dda-9bec-f695b2f2371a/policies
```

```json
{
  "policies": [
    {
      "id": 3,
      "name": "Antivirus healthy (Linux)",
      "query": "SELECT score FROM (SELECT case when COUNT(*) = 2 then 1 ELSE 0 END AS score FROM processes WHERE (name = 'clamd') OR (name = 'freshclam')) WHERE score == 1;",
      "description": "Checks that both ClamAV's daemon and its updater service (freshclam) are running.",
      "author_id": 1,
      "author_name": "Admin",
      "author_email": "admin@example.com",
      "team_id": null,
      "resolution": "Ensure ClamAV and Freshclam are installed and running.",
      "platform": "darwin,windows,linux",
      "created_at": "2022-05-23T20:53:36Z",
      "updated_at": "2022-05-23T20:53:36Z",
      "response": "fail"
    }
  ]
}
```

Related to [#5685](https://github.com/fleetdm/fleet/issues/5685), in another changeset I will be adding "client" endpoints so we can consume this endpoint from Fleet Desktop
2022-05-31 14:54:43 -03:00
Lucas Manuel Rodriguez
98be6cfc29
Improve Fleet Desktop "My Device" menu item UX at install time (#5915)
* Improve Fleet Desktop My Device link availability

* Use svc.clock and add test

* Revert change and add check for LastEnrolledAt on tests
2022-05-31 12:56:51 -03:00
Lucas Manuel Rodriguez
9080563b7d
Fix some go lint warnings (#5888)
* Fix go lint warnings

* Add test for SMTPConfigured update
2022-05-31 07:19:57 -03:00
Michal Nicpon
a652292d0f
Don't return orphaned software from the API (#5840) 2022-05-30 09:23:27 -06:00
Roberto Dip
fc7a045209
ensure previous host membership policies are deleted on enrollment (#5890)
Related to #5776, this ensures that when a host is re-enrolled on a different team we cleanup existing policy memberships in the same way we do when a host is assigned a team through the API.
2022-05-30 10:30:15 -03:00
gillespi314
baeff6e893
Add validation for pack scheduled query interval (#5918) 2022-05-26 16:54:21 -05:00
Michal Nicpon
6083b180a6
fix duplicate hosts in vuln webhook (#5843) 2022-05-25 11:40:12 -06:00
gillespi314
b4ffec10db
Remove skipLoadingExtras and includeCVEScores from GetHost and HostByIdentifier methods (#5874) 2022-05-25 11:30:03 -05:00
gillespi314
85c6ca0e5f
Improve precision in reporting of unseen hosts via host status webhook automations (#5889) 2022-05-25 10:54:56 -05:00
Martin Angers
56ce1649ee
Add issues and device_mapping output to CSV export (#5864) 2022-05-23 15:35:05 -04:00
gillespi314
bbc1891420
Add ability to see Google Chrome profiles on the Hosts page (#5839) 2022-05-23 14:27:30 -05:00
gillespi314
2db2c16511
Include MIA hosts under total count for Offline hosts (#5854) 2022-05-23 14:11:02 -05:00
Roberto Dip
36284fecf0
wrap errors even if an error message is not provided (#5828) 2022-05-23 09:32:17 -03:00