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

GET /advisories #52

Closed

Conversation

carlosthe19916
Copy link
Member

Hi tried to put my hands into generating REST endpoints for the advisories. Some questions came to my mind:

  • Do we really need the following data inside the Paginated Object?
pub num_pages: u64,
pub prev_page: Option<Paginated>,
pub next_page: Option<Paginated>, 

From the REST point of view, whoever is making a request can infer all those 3 fields based on data being send and the first response of the server.

  • At the moment, we save (in the DB) limited data about Advisory . We will definitely need to extract more fields out of the CSAF files. I could not find any code where we are extracting data from CSAF files and then map them to the DB or object. Is something like that already existing somewhere or it needs to be implemented?
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub identifier: String,
    pub location: String,
    pub sha256: String,
}

I'm not expecting this PR to be merged as it does not contain the fields I expect to expose through the REST endpoints, but I just wanted to open this PR for my questions to make more sense.

@carlosthe19916
Copy link
Member Author

Or perhaps starting on "Advisories" was a bad idea as other abstractions like "Packages", "CVEs", "SBOMs" might be better implemented at the moment? xD

@bobmcwhirter
Copy link
Contributor

We can certainly modify how pagination works. That was mostly a spike for me to understand how SeaORM handles paginating, along with my own ignorance of what's needed on the front-end. I somewhat come from the school of HATEOAS, and generally prefer for links to be sent within the response, instead of the client having to calculate and construct URLs from patterns.

But that's not a strongly-held opinion.

@bobmcwhirter
Copy link
Contributor

@carlosthe19916
Copy link
Member Author

We can certainly modify how pagination works. That was mostly a spike for me to understand how SeaORM handles paginating, along with my own ignorance of what's needed on the front-end. I somewhat come from the school of HATEOAS, and generally prefer for links to be sent within the response, instead of the client having to calculate and construct URLs from patterns.

But that's not a strongly-held opinion.

Certainly for a UI is better to rely on itself to create URLs. However, the REST API and the functions within the backend should not consider the UI as the only/unique consumer but also consider other potential consumers of the REST API (like terminals, or anything else that comes to our mid). So having HATEOAS sounds good.

I'll close this PR as I also found the block of code I was searching: https://github.com/trustification/trustify/blob/main/importer/src/csaf/mod.rs#L129 this is where files start their journey to be ingested/processed/stored

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants