Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mdm_apple_declarative_requests table to log DDM requests #17844

Merged
merged 10 commits into from Mar 27, 2024

Conversation

dantecatalfamo
Copy link
Member

@dantecatalfamo dantecatalfamo commented Mar 25, 2024

#17792

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements)
  • Added/updated tests
  • If database migrations are included, checked table schema to confirm autoupdate
  • For database migrations:
    • Checked schema for all modified table for columns that will auto-update timestamps during migration.
    • Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects.

@dantecatalfamo dantecatalfamo marked this pull request as ready for review March 26, 2024 15:05
@dantecatalfamo dantecatalfamo requested a review from a team as a code owner March 26, 2024 15:05
Copy link
Member

@roperzh roperzh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome! left a few minor comments

Copy link
Member

@mna mna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, left some comments as things to keep in mind, might apply or not depending on the requirements here. Also, we typically add unit tests for all Datastore methods, though maybe you plan to add them later during the freeze?

server/datastore/mysql/apple_mdm.go Outdated Show resolved Hide resolved
id BIGINT NOT NULL AUTO_INCREMENT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
enrollment_id VARCHAR(255) NOT NULL,
-- Should be one of "tokens", "declaration-items", "status", or "declaration/…/…" where the ellipses reference a declaration on the server
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

-- Should be one of "tokens", "declaration-items", "status", or "declaration/…/…" where the ellipses reference a declaration on the server
message_type VARCHAR(255),
-- json payload
raw_json TEXT,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here for not null. Also heads-up as it's definitely not obvious, TEXT has smaller limits than MEDIUMTEXT, to keep in mind depending on the size we expect to have to store here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to specify this as JSON rather than TEXT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point, I think Sarah means the JSON data type that's natively supported by mysql (see e.g. the app_config_json table).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does MySQL 5.7 support JSON column types?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it looks like yes! I'd be happy to do that if there are no reasons to stick with TEXT.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah just ran into an issue. All but one message_type have an empty json body, so that validator will complain unless I insert an empty json object

server/fleet/datastore.go Outdated Show resolved Hide resolved
server/service/integration_mdm_test.go Show resolved Hide resolved
@dantecatalfamo
Copy link
Member Author

Looks good, left some comments as things to keep in mind, might apply or not depending on the requirements here. Also, we typically add unit tests for all Datastore methods, though maybe you plan to add them later during the freeze?

I'm still waiting for the method that accepts a JSON body to be filled out

Copy link

codecov bot commented Mar 27, 2024

Codecov Report

Attention: Patch coverage is 65.21739% with 16 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (feat-macos-ddm@1edd9f0). Click here to learn what that means.

Files Patch % Lines
...ables/20240322145615_CreateTableNanoDDMRequests.go 78.26% 4 Missing and 1 partial ⚠️
server/mock/datastore_mock.go 0.00% 5 Missing ⚠️
server/datastore/mysql/apple_mdm.go 80.00% 2 Missing and 1 partial ⚠️
server/service/apple_mdm.go 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##             feat-macos-ddm   #17844   +/-   ##
=================================================
  Coverage                  ?   65.79%           
=================================================
  Files                     ?     1195           
  Lines                     ?   109507           
  Branches                  ?     2568           
=================================================
  Hits                      ?    72052           
  Misses                    ?    32001           
  Partials                  ?     5454           
Flag Coverage Δ
backend 66.79% <65.21%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@roperzh roperzh merged commit 7b13d9c into feat-macos-ddm Mar 27, 2024
19 checks passed
@roperzh roperzh deleted the table-mdm_apple_declarative_requests branch March 27, 2024 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants