Commit Graph

1141 Commits

Author SHA1 Message Date
Jahziel Villasana-Espinoza
8b2e94ed95
fix: add "w" prefix to Windows OS update profile UUIDs (#16437)
> Related issue: #16411

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [x] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [x] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [x] Manual QA for all new/changed functionality
2024-01-30 12:05:43 -05:00
Tim Lee
ae87519938
16356 Unreleased bugfix for osversions filter (#16391) 2024-01-29 13:04:26 -07:00
Martin Angers
ca435eb244
Queued scripts feature (#16300)
This is the feature branch for the [queued
scripts](https://github.com/fleetdm/fleet/issues/15529) story.

---------

Co-authored-by: Jahziel Villasana-Espinoza <jahziel@fleetdm.com>
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com>
Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
2024-01-29 11:37:54 -03:00
Roberto Dip
7d00d5a41e
feature: target profiles by labels (#16202)
for #14715

---------

Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com>
Co-authored-by: Jahziel Villasana-Espinoza <jahziel@fleetdm.com>
2024-01-26 11:00:58 -05:00
Tim Lee
79b5baa297
4345 OS Vulnerabilities Backend (#16303)
#4345 

This backend feature branch includes the following PRs:

macOS Vuln Matching:
#15837 
#15990 
#16077 

Bugs / Issues:
#16004
 #15905 
#16226 

Windows Vuln Matching
#16047 
#16049 
#16085 
#16099 

API:
#16215
2024-01-24 12:18:57 -07:00
Victor Lyuboslavsky
a5482f6e6a
Team host expiry. (#16188)
Teams can configure their own host expiry setting. If global host expiry
is enabled, teams cannot disable host expiry, but they can set a longer
(or shorter) expiry time (in days).
- Added `host_expiry_settings` to team spec, which can be used via
fleetctl apply.
- Added `host_expiry_settings` to PATH /fleet/teams/:id endpoint.


#15609 (parent)
#15966 (subtask)

TODO: Create PR for API docs change: added parameter to `PATCH
/fleet/teams/:id` endpoint

# Checklist for submitter

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-01-22 10:00:02 -06:00
Roberto Dip
4d90b8ee6b
filter for hosts_count > 0 in software title query (#16225)
for #15964, pair programmed with @jacobshandling 
---------

Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2024-01-19 15:42:42 -03:00
Victor Lyuboslavsky
ebbf393bd7
On My device and Host details pages, failing policies are now listed first. (#16102)
On My device, Host details pages, and `GET /api/v1/fleet/hosts/:id` API
endpoint, failing policies are now listed first.
#10379 

REST API change to be documented in a separate PR.

# Checklist for submitter

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-01-16 10:19:16 -06:00
Martin Angers
fc3304c902
Move nanomdm dependency in monorepo (#16015)
#15557 

Following the precedent that Lucas used for other similar PRs, the best
way to review is probably by commits.

* The first one simply copies over the files from the fork to the
monorepo
* Second one adjusts all import paths
* Third one tidies up the `go.mod` files
* Last one fixes the linter issues in the nanomdm package

# Checklist for submitter

- ~~Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.~~ (not a user-visible change)
- [x] Manual QA for all new/changed functionality (ran test suite,
re-generated mocks)

I also verified that our Go test suite did run the newly moved `nanomdm`
package steps:

```
ok  	github.com/fleetdm/fleet/v4/server/mdm/nanomdm/cryptoutil	0.003s	coverage: 0.0% of statements in github.com/fleetdm/fleet/v4/...
ok  	github.com/fleetdm/fleet/v4/server/mdm/nanomdm/mdm	0.005s	coverage: 46.2% of statements in github.com/fleetdm/fleet/v4/...
ok  	github.com/fleetdm/fleet/v4/server/mdm/nanomdm/service/certauth	1.320s	coverage: 20.7% of statements in github.com/fleetdm/fleet/v4/...
ok  	github.com/fleetdm/fleet/v4/server/mdm/nanomdm/storage/file	0.007s	coverage: 24.1% of statements in github.com/fleetdm/fleet/v4/...
```
2024-01-11 23:28:48 -03:00
Victor Lyuboslavsky
abc56d988a
Improve UX for globally enabling/disabling SSO (#15887)
#15236 

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Manual QA for all new/changed functionality
2024-01-10 08:26:55 -06:00
Sarah Gillespie
4be9ca3f73
Fix database migration to preserve updated at timestamp for MDM profiles (#15993) 2024-01-09 14:10:20 -06:00
Sarah Gillespie
fa14eaf63a
Update categorization of Windows OS updates to exclude from user-defined Windows MDM profiles in API responses (#15924) 2024-01-05 09:28:54 -06:00
Tim Lee
d690867a6a
Cleanup Query Results Cron (#15917) 2024-01-05 06:05:01 -07:00
Roberto Dip
18d830a126
allow to verify profiles that are pending (#15911)
for #15678
2024-01-04 18:26:04 -03:00
Roberto Dip
f3d400d48e
automatically install fleetd for hosts that turn MDM manually (#15883)
for #15057
2024-01-03 15:16:59 -03:00
Jahziel Villasana-Espinoza
2833c80cfe
feat: add option to disable scripts (#15815)
> 📜 Related issue: https://github.com/fleetdm/fleet/issues/14500

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-01-03 10:42:08 -05:00
Victor Lyuboslavsky
912abd211d
Added a new synchronous live query endpoint: POST /api/v1/fleet/queries/:id/run (#15860)
Added a new synchronous live query endpoint: POST
/api/v1/fleet/queries/:id/run
#14800 

All relevant integration tests have been updated to work with the old
endpoint and new endpoint.

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-01-03 09:39:16 -06:00
Lucas Manuel Rodriguez
417f45fc61
Move external dependency fleetdm/kolide-kit to monorepo (#15861)
#15556

We will need to pay attention when releasing fleet (the github actions
were modified to use the local file now).

Should be reviewed by commits (first commit is the actual adding of the
`version.go` file)

- [X] Manual QA for all new/changed functionality

Manually tested the following:
- `Settings -> My account` on the UI and checked the `/version` endpoint
response. (Or also visiting https://localhost:8080/version on a
browser).
- Ran `make fleetctl fleet`, `./build/fleetctl --version` and
`./build/fleet version`.
2024-01-02 18:22:52 -03:00
Lucas Manuel Rodriguez
38b8c9cc58
Move external dependency goose to monorepo (#15859)
#15555

Probably the best way to review this is commit by commit:
- First commit does the actual moving.
- Second commit fixes golangci-lint issues (in the least effort way to
avoid refactoring or rearrangement of some of the code).
- Third commit moves a printf to before the migration step is executed.
In the past some customers hitting migration issues (like migration
steps hanging or taking long to execute) and wanted to know which one
was it. The only way to know was to look at the repository and looking
for the next migration after the last one logged.

Checks:
- [X] Manual QA for all new/changed functionality

Manual tests:
- `make fleet && make db-reset`.
- Adding a new migration via `make migration name=Foobar` and then
running `./build/fleet prepare db`.
- Enrolling a new device to Fleet (smoke test).
2024-01-02 17:52:00 -03:00
Jahziel Villasana-Espinoza
1b9b67aa9c
fix: query host search by email (#15833)
> 📜 Related issue: https://github.com/fleetdm/fleet/issues/15522

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-01-02 09:25:09 -05:00
Victor Lyuboslavsky
1704eb4014
Fixed missing 'Last restarted' values when filtering hosts by label. (#15852)
Fixed missing 'Last restarted' values when filtering hosts by label.
#15822

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-29 08:36:15 -06:00
Victor Lyuboslavsky
ebf1650671
device_token endpoint improvements (#15849)
Fixed badly formatted error messages in /api/fleet/orbit/device_token
endpoint and others.
In /api/fleet/orbit/device_token:
- Added token validation -- empty token not allowed
- Replaced 500 error with 409 when token conflicts with another host

#15832 

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA
2023-12-28 14:20:36 -06:00
Victor Lyuboslavsky
6725da2ad0
Added host_count_updated_at to policy API responses. (#15767)
Added `host_count_updated_at` to policy API responses.
#15323 

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-27 15:24:27 -06:00
Victor Lyuboslavsky
289eb271a6
Fixing TestQueries/Delete flaky tests. (#15838)
When deleting queries, associated query stats and aggregated stats are
deleted with separate SQL statements. When testing, we need to wait in a
for loop for both of these to be deleted before continuing with the
test.
2023-12-27 15:22:18 -06:00
Victor Lyuboslavsky
ce8eb74897
Added gigs_total_disk_space to host endpoint responses. (#15756)
Added `gigs_total_disk_space` to host endpoint responses.
- Now user will know host disk size even when disk is full
(percent_disk_space_available==0)
#15058 

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-22 12:46:33 -06:00
Jahziel Villasana-Espinoza
b348399f7e
fix: email searching when filtering by labels (#15774)
# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-21 15:42:44 -05:00
Victor Lyuboslavsky
72621e31ce
Added gigs_total_disk_space to host_disks. (#15753)
Added gigs_total_disk_space to host_disks.

This is just the migration that is needed for the rest of the changes in
#15058
2023-12-21 12:13:04 -06:00
Jahziel Villasana-Espinoza
367459fe02
fix: use other field for checking vuln scanning status (#15720)
# Checklist for submitter

To test, go through the repro steps in the issue; you should see that
the field is true instead of false!

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-21 12:38:21 -05:00
Sarah Gillespie
682ab4aa7e
Add host display name to list hosts query (#15781) 2023-12-21 11:26:08 -06:00
Martin Angers
2e8da551d0
Custom email device-mapping: implement the CLI (fleetd + fleetctl) changes (#15763)
Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com>
2023-12-21 11:22:59 -06:00
Martin Angers
235d2cf2dc
Custom email device-mapping: implement the REST API changes (#15748) 2023-12-21 11:21:39 -06:00
Victor Lyuboslavsky
44c748fded
Removing time.Sleep from TestQueries. (#15764)
Fixing flaky TestQueries tests by removing time.Sleep
2023-12-20 10:01:33 -06:00
Victor Lyuboslavsky
0e51a26bf9
Fixing TestQueries/Save test. (#15729)
Fixing TestQueries/Save test.
2023-12-18 17:00:52 -06:00
Sarah Gillespie
108fadaa2d
Expand ORDER BY in list software titles (#15721) 2023-12-18 14:08:53 -06:00
Tim Lee
8f55f20250
15696 Add Policy stats data migration (#15697) 2023-12-18 10:49:53 -07:00
Victor Lyuboslavsky
b930f66229
Live query stats are cleared when query SQL is modified. (#15710)
Live query stats are cleared when query SQL is modified.

Also, when deleting one or more queries, the associated aggregated stats
are now deleted as well.

#15709

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-18 08:45:19 -06:00
Victor Lyuboslavsky
0e040cc7b0
fleetctl now runs saved queries (#15667)
📺 Looom:
https://www.loom.com/share/1aec4616fa4449e7abac579084aef0ba?sid=0884f742-feb3-48bb-82dc-b7834bc9a6e1

Fixed fleetctl issue where it was creating a new query when running a
query by name, as opposed to using the existing saved query.
#15630

API change will be in a separate PR:
https://github.com/fleetdm/fleet/pull/15673

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-15 12:55:39 -06:00
Lucas Manuel Rodriguez
024a20ac11
Allow enrolling fleetd using osquery's instance identifier (#15570)
#14879

- [X] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
  - For Orbit and Fleet Desktop changes:
- [x] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [x] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
2023-12-15 15:26:32 -03:00
Victor Lyuboslavsky
bac932bd19
Documentation for max_prepared_stmt_count requirements and update-interval. (#15495)
Documentation changes for #15476
2023-12-14 17:38:47 -06:00
Tim Lee
ced538c916
15597 Observer list query filter (#15653) 2023-12-14 13:25:42 -07:00
Tim Lee
27073720c5
15254 oval scan err (#15499) 2023-12-14 10:39:28 -07:00
Victor Lyuboslavsky
835eedae42
Performance stats for live queries (#15440)
📺 Loom explaining the PR:
https://www.loom.com/share/8c6ec0c362014910931f183d68307525?sid=7de51e6f-a59d-4d8f-b06b-f703f1692f17

#467 
Live Queries now collect stats. Stats are collected for saved queries
present in the Queries tab.
- After running a live query, user will see updated stats in Queries
tab.
- Query stats on Host Details page will no longer be cleared after
host/agent reboots.
- Query stats are now deleted when query is deleted.

# Checklist for submitter
- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-13 14:46:59 -06:00
Roberto Dip
fbaa479d01
pre-calculate host counts for software titles (#15601)
found during the load test, this addresses a performance issue with
software titles.

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-13 12:48:57 -03:00
Martin Angers
dd123eacde
Update migration to avoid running DML on table without a PK (#15620) 2023-12-13 10:27:40 -05:00
Martin Angers
3e4f36a20e
Add checksum hash unique column to software table. (#15598) 2023-12-12 17:51:58 -05:00
Jacob Shandling
0967256cce
Per Host Query Reports (#15591)
## Addresses #14415 
<img width="1281" alt="image"
src="https://github.com/fleetdm/fleet/assets/61553566/568f367b-abaa-4c27-b68d-763af9c6a104">
<img width="1277" alt="image"
src="https://github.com/fleetdm/fleet/assets/61553566/07043268-d68a-46c7-94cf-47adb2b86ae3">

- [X] Changes file added for user-visible changes in `changes/` 
- [X] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [X] Added/updated tests
- [X] Manual QA for all new/changed functionality

co-authored by @mostlikelee and @jacobshandling
2023-12-12 14:32:41 -08:00
Sarah Gillespie
6b4f85fd92
Add browser type to software titles UI and API (#15604) 2023-12-12 16:21:44 -06:00
Jacob Shandling
3a482f56b7 Merge branch 'main' into 14415 2023-12-12 10:37:41 -08:00
Roberto Dip
2ed3026819
Add pagination meta to software versions endpoint (#15550) 2023-12-12 12:24:20 -06:00
Tim Lee
f1acd30bcf
15380 extend hosts api (#15421) 2023-12-12 08:40:57 -07:00
Tim Lee
33999cddae
15381 host query report api (#15441) 2023-12-11 15:33:31 -07:00
Jacob Shandling
d2359675d4 Merge branch 'main' into 14415 2023-12-11 13:52:45 -08:00
Victor Lyuboslavsky
9236a19342
Changed query performance statistics to uint64 to match osquery reports. (#15505)
#15472

# Checklist for submitter
- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-11 11:29:17 -06:00
Sarah Gillespie
0e468b4981
Update software titles cron to include browser field (#15491) 2023-12-07 17:43:37 -06:00
Tim Lee
3ba81e1cf6
15146 filter query results (#15473) 2023-12-07 11:24:56 -08:00
Sarah Gillespie
88e8eee1fe
Add backend capability to look up hosts based on MDM IdP email (#15478)
Issue #13034 

TODO: Frontend requirements will be covered in a separate PR.

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
- [x] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-07 12:36:32 -06:00
Lucas Manuel Rodriguez
608038a1bb
Fix deadlock when deleting software during data ingestion (#15459)
This fixes the deadlock reported in #14779.

We found a deadlock in software ingestion during load tests performed in
October:
```
2023-10-26T17:20:41.719627Z 0 [Note] [MY-012468] [InnoDB] Transactions deadlock detected, dumping detailed information. (lock0lock.cc:6482)
2023-10-26T17:20:41.719661Z 0 [Note] [MY-012469] [InnoDB]  *** (1) TRANSACTION:  (lock0lock.cc:6496)
TRANSACTION 3069866646, ACTIVE 0 sec starting index read
mysql tables in use 2, locked 2
LOCK WAIT 8 lock struct(s), heap size 1136, 18 row lock(s), undo log entries 10
MySQL thread id 95, OS thread handle 70431326097136, query id 340045 10.12.3.105 fleet executing
DELETE FROM software WHERE id IN (165, 79, 344, 47, 212, 21, 60, 127, 173, 145) AND
        NOT EXISTS (
                SELECT 1 FROM host_software hsw WHERE hsw.software_id = software.id
        )
2023-10-26T17:20:41.719700Z 0 [Note] [MY-012469] [InnoDB]  *** (1) HOLDS THE LOCK(S):  (lock0lock.cc:6496)
RECORD LOCKS space id 932 page no 8 n bits 256 index PRIMARY of table `fleet`.`software` trx id 3069866646 lock_mode X locks rec but not gap
Record lock, heap no 22 PHYSICAL RECORD: n_fields 11; compact format; info bits 0
 0: len 8; hex 0000000000000015; asc         ;;
 1: len 6; hex 0000a74c4a7c; asc    LJ|;;
 2: len 7; hex 82000000d00264; asc       d;;
 3: len 26; hex 616e74692d76697275735f666f725f736f70686f735f686f6d65; asc anti-virus_for_sophos_home;;
 4: len 5; hex 322e322e36; asc 2.2.6;;
 5: len 4; hex 61707073; asc apps;;
 6: len 0; hex ; asc ;;
 7: len 0; hex ; asc ;;
 8: len 0; hex ; asc ;;
 9: len 0; hex ; asc ;;
 10: len 0; hex ; asc ;;

Record lock, heap no 48 PHYSICAL RECORD: n_fields 11; compact format; info bits 0
 0: len 8; hex 000000000000002f; asc        /;;
 1: len 6; hex 0000a74c4aad; asc    LJ ;;
 2: len 7; hex 81000000e30220; asc        ;;
 3: len 10; hex 7265616c706c61796572; asc realplayer;;
 4: len 11; hex 31322e302e312e31373338; asc 12.0.1.1738;;
 5: len 4; hex 61707073; asc apps;;
6: len 0; hex ; asc ;;
 7: len 0; hex ; asc ;;
 8: len 0; hex ; asc ;;
 9: len 0; hex ; asc ;;
 10: len 0; hex ; asc ;;

Record lock, heap no 61 PHYSICAL RECORD: n_fields 11; compact format; info bits 0
 0: len 8; hex 000000000000003c; asc        <;;
 1: len 6; hex 0000a74c4afb; asc    LJ ;;
 2: len 7; hex 820000017501ba; asc     u  ;;
 3: len 7; hex 636f6e6e656374; asc connect;;
 4: len 5; hex 332e322e37; asc 3.2.7;;
 5: len 4; hex 61707073; asc apps;;
 6: len 0; hex ; asc ;;
 7: len 0; hex ; asc ;;
 8: len 0; hex ; asc ;;
 9: len 0; hex ; asc ;;
 10: len 0; hex ; asc ;;

Record lock, heap no 80 PHYSICAL RECORD: n_fields 11; compact format; info bits 0
 0: len 8; hex 000000000000004f; asc        O;;
 1: len 6; hex 0000a74c4b32; asc    LK2;;
 2: len 7; hex 820000008a01cb; asc        ;;
 3: len 7; hex 68697063686174; asc hipchat;;
 4: len 4; hex 342e3330; asc 4.30;;
 5: len 4; hex 61707073; asc apps;;
 6: len 0; hex ; asc ;;
 7: len 0; hex ; asc ;;
 8: len 0; hex ; asc ;;
 9: len 0; hex ; asc ;;
 10: len 0; hex ; asc ;;

2023-10-26T17:20:41.720564Z 0 [Note] [MY-012469] [InnoDB]  *** (1) WAITING FOR THIS LOCK TO BE GRANTED:  (lock0lock.cc:6496)
RECORD LOCKS space id 695 page no 5994 n bits 1000 index host_software_software_id_fk of table `fleet`.`host_software` trx id 3069866646 lock mode S waiting
Record lock, heap no 31 PHYSICAL RECORD: n_fields 2; compact format; info bits 32
 0: len 8; hex 000000000000004f; asc        O;;
 1: len 4; hex 0000000c; asc     ;;

2023-10-26T17:20:41.720650Z 0 [Note] [MY-012469] [InnoDB]  *** (2) TRANSACTION:  (lock0lock.cc:6496)
TRANSACTION 3069866680, ACTIVE 0 sec starting index read
mysql tables in use 2, locked 2
LOCK WAIT 7 lock struct(s), heap size 1136, 12 row lock(s), undo log entries 8
MySQL thread id 98, OS thread handle 70375801900784, query id 340524 10.12.3.9 fleet executing
DELETE FROM software WHERE id IN (49, 113, 183, 187, 223, 79, 81, 116) AND
        NOT EXISTS (
                SELECT 1 FROM host_software hsw WHERE hsw.software_id = software.id
        )
2023-10-26T17:20:41.720682Z 0 [Note] [MY-012469] [InnoDB]  *** (2) HOLDS THE LOCK(S):  (lock0lock.cc:6496)
RECORD LOCKS space id 695 page no 5994 n bits 1000 index host_software_software_id_fk of table `fleet`.`host_software` trx id 3069866680 lock_mode X locks rec but not gap
Record lock, heap no 31 PHYSICAL RECORD: n_fields 2; compact format; info bits 32
 0: len 8; hex 000000000000004f; asc        O;;
 1: len 4; hex 0000000c; asc     ;;

2023-10-26T17:20:41.720760Z 0 [Note] [MY-012469] [InnoDB]  *** (2) WAITING FOR THIS LOCK TO BE GRANTED:  (lock0lock.cc:6496)
RECORD LOCKS space id 932 page no 8 n bits 256 index PRIMARY of table `fleet`.`software` trx id 3069866680 lock_mode X locks rec but not gap waiting
Record lock, heap no 80 PHYSICAL RECORD: n_fields 11; compact format; info bits 0
 0: len 8; hex 000000000000004f; asc        O;;
 1: len 6; hex 0000a74c4b32; asc    LK2;;
 2: len 7; hex 820000008a01cb; asc        ;;
 3: len 7; hex 68697063686174; asc hipchat;;
 4: len 4; hex 342e3330; asc 4.30;;
 5: len 4; hex 61707073; asc apps;;
 6: len 0; hex ; asc ;;
 7: len 0; hex ; asc ;;
 8: len 0; hex ; asc ;;
 9: len 0; hex ; asc ;;
 10: len 0; hex ; asc ;;

2023-10-26T17:20:41.720984Z 0 [Note] [MY-012469] [InnoDB] *** WE ROLL BACK TRANSACTION (2)  (lock0lock.cc:6496)
```

I was able to reproduce this issue on `main` with the added test. The
solution is to remove the deletion (cleanup) of `software` to a separate
transaction after the main transaction is done.

- [X] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [X] Added/updated tests
- [X] Manual QA for all new/changed functionality
2023-12-07 09:34:53 -03:00
Martin Angers
6b128dd455
Allow filtering hosts by software_version_id and software_title_id. (#15433) 2023-12-06 14:59:00 -05:00
Jahziel Villasana-Espinoza
5fd799ff2e
feat: device health endpoint (#15432)
> #14920 

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Documented any permissions changes (docs/Using
Fleet/manage-access.md)
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-12-06 14:42:29 -05:00
Martin Angers
fb01e30f27
Require a custom Clone for cacheable items, add tooling and CI check to help catch issues (#15458) 2023-12-06 14:34:22 -05:00
Roberto Dip
aada28c1c1
Add list/detail endpoints for software titles (#15464)
related to #15228
2023-12-06 15:28:31 -03:00
Sarah Gillespie
f19dc8abe0
Add GET software/versions and GET software/versions/:id endpoints (#15450) 2023-12-06 08:30:49 -06:00
Jacob Shandling
6c25646499 Merge branch 'main' into 14415 2023-12-05 13:59:02 -08:00
Lucas Manuel Rodriguez
33ceb0ab9f
Update edge case bug in ds.UpdateHostDeviceMapping (#15454)
Found by @mna while working on #14779.

Sort of an edge case but the change is simple enough to fix it.
2023-12-05 18:25:11 -03:00
Lucas Manuel Rodriguez
57351011fa
Fix deadlock when replacing (upserting) host_batteries (#15447)
#14779

This PR fixes the deadlock when upserting to `host_batteries`.
Which probably happens because InnoDB uses row-locking.

I was able to reproduce in main with the new test
`TestHosts/ReplaceHostBatteriesDeadlock`.
I refactored `ds.ReplaceHostBatteries` to use the same upsert pattern as
`ds.ReplaceHostDeviceMapping` (given `battery` is assumed to return just
a few rows per host). With such pattern the tests does not fail with
deadlock errors anymore.

Here are some of the techniques MySQL recommends:
https://dev.mysql.com/doc/refman/5.7/en/innodb-deadlocks-handling.html
Basically by changing the upsert pattern the deadlock goes away (It's
hard to know exactly why the original code deadlocks).

Here's the deadlock trace from load test performed in October:
```
2023-10-26T17:19:17.244707Z 0 [Note] [MY-012468] [InnoDB] Transactions deadlock detected, dumping detailed information. (lock0lock.cc:6482)
2023-10-26T17:19:17.244756Z 0 [Note] [MY-012469] [InnoDB]  *** (1) TRANSACTION:  (lock0lock.cc:6496)
TRANSACTION 3069771944, ACTIVE 0 sec inserting
mysql tables in use 1, locked 1
LOCK WAIT 7 lock struct(s), heap size 1136, 5 row lock(s), undo log entries 1
MySQL thread id 75, OS thread handle 70369297350384, query id 658 10.12.3.201 fleet update
INSERT INTO
      host_batteries (
        host_id,
        serial_number,
        cycle_count,
        health
      )
    VALUES
      (27472, '0000', 505, 'Good'),(27472, '0001', 730, 'Good')
    ON DUPLICATE KEY UPDATE
      cycle_count = VALUES(cycle_count),
      health = VALUES(health),
      updated_at = CURRENT_TIMESTAMP
2023-10-26T17:19:17.244800Z 0 [Note] [MY-012469] [InnoDB]  *** (1) HOLDS THE LOCK(S):  (lock0lock.cc:6496)
RECORD LOCKS space id 867 page no 320 n bits 280 index PRIMARY of table `fleet`.`host_batteries` trx id 3069771944 lock_mode X locks gap before rec
Record lock, heap no 205 PHYSICAL RECORD: n_fields 9; compact format; info bits 0
 0: len 4; hex 00526996; asc  Ri ;;
 1: len 6; hex 0000b6f900d0; asc       ;;
 2: len 7; hex 82000033370110; asc    37  ;;
 3: len 4; hex 0000d829; asc    );;
 4: len 4; hex 30303030; asc 0000;;
 5: len 4; hex 8000065b; asc    [;;
 6: len 4; hex 506f6f72; asc Poor;;
 7: len 4; hex 653a9f95; asc e:  ;;
 8: len 4; hex 653a9f95; asc e:  ;;

2023-10-26T17:19:17.245027Z 0 [Note] [MY-012469] [InnoDB]  *** (1) WAITING FOR THIS LOCK TO BE GRANTED:  (lock0lock.cc:6496)
RECORD LOCKS space id 867 page no 320 n bits 280 index PRIMARY of table `fleet`.`host_batteries` trx id 3069771944 lock_mode X locks gap before rec insert intention waiting
Record lock, heap no 205 PHYSICAL RECORD: n_fields 9; compact format; info bits 0
 0: len 4; hex 00526996; asc  Ri ;;
 1: len 6; hex 0000b6f900d0; asc       ;;
 2: len 7; hex 82000033370110; asc    37  ;;
 3: len 4; hex 0000d829; asc    );;
 4: len 4; hex 30303030; asc 0000;;
 5: len 4; hex 8000065b; asc    [;;
 6: len 4; hex 506f6f72; asc Poor;;
 7: len 4; hex 653a9f95; asc e:  ;;

2023-10-26T17:19:17.245239Z 0 [Note] [MY-012469] [InnoDB]  *** (2) TRANSACTION:  (lock0lock.cc:6496)
TRANSACTION 3069771958, ACTIVE 0 sec inserting
mysql tables in use 1, locked 1
LOCK WAIT 7 lock struct(s), heap size 1136, 5 row lock(s), undo log entries 1
MySQL thread id 9, OS thread handle 70369296809712, query id 708 10.12.2.156 fleet update
INSERT INTO
      host_batteries (
        host_id,
        serial_number,
        cycle_count,
        health
      )
    VALUES
      (59161, '0000', 1384, 'Fair'),(59161, '0001', 396, 'Good')
    ON DUPLICATE KEY UPDATE
      cycle_count = VALUES(cycle_count),
      health = VALUES(health),
      updated_at = CURRENT_TIMESTAMP
2023-10-26T17:19:17.245272Z 0 [Note] [MY-012469] [InnoDB]  *** (2) HOLDS THE LOCK(S):  (lock0lock.cc:6496)
RECORD LOCKS space id 867 page no 320 n bits 280 index PRIMARY of table `fleet`.`host_batteries` trx id 3069771958 lock_mode X locks gap before rec
Record lock, heap no 205 PHYSICAL RECORD: n_fields 9; compact format; info bits 0
 0: len 4; hex 00526996; asc  Ri ;;
 1: len 6; hex 0000b6f900d0; asc       ;;
 2: len 7; hex 82000033370110; asc    37  ;;
 3: len 4; hex 0000d829; asc    );;
 4: len 4; hex 30303030; asc 0000;;
 5: len 4; hex 8000065b; asc    [;;
 6: len 4; hex 506f6f72; asc Poor;;
 7: len 4; hex 653a9f95; asc e:  ;;
 8: len 4; hex 653a9f95; asc e:  ;;

2023-10-26T17:19:17.245504Z 0 [Note] [MY-012469] [InnoDB]  *** (2) WAITING FOR THIS LOCK TO BE GRANTED:  (lock0lock.cc:6496)
RECORD LOCKS space id 867 page no 320 n bits 280 index PRIMARY of table `fleet`.`host_batteries` trx id 3069771958 lock_mode X locks gap before rec insert intention waiting
Record lock, heap no 205 PHYSICAL RECORD: n_fields 9; compact format; info bits 0
 0: len 4; hex 00526996; asc  Ri ;;
 1: len 6; hex 0000b6f900d0; asc       ;;
 2: len 7; hex 82000033370110; asc    37  ;;
 3: len 4; hex 0000d829; asc    );;
 4: len 4; hex 30303030; asc 0000;;
 5: len 4; hex 8000065b; asc    [;;
 6: len 4; hex 506f6f72; asc Poor;;
 7: len 4; hex 653a9f95; asc e:  ;;
 8: len 4; hex 653a9f95; asc e:  ;;

2023-10-26T17:19:17.245730Z 0 [Note] [MY-012469] [InnoDB] *** WE ROLL BACK TRANSACTION (2)  (lock0lock.cc:6496)
```

- [X] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [X] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [X] Added/updated tests
- [X] Manual QA for all new/changed functionality
2023-12-05 18:24:58 -03:00
mostlikelee
5677d734de Merge branch 'main' into 14415 2023-12-04 14:38:28 -07:00
Lucas Manuel Rodriguez
9b40573f54
Fix installed_from_dep value in activity for DEP re-enrolling (#15419)
#12037 

![Screenshot 2023-12-04 at 17 03
03](https://github.com/fleetdm/fleet/assets/2073526/e44cee72-1f1a-4a10-be80-26f0e06c8c91)

- [X] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [X] Added/updated tests
- [X] Manual QA for all new/changed functionality
2023-12-04 17:14:16 -03:00
Sarah Gillespie
0db59a7a25
Add cron for software titles feature (#15422) 2023-12-04 10:09:23 -06:00
Tim Lee
dc3fc5e6f5
15378 record empty data results (#15403) 2023-12-04 08:31:35 -07:00
Martin Angers
f5f66ebe63
Unify profiles database identifier to profile_uuid for macOS and Windows profiles. (#15297) 2023-12-04 10:04:06 -05:00
Sarah Gillespie
b660715e56
Add database migrations to support software titles feature (#15401)
Issue #15222
2023-12-01 11:33:07 -03:00
Victor Lyuboslavsky
a7ae828581
Adding extension_id and browser columns to software table. (#15285)
https://github.com/fleetdm/confidential/issues/2118
API doc changes are at: https://github.com/fleetdm/fleet/pull/15092

This change affects Chrome-based and Firefox browsers. I tried Safari,
but it appears that latest Safari extensions simply show up as regular
apps on macOS.

# Checklist for submitter
- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
  - Tested detail query changes on macOS, Windows, Ubuntu, and ChromeOS
  - Tested Chrome, Edge, Brave, and Firefox browsers

Testing notes:
1. Install some browser extensions.
2. Update fleet to this change.
3. Refresh hosts, and trigger vulnerabilities job (which updates host
software).
4. Do something like `GET
https://localhost:8080/api/v1/fleet/software?query=Password%20Manager`
to see `extension_id` and `browser` for the hosts that have updated.
2023-11-30 19:06:17 -06:00
Sarah Gillespie
976eeba61d
Add validations to disallow custom MDM profiles that contain names reserved by Fleet (#15373) 2023-11-30 17:19:18 -06:00
Roberto Dip
b07fbdc1d7
implement profile verification for windows (#15348)
for #14426.

In order to prevent import cycles and be able to use some type
definitions/constants I followed the same pattern we did for macOS by
creating a new package named `syncml`. This makes the changelog look
bigger than it actually is, so I split it into two commits to make it
easier to review:

-
[d7c233d](d7c233d54c)
moves the relevant bits to this new package
-
[7531a07](7531a0742b)
implements profile verification
2023-11-30 09:17:07 -03:00
Martin Angers
2f927df4f0
Implement Windows OS Updates (feature branch). (#15359) 2023-11-29 11:07:24 -05:00
Martin Angers
0b5eedb801
Fix edge case of AppConfig changes getting lost in cached mysql. (#15352) 2023-11-29 10:09:37 -05:00
Sarah Gillespie
1535b72305
Add hardware serial to host by identifier search (#15353) 2023-11-29 08:39:35 -06:00
Roberto Dip
f439432fae
feature: windows profiles (#15349) 2023-11-29 09:32:42 -05:00
Tim Lee
198b522132
Purge policy stats in cleanup (#15318) 2023-11-28 10:03:03 -07:00
Roberto Dip
4d56d25f11
show FV banner if the disk is encrypted but we don't get a key (#15317)
for #15068

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-11-27 18:23:01 -03:00
Tim Lee
b2568ad475
HotFix - ambiguous policy search name (#15312) 2023-11-27 12:21:39 -07:00
Roberto Dip
9c7b740b03
disable windows profiles feature in the back-end (#15278)
per discussion in slack, reverting relevant user-facing changes for
#13281
2023-11-27 16:08:52 -03:00
Victor Lyuboslavsky
8cfe272091
filtering hosts with invalid team_id now returns 400 error. (#15266)
#15037 
For endpoint fleet/hosts, filtering hosts with invalid team_id now
returns 400 error.

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-11-22 15:04:48 -06:00
Roberto Dip
5f313c8972
fix various bugs after testing windows MDM profiles (#15264)
for #13281
2023-11-22 10:48:28 -03:00
Tim Lee
c5ea7eac4f
Cache policy counts (#15244) 2023-11-21 12:52:06 -07:00
Sarah Gillespie
57df2f250c
Add Windows MDM profiles to host details API response (#15210) 2023-11-20 14:34:57 -06:00
Martin Angers
c1fa8de992
Fix data race in mysql tests (#15204) 2023-11-20 10:20:08 -05:00
Roberto Dip
d9f0f86002
update host profile status when we get a Windows MDM response (#15172)
related to #14364, this adds logic to update the `status` and `detail`
columns of `host_mdm_windows_profiles` when we get a management
response.
2023-11-20 11:25:54 -03:00
Roberto Dip
420dfe1cd0
batch set profiles as pending on profile-related actions (#15179)
final step of #14364
2023-11-20 11:16:02 -03:00
Sarah Gillespie
3399b31bfc
Update API endpoints that support os_setttings filter to include Windows MDM profiles status (#15188) 2023-11-17 12:33:06 -06:00
Victor Lyuboslavsky
91ee14f573
Allow reverting a deleted Munki. (#15183)
When Munki is deleted and reinstalled on the host, Fleet will show Munki
info again.
#12409 

# Checklist for submitter
- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-11-17 12:21:42 -06:00
Sarah Gillespie
0850367734
Add GET /mdm/profiles/summary endpoint (#15077) 2023-11-17 10:49:30 -06:00
Victor Lyuboslavsky
36e12d02e3
Show host display name in query results. (#15173)
Query report now shows the host display name instead of hostname.
#14763 

# Checklist for submitter

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-11-16 14:26:57 -06:00
Sharon Katz
c67d9eb3a5
Hackathon add metrics from Fleet servers. (#14216)
Adding a few stats to the metrics Fleet Servers send to Heroku.
2023-11-16 10:25:19 -05:00
Jahziel Villasana-Espinoza
1fca8b1e38
fix: sort order for Last restarted (#14878)
# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Documented any API changes (docs/REST API/rest-api.md or
docs/Contributing/API-for-contributors.md)
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Rachael Shaw <r@rachael.wtf>
2023-11-15 16:42:57 -05:00
Martin Angers
cb9774fff8
Automate skipping of old database migration tests (#15166) 2023-11-15 15:53:42 -05:00
Martin Angers
4f45942f38
Add endpoint to list macOS and Windows profiles combined, paginated (#15165) 2023-11-15 15:36:20 -05:00
Roberto Dip
319b64f368
allow to set mdm.windows_settings.custom_settings in configs (#15145)
for #14361 this adds the bits related to saving a slice of strings with
paths to configuration profiles.

---------

Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
Co-authored-by: Marko Lisica <83164494+marko-lisica@users.noreply.github.com>
2023-11-15 13:58:46 -03:00
Martin Angers
8c3b23a142
Add endpoint to upload an MDM custom profile for Windows and macOS (#15150) 2023-11-15 10:58:59 -05:00
Martin Angers
9c87b12acb
Fix detection of Redis cluster on RedisLabs (#15104) 2023-11-15 09:03:06 -05:00
Roberto Dip
98c104a3b7
implement endpoint to batch set windows profiles (#15127)
for #14361. Avoiding a changelog entry intentionally since this API is
for contributors only.
2023-11-15 09:37:19 -03:00
Roberto Dip
6215d2e7d8
skip old migration tests (#15130)
migrations are static and not meant to change, so these tests have
successfully accomplished their purpose.

the main motivation is to prevent CI from timming out, as each migration
test runs all prior migrations from scratch, making these very time
expensive.
2023-11-14 13:42:17 -03:00
Jahziel Villasana-Espinoza
70048f5f91
14753 windows ps1 api (#15113)
# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-11-14 09:23:51 -05:00
Martin Angers
965a78d2de
Add endpoint to get or download a profile (Windows and macOS) (#15105) 2023-11-14 08:19:29 -05:00
Roberto Dip
8478171256
add a cron job to deliver windows MDM profiles (#15065)
for #14364 , this implements the delivery mechanism for windows hosts.

I will follow up in another PR with logic to update the profile status
when we get responses from the device.
2023-11-10 11:05:10 -03:00
Jahziel Villasana-Espinoza
447b9e8b25
feat: don't remove user email from activity feed when user deleted (#14975)
# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-11-09 15:50:01 -05:00
Victor Lyuboslavsky
ea47ebfb32
Enabled support and validation of 'after' parameter for several endpoints (#15047)
Loom explaining changes:
https://www.loom.com/share/f05f241a77304c19bc6ba1d0702c7bd8?sid=ea86b282-0bda-4ba4-a6cf-4520f0db610d

#14571 

Enabled support and validation of 'after' parameter for the following
endpoints:
- GET /api/v1/fleet/carves

Setting 'after' parameter no longer returns SQL syntax error for the
following endpoints:
- GET /api/v1/fleet/carves
- GET /api/v1/fleet/invites
- GET /api/v1/fleet/labels
- GET /api/v1/fleet/packs
- GET /api/v1/fleet/global/policies
- GET /api/v1/fleet/teams/{id}/policies
- GET /api/v1/fleet/queries
- GET /api/v1/fleet/packs/{id}/scheduled
- GET /api/v1/fleet/teams
- GET /api/v1/fleet/users

API doc changes PR: https://github.com/fleetdm/fleet/pull/15061

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Rachael Shaw <r@rachael.wtf>
2023-11-09 13:18:29 -06:00
Martin Angers
182ce615fb
Implement DELETE /mdm/profiles/{id} for Windows and macOS (#15045)
#14363 (partial implementation, missing the get/download endpoint which
will come in a subsequent PR)
2023-11-09 14:59:14 -03:00
Martin Angers
c7d5e5e618
Update authorization for MDM profiles to be platform-independent (#15023) 2023-11-08 11:36:57 -05:00
Martin Angers
9543bef88f
Use a uuid as primary key for windows profiles (#15008) 2023-11-07 16:35:28 -05:00
Roberto Dip
b112505bf1
rename profile status constants to be platform agnostic (#15013)
part of https://github.com/fleetdm/fleet/issues/14364, submitting
separately to reduce noise for the important bits.
2023-11-07 18:03:03 -03:00
Martin Angers
3bfafcd23c
Implement custom cloning of Team MDM config for the cached mysql layer. (#14965) 2023-11-07 09:51:55 -05:00
Martin Angers
f42f4d48af
Implement the database migrations for the Windows profiles story. (#14973) 2023-11-07 09:28:43 -05:00
Roberto Dip
33db665d63
show full formatted results for windows commands in fleetctl (#14922)
for #14912 this adds the full results to the "RESULTS" column of
`fleetctl get mdm-command-results`.

Additionally I included formatting of the XML output to improve
readability.
2023-11-03 12:01:43 -03:00
Victor Lyuboslavsky
3991619244
Added ListOptions validation to fleet/software endpoint. (#14838)
#14554 

For the following endpoints:
/api/v1/fleet/software
/api/v1/fleet/software/count
- added validation on `page`, `per_page`, `order_key`, `order_direction`
-- invalid values will now return 400 HTTP status code

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-11-01 09:56:27 -05:00
Roberto Dip
9cf30a9131
Feat windows msmdm (#14837)
for #13069

---------

Co-authored-by: Marcos Oviedo <marcos@fleetdm.com>
Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
Co-authored-by: gillespi314 <73313222+gillespi314@users.noreply.github.com>
2023-11-01 11:13:12 -03:00
Jahziel Villasana-Espinoza
b265d56d73
feat: reset yes/no count when query changes (#14776)
# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-10-31 12:29:09 -04:00
guangwu
33858d7301
chore: remove refs to deprecated io/ioutil (#14485)
# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [ ] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Documented any API changes (docs/Using-Fleet/REST-API.md or
docs/Contributing/API-for-contributors.md)
- [ ] Documented any permissions changes (docs/Using
Fleet/manage-access.md)
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] Manual QA for all new/changed functionality
  - For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
2023-10-27 15:28:54 -03:00
Roberto Dip
683c1dfe95
allow macOS hosts that turned on MDM via SSO to renew their enrollment (#14739)
for #14238
2023-10-27 12:42:30 -03:00
Lucas Manuel Rodriguez
fd99fd4121
Add optimizations for query reports at scale (#14710)
#7766

- ~[ ] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.~
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- ~[ ] Documented any API changes (docs/Using-Fleet/REST-API.md or
docs/Contributing/API-for-contributors.md)~
- ~[ ] Documented any permissions changes (docs/Using
Fleet/manage-access.md)~
- ~[ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)~
- ~[ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.~
- [X] Added/updated tests
- [X] Manual QA for all new/changed functionality
  - ~For Orbit and Fleet Desktop changes:~
- ~[ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.~
- ~[ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).~

---------

Co-authored-by: Jahziel Villasana-Espinoza <jahziel@fleetdm.com>
2023-10-25 19:20:27 -03:00
gillespi314
9c123ddd2b
Add integration tests for host disk encryption details (#14636) 2023-10-19 09:23:42 -05:00
gillespi314
484550a620
Add host mdm disk encryption detail to host details API response (#14623) 2023-10-18 15:39:23 -05:00
Roberto Dip
436733763a
always assign a DEP profile if the host is assigned in ABM (#14606)
for #13703 and #13992, this updates the logic used by the functions that
gather hosts that need DEP profile updates to use hosts directly from
`host_dep_assignments`, regardless of their MDM status.
2023-10-18 11:29:40 -03:00
Lucas Manuel Rodriguez
e58e72fb77
Prevent empty logging_type when creating and editing queries (#14575)
#14551

- ~[ ] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.~
- ~[ ] Documented any API changes (docs/Using-Fleet/REST-API.md or
docs/Contributing/API-for-contributors.md)~
- ~[ ] Documented any permissions changes (docs/Using
Fleet/manage-access.md)~
- ~[ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)~
- ~[ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.~
- [X] Added/updated tests
- [x] Manual QA for all new/changed functionality
  - ~For Orbit and Fleet Desktop changes:~
- ~[ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.~
- ~[ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).~
2023-10-16 19:33:39 -03:00
Roberto Dip
540f8b9657
Bring MDM hotfixes to main (#14494)
This brings the hotfixes in https://github.com/fleetdm/fleet/pull/14433
for https://github.com/fleetdm/confidential/issues/3922 and
https://github.com/fleetdm/confidential/issues/https://github.com/fleetdm/fleet/issues/3904

---------

Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
2023-10-13 08:49:11 -03:00
Jacob Shandling
51854b88bf make dump 2023-10-11 14:04:32 -07:00
Lucas Rodriguez
10c6390b94
Reorder migrations 2023-10-11 17:53:30 -03:00
Jacob Shandling
9cf4239b09 update order of migrations 2023-10-11 13:22:28 -07:00
Jacob Shandling
b886362ef2 remove duplicate migration file 2023-10-11 13:16:17 -07:00
Jacob Shandling
8c70011d87 update migration timestamp 2023-10-11 13:11:27 -07:00
Jacob Shandling
ed229af4b2 run make dump-test-schema 2023-10-11 12:58:22 -07:00
Jacob Shandling
70e0182e4d Merge branch 'main' into 7766-main-merge 2023-10-11 12:56:52 -07:00
Lucas Manuel Rodriguez
9facf144dc
Schedule queries on hosts even if automations off (given we now store results) (#14411)
This is ready to go.

---------

Co-authored-by: Tim Lee <timlee@fleetdm.com>
2023-10-11 15:20:06 -03:00
Roberto Dip
9ffa11c25d
Feat: saved scripts (#14409)
For #9537
2023-10-10 19:00:45 -03:00
Jacob Shandling
06ec117580 make dump-test-schema 2023-10-10 14:31:06 -07:00
Jacob Shandling
0422254ffd update timestamps 2 2023-10-10 14:20:25 -07:00
Jacob Shandling
d3b65bdf48 update timestamp 2023-10-10 13:36:59 -07:00
Jacob Shandling
bbebbc59b4 run make-dump-test-schema 2023-10-10 13:23:43 -07:00
Jacob Shandling
fb494ca3cb Merge branch '7766-frontend' into 7766-backend-frontend 2023-10-10 13:21:19 -07:00
Jahziel Villasana-Espinoza
0435431ae9
feat: can delete via cron job if global flag set (#14398)
# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added/updated tests

---------

Co-authored-by: Lucas Rodriguez <lucas@fleetdm.com>
2023-10-10 10:06:54 -03:00
Tim Lee
fa55d72118
Save Query Results to DB (#14335)
# Checklist for submitter

#13486 

If some of the following don't apply, delete the relevant line.

- [ ] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Documented any API changes (docs/Using-Fleet/REST-API.md or
docs/Contributing/API-for-contributors.md)
- [ ] Documented any permissions changes (docs/Using
Fleet/manage-access.md)
- [X] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [X] Added/updated tests
- [X] Manual QA for all new/changed functionality

---------

Co-authored-by: RachelElysia <71795832+RachelElysia@users.noreply.github.com>
Co-authored-by: Eric <eashaw@sailsjs.com>
Co-authored-by: Sampfluger88 <108141731+Sampfluger88@users.noreply.github.com>
Co-authored-by: Mike Thomas <78363703+mike-j-thomas@users.noreply.github.com>
Co-authored-by: Roberto Dip <me@roperzh.com>
Co-authored-by: Tyler Diderich <15862572+tdiderich@users.noreply.github.com>
Co-authored-by: Dave Herder <27025660+dherder@users.noreply.github.com>
Co-authored-by: Rachael Shaw <r@rachael.wtf>
Co-authored-by: Lucas Manuel Rodriguez <lucas@fleetdm.com>
Co-authored-by: Sharon Katz <121527325+sharon-fdm@users.noreply.github.com>
Co-authored-by: Mike McNeil <mikermcneil@users.noreply.github.com>
Co-authored-by: Nathanael Holliday <100959072+hollidayn@users.noreply.github.com>
Co-authored-by: Katheryn Satterlee <me@ksatter.com>
Co-authored-by: Mo Zhu <mo@fleetdm.com>
Co-authored-by: Mo Zhu <mozhu888@gmail.com>
Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
Co-authored-by: Robert Fairburn <8029478+rfairburn@users.noreply.github.com>
Co-authored-by: Sabrina Coy <13890648+sabrinabuckets@users.noreply.github.com>
Co-authored-by: Isabell Reedy <113355639+ireedy@users.noreply.github.com>
Co-authored-by: Noah Talerman <47070608+noahtalerman@users.noreply.github.com>
Co-authored-by: Alex Mitchell <105945793+alexmitchelliii@users.noreply.github.com>
2023-10-10 09:44:03 -03:00
Jahziel Villasana-Espinoza
5c868c9d3d
feat: deletion for query results (#14302)
# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
2023-10-09 17:43:17 -04:00
Jacob Shandling
eb327faabf
maintenance merge of main into feature branch (#14393)
maintenance merge of `main` into feature branch
2023-10-09 14:28:35 -07:00
Marcos Oviedo
f0d77ab3db
Merging Bitlocker feature branch (#14350)
This relates to #12577

---------

Co-authored-by: gillespi314 <73313222+gillespi314@users.noreply.github.com>
Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
2023-10-06 19:04:33 -03:00
Jahziel Villasana-Espinoza
b0de002fb2
fix: we should discard by default to avoid anything happening with existing queries (#14305)
# Checklist for submitter

The implementation #13488 was wrong; we needed to have query results
discarded by default, so customers shouldn't notice anything when they
upgrade.

If some of the following don't apply, delete the relevant line.

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
2023-10-05 08:29:40 -04:00
Tim Lee
4b50cf811b
Revert Backmerge from Main 2023-10-04 20:56:17 -06:00
Tim Lee
38af9678f4
Backmerge from main (#14298) 2023-10-04 14:24:40 -06:00
Jahziel Villasana-Espinoza
fe0589c9e5
feat: discard data column for queries (#14269)
Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
2023-10-03 15:43:38 -04:00
Tim Lee
c63e87fe17
13485 create query_results table migration (#14205) 2023-10-03 12:26:44 -06:00
Jahziel Villasana-Espinoza
b2938d1d53
jahzielv/fix/13809 host filtering (#14099)
- fix: use function that returns params
- fix: missing integration test

fixes: #13809

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
2023-09-26 12:59:37 -04:00