Skip to content

Commit 060d21f

Browse files
committed
Fetching id, name, and properties, but lacking purls
1 parent 2e26790 commit 060d21f

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

modules/fundamental/src/sbom/endpoints/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ async fn get_aibom_models(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
17731773
let uri = format!("/api/v2/sbom/{id}/models");
17741774
let req = TestRequest::get().uri(&uri).to_request();
17751775
let response: Value = app.call_and_read_body_json(req).await;
1776-
log::info!("response:\n{:#}", json!(response));
1776+
log::debug!("response:\n{:#}", json!(response));
17771777
let expected_result = json!(
17781778
{
17791779
"items": [

modules/fundamental/src/sbom/model/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
purl::model::summary::purl::PurlSummary,
99
source_document::model::SourceDocument,
1010
};
11-
use sea_orm::{ConnectionTrait, ModelTrait, PaginatorTrait, prelude::Uuid};
11+
use sea_orm::{ConnectionTrait, FromQueryResult, ModelTrait, PaginatorTrait, prelude::Uuid};
1212
use serde::{Deserialize, Serialize};
1313
use time::OffsetDateTime;
1414
use tracing::instrument;
@@ -110,12 +110,18 @@ impl SbomSummary {
110110
}
111111
}
112112

113-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, ToSchema, Default)]
113+
#[derive(
114+
FromQueryResult, Serialize, Deserialize, Debug, Clone, PartialEq, Eq, ToSchema, Default,
115+
)]
114116
pub struct SbomModel {
115117
/// The SBOM internal ID of a model
116118
pub id: String,
117119
/// The name of the model in the SBOM
118120
pub name: String,
121+
/// The properties associated with the model
122+
pub properties: serde_json::Value,
123+
/// The model's PURL
124+
pub purls: Vec<serde_json::Value>,
119125
}
120126

121127
impl SbomModel {

modules/fundamental/src/sbom/service/sbom.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,10 @@ impl SbomService {
446446
let query = join_purls(
447447
sbom_ai::Entity::find()
448448
.select_only()
449-
.column(sbom_ai::Column::SbomId)
450-
.group_by(sbom_ai::Column::SbomId)
451-
.column(sbom_ai::Column::NodeId)
449+
.column_as(sbom_ai::Column::NodeId, "id")
452450
.group_by(sbom_ai::Column::NodeId)
451+
.column_as(sbom_node::Column::Name, "name")
452+
.group_by(sbom_node::Column::Name)
453453
.column(sbom_ai::Column::Properties)
454454
.group_by(sbom_ai::Column::Properties)
455455
.filter(sbom_ai::Column::SbomId.eq(sbom_id))
@@ -458,16 +458,19 @@ impl SbomService {
458458
)
459459
.filtering(search)?;
460460

461-
let limiter = query.limiting(connection, paginated.offset, paginated.limit);
461+
let limiter = limit_selector::<'_, _, _, _, SbomModel>(
462+
connection,
463+
query,
464+
paginated.offset,
465+
paginated.limit,
466+
);
467+
462468
let total = limiter.total().await?;
463469
let items = limiter.fetch().await?;
464470

465471
log::debug!("total={total}");
466472

467-
Ok(PaginatedResults {
468-
items: SbomModel::from_entities(&items).await?,
469-
total,
470-
})
473+
Ok(PaginatedResults { items, total })
471474
}
472475

473476
/// Get all the tuples License ID, License Name from the licensing_infos table for a single SBOM

openapi.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5004,13 +5004,21 @@ components:
50045004
required:
50055005
- id
50065006
- name
5007+
- properties
5008+
- purls
50075009
properties:
50085010
id:
50095011
type: string
50105012
description: The SBOM internal ID of a model
50115013
name:
50125014
type: string
50135015
description: The name of the model in the SBOM
5016+
properties:
5017+
description: The properties associated with the model
5018+
purls:
5019+
type: array
5020+
items: {}
5021+
description: The model's PURL
50145022
total:
50155023
type: integer
50165024
format: int64
@@ -5682,13 +5690,21 @@ components:
56825690
required:
56835691
- id
56845692
- name
5693+
- properties
5694+
- purls
56855695
properties:
56865696
id:
56875697
type: string
56885698
description: The SBOM internal ID of a model
56895699
name:
56905700
type: string
56915701
description: The name of the model in the SBOM
5702+
properties:
5703+
description: The properties associated with the model
5704+
purls:
5705+
type: array
5706+
items: {}
5707+
description: The model's PURL
56925708
SbomPackage:
56935709
type: object
56945710
required:

0 commit comments

Comments
 (0)