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

44 validation cannot handle asserted relations with inferred assets #56

Conversation

mike1813
Copy link
Member

@mike1813 mike1813 commented Jul 5, 2023

There is now an update to the domain-network KB addressing issue Spyderisk/domain-network#23, which is tagged as v6a3-1-2-beta1 in the Spyderisk domain-network repository.

With this in place, it is possible to run a simple test of the system-modeller fix on branch 44 using the attached system model, which contains a single IoT Sensor. The test sequence is as follows:

  • deploy the system-modeller
  • deploy domain-network KB v6a3-1-2-beta1
  • import the test case
  • validate: this will create an onboard SensorProcess and a Data asset representing the sensor output
  • select the Sensor and use the properties panel to create a new outbound relationship 'stores' from the Sensor to the inferred Data asset
  • revalidate: this should add a stored DataCopy of the Data on the Sensor, and a DataService enabling access to it, plus relationships indicating that the SensorProcess now writes its output to the stored copy

Before the fix, the first validation failed to insert the correct relationship between the Process and Data, due to issue #52. The revalidation would then crash due to issue #44 (a separate problem not due to issue #52).

The fix consists of changes to the implementation of caching and especially cache synchronisation which were the cause of issue #52, and changes to the method for retrieving assets from the triple store which caused issue #44.

Closes #52, #44.
Issue 44 Test - Asserted - Before.nq.gz

mike1813 added 7 commits July 3, 2023 12:33
…irectly encoded links are not overwritten. Addresses #44.
…irectly encoded links are not overwritten. Addresses #52.
…erred-assets' of github.com:SPYDERISK/system-modeller into 44-validation-cannot-handle-asserted-relations-with-inferred-assets
…a bug in JenaQuerier.fixCardinalityConstraintURI() whereby CC URIs involving inferred assets were corrupted by revalidation.
@mike1813 mike1813 requested review from scp93ch and kenmeacham July 5, 2023 23:24
@mike1813 mike1813 linked an issue Jul 5, 2023 that may be closed by this pull request
Copy link
Contributor

@kenmeacham kenmeacham left a comment

Choose a reason for hiding this comment

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

The code changes seem reasonable, although I'm struggling to understand much of it.

I did some testing. Firstly just to say I couldn't find v6a3-1-2-beta1, although I did get hold of v6a3-1-2. Not sure if this is a problem?

Using this, I tested first on dev and did get an Exception where expected. I then tried this branch, which gave no errors. As far as I can tell, it produces inferred assets that you mentioned, although was I supposed to see those listed in #52? I don't see OutputPool for example.

If the above can be clarified, then I could approve the merge I think, as long as you are pretty sure that it behaves as you expect. I'll also run the unit tests manually, to be sure.

@mike1813
Copy link
Member Author

@kenmeacham : thanks for taking a look. Here are some clarifications on the test case.

The version number on the domain model should be OK. The last domain model fix is not yet merged, so I tried to give it the tag 'v6a3-1-2-beta1', but I think I screwed that up and ended up making it 'v6a3-1-2'.

The list of assets from issue #52 is what you should see before the Sensor-stores-[Data:Sensor] link was added. The issue there was that some of the links were not stored properly. So the point at which that should be checked is before you add the asserted link.

