Commit graph

128 commits

Author SHA1 Message Date
Roberto Dip
178c0d565f Merge remote-tracking branch 'origin/main' into feat-save-certs 2024-05-30 18:34:40 -03:00
Roberto Dip
545e56d288
19016 ingest certs on start (#19360)
For #19016

This changes all the places where we previously assumed that certs were
hardcoded when the Fleet server started to query the database instead.

The plan is to loadtest afterwards, but as a first preemptive measure,
this adds a caching layer on top the mysql datastore.

# 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] 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] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [x] Manual QA for all new/changed functionality
2024-05-30 18:18:42 -03:00
Lucas Manuel Rodriguez
cdf2a0c47c
iPhone/iPad support (#19221)
#18119

- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/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)
- [ ] 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

---------

Co-authored-by: RachelElysia <71795832+RachelElysia@users.noreply.github.com>
Co-authored-by: Jacob Shandling <61553566+jacobshandling@users.noreply.github.com>
Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2024-05-28 19:17:14 -03:00
Lucas Manuel Rodriguez
984711060f
Some docs added while learning DDM for iOS/iPadOS support research (#18561)
Some docs added while working on #18423.
2024-05-28 15:03:39 -03:00
Jahziel Villasana-Espinoza
e11f44a89b
feat: upload and delete APNS certs (#19275)
> Related issue: #19014 

# 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/`,
`orbit/changes/` or `ee/fleetd-chrome/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

---------

Co-authored-by: Roberto Dip <rroperzh@gmail.com>
2024-05-27 11:13:08 -03:00
Jahziel Villasana-Espinoza
1e92d3b10e fix: wrap errors 2024-05-24 13:52:33 -04:00
Jahziel Villasana-Espinoza
2d8038ddd0 fix: address feedback 2024-05-23 20:55:36 -04:00
Jahziel Villasana-Espinoza
be8489a2fd chore: cleanup 2024-05-23 18:27:18 -04:00
Jahziel Villasana-Espinoza
396630213e feat: implement reusing existing apns key 2024-05-23 17:22:36 -04:00
Jahziel Villasana-Espinoza
3ffe65b2f9 feat: call website, start integration test 2024-05-23 14:56:43 -04:00
Jahziel Villasana-Espinoza
2f98b9d09f feat: can write to db 2024-05-22 18:04:00 -04:00
Jahziel Villasana-Espinoza
2d93f7c55d feat: basic endpoint setup 2024-05-22 09:31:08 -04:00
Roberto Dip
05719633a1
add consistent MDM host lifecycle management (#18510)
The mantra for MDM lifecycle events is:

> - Noah: When MDM is turned on, install fleetd, bootstrap package (if
DEP),
> and profiles. Don't clear host vitals (everything you see on the Host
>      details page)
>    - Noah: On re-enrollment, don't clear host vitals.
>    - Noah: On lock and wipe, don't clear host vitals.
>    - Noah: On delete, clear host vitals.

This addresses issues:

- https://github.com/fleetdm/fleet/issues/17243
- https://github.com/fleetdm/fleet/issues/17481
- https://github.com/fleetdm/fleet/issues/17292
- https://github.com/fleetdm/fleet/issues/18030
- https://github.com/fleetdm/fleet/issues/18031
2024-04-29 16:43:15 -03:00
Gabriel Hernandez
c423f415a6
Fix uploading signed apple mobileconfig profiles (#18482)
relates to #18389

This fixes an issue with some signed apple mobileconfig profiles were
not able to be uploaded.

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

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/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-04-25 17:09:53 +01:00
Roberto Dip
e39f5bce3b
implement logic to sign apple profiles (#16490)
#10418
2024-04-18 18:01:37 -03:00
Martin Angers
47279ca2a9 Fix conflicts 2024-04-15 16:10:10 -04:00
Martin Angers
ea0da5e2fa
Add tool to get a profile as defined in Apple BM (#18274) 2024-04-15 15:11:46 -04:00
Martin Angers
6af79d139d Remove obsolete todo 2024-04-08 17:04:40 -04:00
Sarah Gillespie
05ccf9ee23
Fix issues related to Fleet builtin labels and reserved MDM profile names (#18043) 2024-04-08 14:34:55 -05:00
Martin Angers
7964a81828 Add tests for declarations 2024-04-08 14:48:11 -04:00
Roberto Dip
f1b45a3865
friday tidy up party (#18106)
- add missing tests
- remove unused code
- remove unnecessary nested branches
2024-04-08 08:42:42 -03:00
Martin Angers
c28bd8fc3a Create the DDM profile for macOS updates 2024-04-03 09:50:30 -04:00
Roberto Dip
9af01e53e9 add missing activity items, fix CLI error messages
for #17954
2024-03-29 14:43:28 -03:00
Roberto Dip
e34b320ed5 Merge remote-tracking branch 'origin/main' into feat-macos-ddm 2024-03-27 11:58:22 -03:00
Roberto Dip
f0ad942a57
implement status reports for DDM commands (#17831)
for #17408
2024-03-26 10:40:35 -03:00
Martin Angers
994040b1c9
Send DeviceConfigured MDM command after DEP enrollment (#17737) 2024-03-25 13:25:29 -04:00
Gabriel Hernandez
577d5c27ea Merge branch 'main' into feat-macos-ddm 2024-03-25 11:11:40 +00:00
StepSecurity Bot
80335d88d1
[StepSecurity] Apply security best practices (#17811) 2024-03-22 16:19:11 -05:00
Sarah Gillespie
01e3b94e55
Update backend APIs for macOS DDM (#17734)
Co-authored-by: Jahziel Villasana-Espinoza <jahziel@fleetdm.com>
2024-03-20 14:15:07 -05:00
Roberto Dip
e26d23460c
record declarative checkin command responses (#17693)
this is to prevent nanomdm to send the DeclarativeManagement command
every time the host checks in.
2024-03-18 14:41:33 -03:00
Roberto Dip
525233efea
fix unreleased bug with ADE profile assignment (#17509)
for unreleased #17508
2024-03-08 16:45:18 -03:00
Roberto Dip
e8b7ce81dc
don't run SCEP test in parallel to avoid race in dependency (#17457)
The https://pkg.go.dev/go.mozilla.org/pkcs7 package uses an unguarded
package-level variable:


33d05740a3/ber.go (L19-L21)

This was causing this data race during tests:

```
==================
WARNING: DATA RACE
Read at 0x0000009b89b0 by goroutine 22:
  go.mozilla.org/pkcs7.asn1Structured.EncodeTo()
      /home/runner/go/pkg/mod/go.mozilla.org/pkcs7@v0.0.0-20210826202110-33d05740a352/ber.go:21 +0x56
  go.mozilla.org/pkcs7.(*asn1Structured).EncodeTo()
      <autogenerated>:1 +0xa5
  go.mozilla.org/pkcs7.ber2der()
      /home/runner/go/pkg/mod/go.mozilla.org/pkcs7@v0.0.0-20210826202110-33d05740a352/ber.go:68 +0xdb
  go.mozilla.org/pkcs7.Parse()
      /home/runner/go/pkg/mod/go.mozilla.org/pkcs7@v0.0.0-20210826202110-33d05740a352/pkcs7.go:160 +0x12f
  github.com/fleetdm/fleet/v4/server/mdm/scep/scep.ParsePKIMessage()
      /home/runner/work/fleet/fleet/server/mdm/scep/scep/scep.go:234 +0x1d2
  github.com/fleetdm/fleet/v4/server/mdm/scep/scep_test.testParsePKIMessage()
      /home/runner/work/fleet/fleet/server/mdm/scep/scep/scep_test.go:21 +0x56
  github.com/fleetdm/fleet/v4/server/mdm/scep/scep_test.TestNewCSRRequest.func1()
      /home/runner/work/fleet/fleet/server/mdm/scep/scep/scep_test.go:198 +0x7e5
  testing.tRunner()
      /opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      /opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1648 +0x44

Previous write at 0x0000009b89b0 by goroutine 23:
  go.mozilla.org/pkcs7.asn1Structured.EncodeTo()
      /home/runner/go/pkg/mod/go.mozilla.org/pkcs7@v0.0.0-20210826202110-33d05740a352/ber.go:21 +0x6e
  go.mozilla.org/pkcs7.(*asn1Structured).EncodeTo()
      <autogenerated>:1 +0xa5
  go.mozilla.org/pkcs7.ber2der()
      /home/runner/go/pkg/mod/go.mozilla.org/pkcs7@v0.0.0-20210826202110-33d05740a352/ber.go:68 +0xdb
  go.mozilla.org/pkcs7.Parse()
      /home/runner/go/pkg/mod/go.mozilla.org/pkcs7@v0.0.0-20210826202110-33d05740a352/pkcs7.go:160 +0x12f
  github.com/fleetdm/fleet/v4/server/mdm/scep/scep.(*PKIMessage).DecryptPKIEnvelope()
      /home/runner/work/fleet/fleet/server/mdm/scep/scep/scep.go:344 +0xde
  github.com/fleetdm/fleet/v4/server/mdm/scep/scep_test.TestNewCSRRequest.func1()
      /home/runner/work/fleet/fleet/server/mdm/scep/scep/scep_test.go:199 +0x7fa
  testing.tRunner()
      /opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      /opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1648 +0x44

Goroutine 22 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1648 +0x845
  github.com/fleetdm/fleet/v4/server/mdm/scep/scep_test.TestNewCSRRequest()
      /home/runner/work/fleet/fleet/server/mdm/scep/scep/scep_test.go:165 +0x3ac
  testing.tRunner()
      /opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      /opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1648 +0x44

Goroutine 23 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1648 +0x845
  github.com/fleetdm/fleet/v4/server/mdm/scep/scep_test.TestNewCSRRequest()
      /home/runner/work/fleet/fleet/server/mdm/scep/scep/scep_test.go:165 +0x3ac
  testing.tRunner()
      /opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1595 +0x261
  testing.(*T).Run.func1()
      /opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1648 +0x44
==================
    testing.go:1465: race detected during execution of test
=== NAME  TestNewCSRRequest/KeyEncipherment_not_set_with_NOP_certificates_selector
```
2024-03-07 12:01:52 -03:00
Roberto Dip
9c5b59df0d
prevent redundant ADE profile assignment (#17427)
For #17291, this prevent re-assigning profiles to ABM hosts that already
have the right one.

This was happening very frequently for hosts that are in the last page
of the `/sync` request, as there's no indication that the cursor was
exhausted and we keept on assigning profiles to those hosts.

This caused profile assignment to eventually fail, presumably due to
rate limiting.
2024-03-06 18:16:10 -03:00
Roberto Dip
e3712fb263
Don't run cleanup tasks or enqueue commands on SCEP renewals (#17303)
for #17232
2024-03-04 16:53:16 -03:00
Gabriel Hernandez
4fa50778ac merge main into feat-mdm-wipe-host 2024-03-01 17:08:41 +00:00
Sarah Gillespie
e0cb59d4cb
Surface MDM devices where DEP assignment failed (#16973) 2024-03-01 10:52:19 -06:00
Roberto Dip
89ae60ddec
fix tests run with -race in server/mdm/scep (#17274)
scheduled tests, which are run with `-race` are [failing][1], this was
fixed in the `etcd-io/bbolt` fork of the now archived `boltdb/bolt`, for
more details check [this issue][2].

since boltdb is used only for tests, and they're passing after switching
to the fork, this seems like a reasonable way to fix them.

[1]: https://github.com/fleetdm/fleet/actions/runs/8090809417
[2]: https://github.com/etcd-io/bbolt/issues/391

# 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] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-02-29 15:55:15 -03:00
Gabriel Hernandez
4ee65ce184 Merge branch 'main' into feat-mdm-wipe-host 2024-02-29 11:22:31 +00:00
Jahziel Villasana-Espinoza
2d4a183789
feat: allow <Add> node in Windows MDM profiles (#17234)
> Related issue: #16335

# 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-02-28 15:05:13 -05:00
Gabriel Hernandez
01af4b78cd Merge branch 'main' into feat-mdm-wipe-host 2024-02-27 14:23:43 +00:00
Martin Angers
a01241ec2e
Remote wipe: add API endpoint and activity (#17060) 2024-02-26 11:31:00 -05:00
Martin Angers
2dfb260850
Move nanodep dependency in monorepo (#16984) 2024-02-26 10:26:00 -05:00
Roberto Dip
261332f76c
automatically renew macOS identity certificates 30 days prior to their expiration (#17057)
#15332

# 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
2024-02-22 16:23:12 -03:00
Jahziel Villasana-Espinoza
272ce3187f
feat: move scep dependency inside the monorepo (#16988)
Following the pattern set up by Martin and Lucas for similar PRs. Can be
reviewed by commits:

1. move scep directory into monorepo
2. update import paths
3. update go.mod, go.sum
4. fix golint errors in scep package
5. skip a failing test that's been broken for a while
6. fix that failing test

# 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] Manual QA for all new/changed functionality

Also verified that our test suite runs the `scep` tests.
2024-02-22 13:13:46 -05:00
Martin Angers
c5b988d600
Fix stack trace of captured errors in Sentry, capture errors in more code paths (#16966)
#16480 

# 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
2024-02-22 15:10:28 -03:00
Martin Angers
9082438580
Feature: Remote Lock for macOS, Windows and Linux (#16783)
Feature branch for the #9949  story.

---------

Co-authored-by: Jahziel Villasana-Espinoza <jahziel@fleetdm.com>
Co-authored-by: Roberto Dip <me@roperzh.com>
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
Co-authored-by: Sarah Gillespie <sarah@fleetdm.com>
2024-02-13 13:03:53 -05:00
Roberto Dip
2d4c1b079a
improvements for troubleshooting workflow for MDM commands (#16654)
for #16416
2024-02-07 16:24:03 -03:00
Sarah Gillespie
78aa1b0080
Update backend MDM migration flow and add logging to aid in debugging migration errors (#16627) 2024-02-06 16:53:43 -06:00
Roberto Dip
5fe65d414c
allow to configure a custom configuration_web_url (#16175)
for #15633
2024-01-17 19:47:04 -03:00
Martin Angers
45cc94d9c3
Fix polling schedule for Windows MDM (#16104) 2024-01-16 09:05:19 -05:00