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

[ BUG ] Settings are not applied when creating new policies using Import-FalconConfig #222

Closed
ghost opened this issue Jul 19, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Jul 19, 2022

Describe the bug
Importing a configuration that was exported does not work correctly.
When importin a custom prevention policy no settings are imported. So every setting is set to false. Also the groups section is not imported.

It will print this error message, when importing a custom prevention policy:
Write-Result : [{"code":400,"message":"Prevention settings must specify an id"},{"code":400,"message":"Prevention settings must specify an id"},{"code":400,"message":"Prevention settings must specify an id"},{"code":400,"message":"Prevention settings must specify an id"},{"code":400,"message":"Prevention settings must specify an id"},{"code":400,"message":"Prevention settings must specify an id"},{"code":400,"message":"Prevention settings must specify an id"},{"code":400,"message":"Prevention settings must specify an id"},{"code":400,"message":"Prevention settings must specify an id"}]

With the debug option it is possible to see that the client sends the wrong data:

{"resources":[{"id":"----------------","settings":[{"id":null,"value":null},{"id":null,"value":null},{"id":null,"value":null},{"id":null,"value":null},{"id":null,"value":null},{"id":null,"value":null},{"id":null,"value":null},{"id":null,"value":null},{"id":null,"value":null}]}]}

To Reproduce
Export a configuration from a profile with custom settings and prevention policies, then delete these policies and import them back.

Expected behavior
It should import the configuration correct, so when exporting the configuration again, there should be no major difference.

Environment (please complete the following information):

  • OS: [Windows 10]
  • PowerShell: [5.1.19041.1682]
  • PSFalcon: [2.2.1]
  • API Keys scopes: Custom IOA rules RW, Host groups RW, Prevention policies RW, Response policies RW, Sensor update policies RW
@ghost ghost added the bug Something isn't working label Jul 19, 2022
@ghost ghost assigned bk-cs Jul 19, 2022
@bk-cs
Copy link
Collaborator

bk-cs commented Jul 21, 2022

Thank you for the report. I've verified this bug and plan on fixing it in the next release. In the meantime, you can work around the problem by using the Import-FalconConfig command twice while using the ModifyExisting parameter during the second run:

Import-FalconConfig MyConfig.zip
Import-FalconConfig MyConfig.zip -ModifyExisting PreventionPolicy

Please let me know if this does not behave as expected.

@ghost
Copy link
Author

ghost commented Jul 22, 2022

Unfortunatly it did not work:
I received error messages for the secound run. This is a part from them:

Import-FalconConfig : Das Argument für den Parameter "Id" kann nicht überprüft werden. Das Argument "f61XXXXc6 f61XXXXc6 " entspricht nicht dem Muster "^[a-fA-F0-9]{32}$". Geben   
Sie ein Argument an, das "^[a-fA-F0-9]{32}$" entspricht, und führen Sie den Befehl erneut aus.
In C:\Users\ME\script.ps1:169 Zeichen:5
+     Import-FalconConfig -Path  $ImportPath -ModifyExisting Prevention ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Import-FalconConfig

bk-cs added a commit that referenced this issue Aug 19, 2022
Issue #222: Updated comparison process to ensure an imported policy would be properly added to the list of items to be modified, whether or not it was going to be created. Removed existing copy policy operation from creation process.

Modified method of Write-Host output during the 'Add-Result' function to reduce overall code.

Updated 'Add-Result' to ensure proper results when modifying newly created policies.

Updated 'Import-ConfigData' function to exclude 'created_by', 'modified_by', 'created_timestamp' and 'modified_timestamp' fields during import.

Slightly re-organized the creation of 'FirewallGroup', 'IoaGroup', 'Script', 'IoaExclusion', 'MlExclusion' and 'SvExclusion'.
Moved HostGroup id update before creation of policies.

Changed 'if' statement that was used to determine if settings needed modification to reduce complexity.

Corrected warning message output to ensure that warning messages are produced for each policy and platform type when policy precedence should be verified.

Removed forced declaration of [object[]] arrays to ensure it didn't cause issues with the creation of policies with non-array based 'settings'.
@bk-cs
Copy link
Collaborator

bk-cs commented Aug 19, 2022

I believe I have fixed this issue. Can you try testing by replacing your Public\psf-config.ps1 file with the version below?

https://raw.githubusercontent.com/CrowdStrike/psfalcon/2.2.2/Public/psf-config.ps1

You will need to reload your PSFalcon module in order for the changes to take effect.

@bk-cs bk-cs changed the title [ BUG ] settings go missing when importing configurations [ BUG ] Settings are not applied when creating new policies using Import-FalconConfig Aug 24, 2022
@bk-cs
Copy link
Collaborator

bk-cs commented Sep 12, 2022

Closing issue--resolved in 2.2.2 release.

@bk-cs bk-cs closed this as completed Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant