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

Sandbox: Flag enum content is not displayed in 'View' mode #67

Closed
daalcant opened this issue Jun 29, 2021 · 4 comments · Fixed by #65
Closed

Sandbox: Flag enum content is not displayed in 'View' mode #67

daalcant opened this issue Jun 29, 2021 · 4 comments · Fixed by #65
Labels
bug Something isn't working

Comments

@daalcant
Copy link
Contributor

Description:
In the Sandbox, objects containing flag enum members do not display corresponding enum content when viewed. Only the label is displayed.
E.g. see FirewallObject flag enum member 'Profiles'

Expected behavior:
Objects in 'View' mode should display all possible enum flag values as checkboxes, defaulting to unchecked.

To Reproduce:
Steps to reproduce the behavior:

  1. Run ASA, open GUI
  2. Click Sandbox page
  3. Select type that contains flag enum input, e.g. FirewallObject
  4. Create the object
  5. Click 'View' tab to view the object, expand its contents
  6. See labels where flag enum inputs are not being populated, for example 'Profiles' label when viewing FirewallObject

Configuration:

  • ASA Application Version: v2.3.146-beta
  • OAT Application Version: 718b12b
@daalcant
Copy link
Contributor Author

Partial fix currently exists in OAT repo branch: da/component-update, but set functionality hasn't been updated yet.

Modified FlagsInput.razor to still create checkboxes in cases where the flag enum member is null

@gfs gfs transferred this issue from microsoft/AttackSurfaceAnalyzer Jul 15, 2021
@gfs gfs linked a pull request Jul 15, 2021 that will close this issue
@gfs
Copy link
Contributor

gfs commented Jul 16, 2021

Modified FlagsInput.razor to still create checkboxes in cases where the flag enum member is null

This is probably the wrong approach. This should be covered by the set to null checkbox already.

@gfs
Copy link
Contributor

gfs commented Jul 16, 2021

According to official documentation the way to check if a type is nullable is

Nullable.GetUnderlyingType(type) != null

https://docs.microsoft.com/en-us/dotnet/api/system.nullable.getunderlyingtype?view=net-5.0

However, this does not appear to work for Enums, and this method will instead return null. I've verified this behavior directly in OAT so it is not an ASA issue. Unfortunately, it doesn't seem viable to de-nullable the Enums in Attack Surface Analyzer as null is a valid value for them (some of the enums are only valid on windows systems and the flags are passed through.)

@gfs
Copy link
Contributor

gfs commented Jul 16, 2021

I've narrowed this problem down to only Enums that start as null. Enums that are nullable but don't start as null now work.

gfs added a commit that referenced this issue Jul 21, 2021
Now works with nullable enums that are default to null.
@gfs gfs added the bug Something isn't working label Jul 27, 2021
@gfs gfs closed this as completed in #65 Jul 28, 2021
gfs added a commit that referenced this issue Jul 28, 2021
* Carry Scaffold Parameter Value Types

* Update ScaffoldInput.razor

* Update FlagsInput to use carried type

* Update Scaffold.cs

* Update ScaffoldInput.razor

* Move Tuple Check to Helpers.cs

* Update Helpers.cs

* Update Helpers.cs

* Update Helpers.cs

* Revert "Update Helpers.cs"

This reverts commit fa6dee3.

* Style ObjectInput

* Update ScaffoldInput.razor

* Update ScaffoldInput.razor

* Update PropertyInput.razor

* Update BoolInput.razor

* Update FlagsInput.razor

* Fix #68 and #69

* Should fix button to set nullables.

* Finish fixing #67

Now works with nullable enums that are default to null.

* Fixes

* Update OAT.Blazor.csproj

* Mostly Fix GUI

Issues:
Many elements cannot be clicked on, but can be tabbed to and used.
Icons images are not sized correctly.

* Improve which constructors are supported to match the inputs we have supported.

Fixes setting values in dictionaries.

* Remove merge comments.

* Also show the checkbox if the value is null

We cannot actually check if reference types are nullable so we need to check if the value is null and show the checkbox when it is null.

We do not show the checkbox if the value is no longer null and we can't confirm that its nullable.

* Support lists of enums

* Bump dependencies

Co-authored-by: David Alcantar <daalcant@microsoft.com>
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

Successfully merging a pull request may close this issue.

2 participants