Once the asserted link has been added, we should get a total of 11 assets:

  • Sensor: the asserted asset
  • [World] is the global inferred public space where the Sensor is assumed to be (given that it has no other location
  • [Data:Sensor] is the sensed data
  • [DataCopy:{Data:Sensor]-Sensor]: is the serialized copy of this data stored on the Sensor device
  • [SensorProcess:Sensor] is the onboard process that communicates this data to other processes
  • [DataService:Sensor] is a data service added by the USB storage submodel, the sensor being assumed to be a USB device which is now storing a copy of its data
  • [DataOutput:[Data:Sensor]-[SensorProcess:Sensor]] represents the data in the workspace of the SensorProcess:Sensor projects that created it. This used to be an OutputPool because it was the only source of this data, but now the data is accessible via the DataService so the creation is represented as a simple DataOutput asset
  • [StoredDataPool:[Data:Sensor]-[DataService:Sensor]] represents the data in the workspace of the DataService:Sensor process
  • [HostContext:Sensor-[World]] is the context for access rights on Sensor when in [World]
  • [ProcessContext:Sensor-[SensorProcess:Sensor]-[World]] is the context for access rights of [SensorProcess:Sensor] on Sensor when in [World]
  • [ProcessContext:Sensor-[DataService:Sensor]-[World]] is the context for access rights of [DataService:Sensor] on Sensor when in [World]

The relationships are obviously a little different as well. Before issue #52 was addressed, only outgoing relationships from the Sensor device would have been stored. Now we should get 23 inferred relationship plus the 1 asserted relationship we added.

@kenmeacham
Copy link
Contributor

@kenmeacham : thanks for taking a look. Here are some clarifications on the test case.

The version number on the domain model should be OK. The last domain model fix is not yet merged, so I tried to give it the tag 'v6a3-1-2-beta1', but I think I screwed that up and ended up making it 'v6a3-1-2'.

The list of assets from issue #52 is what you should see before the Sensor-stores-[Data:Sensor] link was added. The issue there was that some of the links were not stored properly. So the point at which that should be checked is before you add the asserted link.

Once the asserted link has been added, we should get a total of 11 assets:

* Sensor: the asserted asset

* [World] is the global inferred public space where the Sensor is assumed to be (given that it has no other location

* [Data:Sensor] is the sensed data

* [DataCopy:{Data:Sensor]-Sensor]: is the serialized copy of this data stored on the Sensor device

* [SensorProcess:Sensor] is the onboard process that communicates this data to other processes

* [DataService:Sensor] is a data service added by the USB storage submodel, the sensor being assumed to be a USB device which is now storing a copy of its data

* [DataOutput:[Data:Sensor]-[SensorProcess:Sensor]] represents the data in the workspace of the SensorProcess:Sensor projects that created it. This used to be an OutputPool because it was the only source of this data, but now the data is accessible via the DataService so the creation is represented as a simple DataOutput asset

* [StoredDataPool:[Data:Sensor]-[DataService:Sensor]] represents the data in the workspace of the DataService:Sensor process

* [HostContext:Sensor-[World]] is the context for access rights on Sensor when in [World]

* [ProcessContext:Sensor-[SensorProcess:Sensor]-[World]] is the context for access rights of [SensorProcess:Sensor] on Sensor when in [World]

* [ProcessContext:Sensor-[DataService:Sensor]-[World]] is the context for access rights of [DataService:Sensor] on Sensor when in [World]

The relationships are obviously a little different as well. Before issue #52 was addressed, only outgoing relationships from the Sensor device would have been stored. Now we should get 23 inferred relationship plus the 1 asserted relationship we added.

Thanks for the clarification. I see the assets that you described, after initial validation, then adding the relation, etc.

What doesn't yet match is the relations. This is what I currently see to/from the Sensor:

image

@mike1813
Copy link
Member Author

@kenmeacham : there was a slight glitch in my previous comment. The number of assets is indeed 11, but I was using domain-network v6a3-1-1 which gets the inferred relationships slightly wrong. With v6a3-1-2, we should get 27 not 23 inferred relationships.

I have now checked the validated model as downloaded from your test system. You are getting the expected results: 11 assets, 28 relationships, 117 threats (plus 4 modelling error threats), 53 active control types related to the 11 assets, and 45 visible consequences, etc.

@kenmeacham
Copy link
Contributor

@kenmeacham : there was a slight glitch in my previous comment. The number of assets is indeed 11, but I was using domain-network v6a3-1-1 which gets the inferred relationships slightly wrong. With v6a3-1-2, we should get 27 not 23 inferred relationships.

I have now checked the validated model as downloaded from your test system. You are getting the expected results: 11 assets, 28 relationships, 117 threats (plus 4 modelling error threats), 53 active control types related to the 11 assets, and 45 visible consequences, etc.

Great. On that basis it seems that the fix is working, so I'll OK the pull request :)

@kenmeacham kenmeacham self-requested a review July 10, 2023 13:33
Copy link
Contributor

@kenmeacham kenmeacham 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 to merge, based on the latest tests and validation of results, etc.

@kenmeacham kenmeacham merged commit 695d128 into dev Jul 10, 2023
@kenmeacham kenmeacham deleted the 44-validation-cannot-handle-asserted-relations-with-inferred-assets branch July 10, 2023 13:36
@kenmeacham kenmeacham added this to the Release version 3.5.0 milestone Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants