-
Notifications
You must be signed in to change notification settings - Fork 53
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
Jtikekar/reverting nullables #353
Conversation
Revert DTO-nullables, Add Metadata-serializer
Revert nullables, Revert DTO-nullables, Add Metadata-serializer
epgrading to API version 3.0.2
Support for Metadata as per 3.0.2
Support for /submodel-elements and Get + $path
Support for $Path
|
||
[XmlIgnore] | ||
[JsonIgnore] | ||
private DateTime[] _timeStamp = new DateTime[2]; |
Check notice
Code scanning / CodeQL
Missed 'readonly' opportunity Note
else if(typeof(IMetadataDTO).IsAssignableFrom(context.ObjectType)) | ||
{ | ||
JsonNode? json = MetadataJsonSerializer.ToJsonObject((IMetadataDTO)context.Object); | ||
var writer = new Utf8JsonWriter(response.Body); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
foreach (var item in pagedResult.result) | ||
{ | ||
var json = MetadataJsonSerializer.ToJsonObject(item); | ||
jsonArray.Add(json); | ||
} |
Check notice
Code scanning / CodeQL
Missed opportunity to use Select Note
maps its iteration variable to another variable
pagingMetadata["cursor"] = cursor; | ||
} | ||
jsonNode["paging_metadata"] = pagingMetadata; | ||
var writer = new Utf8JsonWriter(response.Body); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
{ | ||
jsonNode = JsonSerializer.SerializeToNode(pagedResult); | ||
} | ||
var writer = new Utf8JsonWriter(response.Body); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtent/LevelExtentTransformer.cs
Fixed
Show fixed
Hide fixed
var valueNode = JsonSerializer.Deserialize<JsonNode>(valueString); | ||
valueArray.Add(valueNode); | ||
} | ||
var elementNode = ToJsonObject(element, true) as JsonNode; |
Check warning
Code scanning / CodeQL
Cast to same type Warning
return valueObject; | ||
} | ||
|
||
if (isParentSML) |
Check warning
Code scanning / CodeQL
Constant condition Warning
var context = new LevelExtentModifierContext(level, extent); | ||
return that.Select(source => source != null ? _transformer.Transform(source, context) : null).ToList(); | ||
private readonly IAppLogger<LevelExtentModifierService> _logger; | ||
LevelExtentTransformer _transformer; |
Check notice
Code scanning / CodeQL
Missed 'readonly' opportunity Note
@@ -214,7 +214,7 @@ | |||
[SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] | |||
[SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] | |||
[SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] | |||
public virtual IActionResult GetAllSubmodelDescriptorsThroughSuperpath([FromRoute] [Required] string aasIdentifier, | |||
public virtual IActionResult GetAllSubmodelDescriptorsThroughSuperpath([FromRoute] [Required] string? aasIdentifier, |
Check failure
Code scanning / CodeQL
Missing function level access control High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 4 months ago
To fix the issue, we need to add an authorization check to the GetAllSubmodelDescriptorsThroughSuperpath
method. The best way to do this in an ASP.NET Core MVC application is to use the [Authorize]
attribute, which ensures that only authenticated users can access the method. If specific roles are required, we can specify them within the attribute.
- Add the
[Authorize]
attribute to theGetAllSubmodelDescriptorsThroughSuperpath
method. - Ensure that the necessary imports for authorization are present.
-
Copy modified line R217
@@ -216,2 +216,3 @@ | ||
[SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] | ||
[Authorize] | ||
public virtual IActionResult GetAllSubmodelDescriptorsThroughSuperpath([FromRoute] [Required] string? aasIdentifier, |
|
Added copyright headers. |
Change in incorrect level and extent handling
var aasList = new List<IAssetAdministrationShell>(); | ||
foreach (var assetId in assetIds) | ||
{ | ||
aasList = output.Where(a => a.AssetInformation.SpecificAssetIds.ContainsSpecificAssetId(assetId)).ToList(); | ||
var result = new List<IAssetAdministrationShell>(); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning
result
if (assetId.Name.Equals("globalAssetId", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
result = output.Where(a => a.AssetInformation.GlobalAssetId!.Equals(assetId.Value)).ToList(); | ||
} | ||
else | ||
{ | ||
result = output.Where(a => a.AssetInformation.SpecificAssetIds!.ContainsSpecificAssetId(assetId)).ToList(); | ||
} |
Check notice
Code scanning / CodeQL
Missed ternary opportunity Note
( | ||
InoutputArguments == other.InoutputArguments || | ||
InoutputArguments != null && | ||
InoutputArguments.Equals(other.InoutputArguments) | ||
) && | ||
( | ||
InputArguments == other.InputArguments || | ||
InputArguments != null && | ||
InputArguments.Equals(other.InputArguments) | ||
) && | ||
( | ||
ClientTimeoutDuration == other.ClientTimeoutDuration || | ||
ClientTimeoutDuration != null && | ||
ClientTimeoutDuration.Equals(other.ClientTimeoutDuration) | ||
); |
Check notice
Code scanning / CodeQL
Complex condition Note
if (InoutputArguments != null) | ||
hashCode = hashCode * 59 + InoutputArguments.GetHashCode(); |
Check warning
Code scanning / CodeQL
Misleading indentation Warning
the control flow successor
if (InputArguments != null) | ||
hashCode = hashCode * 59 + InputArguments.GetHashCode(); |
Check warning
Code scanning / CodeQL
Misleading indentation Warning
the control flow successor
if (InoutputArguments != null) | ||
hashCode = hashCode * 59 + InoutputArguments.GetHashCode(); |
Check warning
Code scanning / CodeQL
Misleading indentation Warning
the control flow successor
catch (Exception e) | ||
{ | ||
throw new InvalidSerializationModifierException("extent"); | ||
} |
Check notice
Code scanning / CodeQL
Generic catch clause Note
{ | ||
result = Enum.Parse<ExtentEnum>(extent, true); | ||
} | ||
catch (Exception e) |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning
e
catch(Exception e) | ||
{ | ||
throw new InvalidSerializationModifierException("level"); | ||
} |
Check notice
Code scanning / CodeQL
Generic catch clause Note
{ | ||
result = Enum.Parse<LevelEnum>(level, true); | ||
} | ||
catch(Exception e) |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning
e
[SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] | ||
public virtual IActionResult GetDescription() | ||
{ | ||
var output = new ServiceDescription(); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning
output
|
||
/// <inheritdoc cref="IServiceDescription.ToString" /> | ||
public override string ToString() | ||
{ | ||
var sb = new StringBuilder(); | ||
sb.Append("class ServiceDescription {\n"); | ||
sb.Append(" Profiles: ").Append(Profiles).Append('\n'); | ||
sb.Append(" Profiles: ").Append(profiles).Append('\n'); |
Check warning
Code scanning / CodeQL
Use of default ToString() Warning
List
var reqIsCaseOf = _jsonQueryDeserializer.DeserializeReference("isCaseOf", isCaseOf); | ||
var reqDataSpecificationRef = _jsonQueryDeserializer.DeserializeReference("dataSpecificationRef", dataSpecificationRef); | ||
|
||
var cdList = new List<IConceptDescription>(); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning
cdList
outputEnv.AssetAdministrationShells.AddRange(aasList); | ||
} | ||
|
||
//Fetch Submodels for the requested submodelIds | ||
var submodelList = _submodelService.GetAllSubmodels(); | ||
//Using is null or empty, as the query parameter in controll currently receives empty list (not null, but count = 0) | ||
if (submodelIds.IsNullOrEmpty()) | ||
if (!submodelIds.IsNullOrEmpty()) |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
submodelIds
Variable
submodelIds
.Where(foundSubmodel => foundSubmodel.Any())) | ||
|
||
|
||
if((bool)includeCD) |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
includeCD
Revert nullables, Revert DTO-nullables, Add Metadata-serializer
Upgrading to API version 3.0.2
Remove child elements from MetadataDTOs (3.0.2)
Support for Metadata as per 3.0.2
Support for /submodel-elements and Get + $path
Support for $Path
Change in incorrect level and extent handling
…n-shell-io/aasx-server into jtikekar/revertingNullables
Description
Upgrading the AAS Repo APIs to BugFix Version 3.0.2 and fixing the broken Get APIs.
Motivation and Context
Due to refactoring lot of APIs have stopped working. Thus, fixing the API step by step also upgrading the APIs to the latest BugFix Version.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
The APIs have been tested manually and with the aas-test-engine.
Screenshots (if appropriate):
Checklist: