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

SALTO-6721: [Intune] Create a static file from the Device Configuration template payload #6625

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

shoshana-houri
Copy link
Contributor

Some device configuration policies may contain configuration profile files returned as base64 blobs. This PR extracts them to static files.


See example .nacl structure here.
And the matching static file.


Release Notes:


User Notifications:

@coveralls
Copy link

coveralls commented Sep 25, 2024

Coverage Status

coverage: 93.883% (+0.001%) from 93.882%
when pulling c656fbe on shoshana-houri:salto-6721
into 6ae846f on salto-io:main.

Copy link
Contributor

@shir-reifenberg shir-reifenberg left a comment

Choose a reason for hiding this comment

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

Great job (and super fast)
added some comments, LMK WDYT 😄

...value,
payload: createStaticFileFromBase64Blob({
typeName: DEVICE_CONFIGURATION_TYPE_NAME,
fullName: value[NAME_ID_FIELD.fieldName],
Copy link
Contributor

Choose a reason for hiding this comment

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

(I think I missed it in the previous reviews, sorry about this)
you're making an assumption here that elemID fields are always NAME_ID_FIELD, while it can be configured by the user and then the instance and the static file will be misaligned / we'll get few static files in the same file

I think the alternatives are

  1. calling the function to calculate the elemID here (see similar example here)
  2. use custom to create the instance (I don't really like it 😅

Any other suggestions ? WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh, that's a good point, thanks!
Can the elemID still be configured by the user with the new infra? I don't think we’re accounting for the user config when creating the fetch definitions (at least not explicitly in the Microsoft Security adapter)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yap :) via elemID config (under fetch), see this part

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, thanks @shir-reifenberg! The issue with the first method is that AFAIU it can only be used after the definitions are resolved, whereas we need it when setting the fetch definitions, since this is called inside an adjust function in the fetch definitions.
WDYS? Perhaps we should consider allowing the user config to be propagated to the custom adjust functions?

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right @shoshana-houri 😄 , even if we pass the userConfig, it won't take into account SALTO_DEFINITIONS_OVERRIDES as well... and it's actually quite strange to calculate elem ID related things in the adjust function of the request

I guess that's the issue with creating static files while we don't have the parent instance yet in hand..
I think you can merge this for now, but we should address it differently as it wouldn't work with elemIDs customizations on the device configuration.
Can you please open a ticket for this ? (and also tag @netama, as she might have a suggestion / thought about it before)

Copy link
Contributor

@Nurdok Nurdok left a comment

Choose a reason for hiding this comment

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

LGTM. I'll leave the approval for Shir :)

const value = {
displayName: 'name',
payload:
'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxub3RlPg0KICA8dG8+VGVzdDwvdG8+DQogIDxmcm9tPlRlc3RlcjwvZnJvbT4NCiAgPGhlYWRpbmc+UGxlYXNlIHdvcmsgbmljZWx5PC9oZWFkaW5nPg0KICA8Ym9keT5UaGFuayB5b3U8L2JvZHk+DQo8L25vdGU+',
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an arbitrary base64-encoded string, why not make it shorter? 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image My kind of easter egg 🥚 😅 You're right though, I'll use the shorter one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants