Commit Graph

300 Commits

Author SHA1 Message Date
Tomas Touceda
a38a7f4ad4
Refactor one mysql test to be able to run independently (#1379)
* Refactor one mysql test to be able to run independently

* Initialize schema once

* Address review comments
2021-07-16 13:13:51 -03:00
Tomas Touceda
2d553db2aa
Issue 1231 add global schedule (#1383)
* Add Global Schedule

* Uncomment tests

* Uncomment integration tests

* Add targets for global schedule

* Add host label

* Simplify implementation

* wip

* Fix mock

* Add missing test

* Further simplify the implementation

* Forgot to remove test name

* Update names
2021-07-16 10:15:15 -03:00
Tomas Touceda
74fecf0d5b
Remove duplicate enroll secrets (#1388) 2021-07-14 19:05:54 -03:00
Tomas Touceda
82ab0a798e
Add host users (#1334)
* Add host users

* Add changes file and test removing pull_request from the on test

* Remove users and store the removal timestamp

* Improve test yml to allow for PRs from forks
2021-07-13 17:15:38 -03:00
Tomas Touceda
d5e40f329e
Issue 1324 add activity feed (#1343)
* Add activities generation

* Add activities endpoint

* Fix merge error

* Fix indentation issue

* Add changes file

* Address PR review comments

* Add mock activity func

* Address codacy warings

* Set foreign key but on delete set null

* Make user_id set to null if deleted
2021-07-13 16:54:22 -03:00
Tomas Touceda
322ac3c8f6
Make roles for users mandatory (#1338)
* Make roles for users mandatory

* Remove nop migration

* Add missing test for wrong role

* Properly validate global and team roles

* Address codacy issues

* Address codacy review

* No need to check for nil
2021-07-13 16:33:04 -03:00
Tomas Touceda
12215bfbbd
Disable user sso_enable if org is disabling sso (#1331)
* Disable user sso_enable if org is disabling sso

* Cleanup test

* Add withTx and use it in SaveConfig
2021-07-09 13:12:21 -03:00
Tomas Touceda
18fa2f6a02
Issue 1009 calculate diff software (#1305)
* First approach to diff

* Refactor things for better readability and testing

* Remove draft comment for algorithm

* Format things a bit better

* Remove unused and simplify code a bit

* Refactor for readability and testing

* Add changes file

* Implement new approach based on review comments

* Make sure to only delete from the current host

* Add single uninstall test and fix code

* Improve code based on review
2021-07-08 13:57:43 -03:00
Tomas Touceda
39034071ca
Issue 1286 improve errors (#1322)
* Refactor error handling for better extensibility and add more scaffolding for specific db errors

* Add integration tests to check errors from mysql are translated properly

* Address review comments

* Add changes file
2021-07-08 12:50:43 -03:00
Tomas Touceda
05ba38ce2f
Fetch all data for a host when listing it (#1293) 2021-07-02 12:59:42 -03:00
Zach Wasserman
8be9068c1c
Fix migration for MariaDB compatibility (#1280)
Give unique names to each new foreign key in the migrations.

Fixes #1279
2021-07-01 15:59:31 -07:00
Zach Wasserman
e0799bbc59
Include Team names when listing label hosts (#1267)
Fixes #1266
2021-06-30 09:28:45 -07:00
Zach Wasserman
c5280c0517
Add v4 suffix in go.mod (#1224) 2021-06-25 21:46:51 -07:00
RachelElysia
aeb852e168
Remove username from UI (#1168)
* Remove username from UI code
* Remove username from tests
* Remove username from database
* Modify server endpoints for removing username
* Implement backend aspects of removing username
* Update API docs
* Add name to fleetctl
2021-06-24 13:42:29 -07:00
Zach Wasserman
1417d01407
Make naming of host columns consistent (#1183)
Adding consistency between API and DB helps to make it easier for users
and developers working with the API to correctly order things.

Closes #317
2021-06-23 17:32:19 -07:00
Zach Wasserman
0a77f79d22
Backend and fleetctl for usage analytics (#1167)
- Add enable_analytics column to database.
- Allow enable_analytics to be set via API.
- Add messaging in fleetctl setup.

Note that this defaults to off for existing installations, and defaults
on for newly set up installs.

No collection or sending of analytics yet exists, we are strictly
storing the preference at this time.

Part of #454
2021-06-22 18:02:20 -07:00
Zach Wasserman
4800856bf7
Add label ID to get labels response (#1164)
Fixes #1065
2021-06-22 16:41:25 -07:00
Zach Wasserman
b859f7b747
Sort labels for membership update (#1156)
This may help with deadlocks on the `label_membership` table. It is not
clear from MySQL documentation whether the order of the records is
significant for locking within a single query. If it is, this should
help the problem. If it is not, this should have no negative impact.

May fix #1146
2021-06-21 16:10:24 -07:00
Zach Wasserman
19e8da177f
Allow Packs to be targeted to Teams (#1130)
- Add additional target type for packs.
- Refactor pack target datastore.
- Fixes for frontend target selector tier logic on packs page.
2021-06-18 09:43:16 -07:00
Zach Wasserman
2ad557e3b3 Merge branch 'main' into teams 2021-06-18 09:42:20 -07:00
Martavis Parker
5b2cac31d9
Agent options added to organization settings (#1120)
* #511 refactored update options - new params & ts

* updated server to include agent_options for read and update

* added agent options form to org settings

* #511 finished connecting agent form to server

* #511 fixing api to save/read agent options

* #511 linted

* #511 fixed reading & updating agent options

* #511 api fixes to support agent options

* #511 removed log

* Fix json.RawMessage pointers in tests

Co-authored-by: Zach Wasserman <zach@fleetdm.com>
2021-06-17 13:47:15 -07:00
Zach Wasserman
6b59a40dbc
Add backend and fleetctl support for API-only user (#1119)
- Add api_only to users table.
- Pass api_only values through service.
- Allow setting api_only in `fleetctl user create`.

Backend part of #402
2021-06-16 18:11:28 -07:00
Zach Wasserman
6249beb465
Reorder migrations for pre-4.0 upgrades (#1114)
Reorder migrations from the long-running `teams` branch to ensure that
they can run successfully for deployments upgrading from a pre-4.0
release.

All migrations from the `teams` branch are reordered to take place
_after_ all migrations from the `main` branch, using `20210601` as the
new date, after the latest released `main` branch migration on `20210526`.

Fixes #1058
2021-06-16 11:58:00 -07:00
Zach Wasserman
0a99ec751c
Fix targeting Teams in live queries (#1043)
Properly handle the `TargetTeam` type, allowing live queries to
successfully execute against Teams.

Part of #1022
2021-06-09 18:56:57 -07:00
Zach Wasserman
6a18b2a250
Appropriately filter teams returned in targets API (#1042)
Fixes #1021 by adding the appropriate teams filtering.
2021-06-09 18:05:04 -07:00
Zach Wasserman
0fd8590605
Add additional logging for label save failures (#1012)
This is intended to help with debugging #744.
2021-06-08 15:29:26 -07:00
Zach Wasserman
db459d3363
Continue to update names in backend code and docs (#976) 2021-06-06 16:58:23 -07:00
Zach Wasserman
fb32f0cf40
Remove kolide types and packages from backend (#974)
Generally renamed `kolide` -> `fleet`
2021-06-06 15:07:29 -07:00
Zach Wasserman
e4358a92bc
Filter hosts and label counts by teams (#949)
- Add TeamFilter to relevant host and label methods.
- Pass appropriate filter in service methods.

The dashboard should now show the appropriate hosts for a user's team membership.
2021-06-03 18:53:43 -07:00
Zach Wasserman
a5bd03e5d7 Merge branch 'master' into teams 2021-05-31 10:56:50 -07:00
Zach Wasserman
64f2cfc9cd
Refactor enroll secrets to support Teams (#903)
- Add `team_id` field to secrets.
- Remove secret `name` and `active` fields (migration deletes inactive secrets).
- Assign hosts to Team based on secret provided.
- Add API for retrieving secrets by Team.
2021-05-31 09:02:05 -07:00
Zach Wasserman
8ee47f8b23
Add support for Teams in targets and live queries (#880)
- Accept Teams as a searchable target type for the target selection API.
- Accept Teams for targets in running live queries.
- Refactoring to support these changes.
- Update API documentation.
2021-05-27 13:18:00 -07:00
Zach Wasserman
48c413a254
Split host additional into separate table (#875)
- Move host `additional` into a separate table.
- Join when that data is needed.
- API change: `/api/v1/fleet/hosts` now returns only the requested
  `additional` columns, unless `*` is provided as the sole argument.

Background:

A customer reported that MySQL binlogs grew huge and replication lag
went way up when data was stored in the `additional` column. In this
deployment MySQL was running with ROW replication. This would cause the
entire `additional` data to be copied on each update of the host checkin
time. While switching to STATEMENT or MIXED replication would likely
mitigate the issue, this was not an option in their environment.
2021-05-26 16:24:12 -07:00
Zach Wasserman
0e9eb920d4
Refactor struct slices for consistent pointer use (#864)
Some datastore and service methods would return slices of structs,
rather than slices to pointers of structs (which most methods used).
Make this more consistent.
2021-05-25 18:53:22 -07:00
Zach Wasserman
76f8d59290
Refactor usage of null values in Teams models (#863)
- Use pointers rather than null package types.
- Use new internal ptr package.
- Improved handling of changing user teams/roles.
2021-05-25 15:46:46 -07:00
Zach Wasserman
fef1ce579e
Fix host count for list teams (#861)
- Add test
2021-05-25 15:30:01 -07:00
Zach Wasserman
15b81824f5
Filter query page API responses based on team membership (#850)
- Include only hosts that the user has access to in search targets API.
- Add parameter to specify whether `observer` hosts should be included.
- Generate counts based on which hosts user can access.
- Update API doc.
2021-05-24 21:34:08 -07:00
Noah Talerman
72882e8f9f Merge branch 'master' into teams 2021-05-19 13:16:54 -04:00
Zach Wasserman
ea0c6c8e3f
Include team name in host API responses (#781)
Update model and datastore methods to retrieve team name.
2021-05-17 17:52:59 -07:00
Zach Wasserman
85d9d00096
Add "observer can run" to query objects (#777)
- Database migration.
- Update model and datastore methods.
2021-05-17 12:23:56 -07:00
Zach Wasserman
79138d4b60
Move and refactor host team transfer endpoint (#778)
- Move API endpoint to `/hosts/transfer`.
- Refactor service and datastore methods from teams to hosts.
2021-05-17 12:23:21 -07:00
WangXiang
468754f2b9
Format and clean code (#774)
1. use [staticcheck](https://staticcheck.io/) to check the code, and fix some issues.
2. use `go fmt` to format the code.
3. use `go mod tidy` clean the go mod.
2021-05-17 10:29:50 -07:00
Zach Wasserman
027b12e6c4
Fix foreign key cascade for query stats table (#776)
Introduces the appropriate cascading for foreign keys on the
scheduled_query_stats table to prevent errors when deleting the
associated packs, scheduled queries, and queries.

Fixes #764
Fixes #766
2021-05-17 10:26:01 -07:00
Zach Wasserman
daa8eeb9d0
Add refetch host API (#767)
This allows the host details to be refetched on the next check in,
rather than waiting for the normal interval to go by. Associated UI
changes are in-progress.

- Migration and service methods for requesting refetch.
- Expose refetch over API.
- Change detail query logic to respect this flag.
2021-05-13 13:09:22 -07:00
Zach Wasserman
1a29a408ce
Add support for bulk transfer of hosts for team (#761)
- Relevant datastore method.
- Expose via API endpoint /teams/:id/hosts.
2021-05-12 19:05:45 -07:00
Zach Wasserman
b1a98a6e91
Update agent options storage for teams (#754)
- Allow agent options to be set on per-team basis.
- Move global agent options into app configs.
- Update logic for calculating agent options for hosts.
- Updates to relevant testing.
2021-05-11 18:15:16 -07:00
Zach Wasserman
56a9e2cf20
Add description to returned query stats (#742)
Gets the description from the associated query.
2021-05-07 12:47:52 -07:00
Zach Wasserman
f788254e61
Implement storage of scheduled query statistics (#735)
Track all data from the osquery_schedule table on a per-host basis. This
data is now returned when retrieving host details in the API.
2021-05-06 21:05:09 -07:00
Zach Wasserman
b2b53ecbbe
Add agent options on a per-team basis (#696)
Solely API implementation. Does not yet handle returning the options
during agent requests.
2021-05-03 09:32:04 -07:00
Zach Wasserman
a17556b2db Merge branch 'master' into teams 2021-04-30 09:40:10 -07:00