@@ -7,7 +7,10 @@ import * as facts from "./facts";
77import { instructionDigest } from "./dockerfile" ;
88import { DockerFileAnalysis , DockerFilePackages } from "./dockerfile/types" ;
99import { OCIDistributionMetadata } from "./extractor/oci-distribution-metadata" ;
10+
1011import * as types from "./types" ;
12+ import { truncateAdditionalFacts } from "./utils" ;
13+ import { PLUGIN_VERSION } from "./version" ;
1114
1215export { buildResponse } ;
1316
@@ -81,6 +84,62 @@ async function buildResponse(
8184 additionalFacts . push ( imageLabels ) ;
8285 }
8386
87+ if ( depsAnalysis . containerConfig ) {
88+ const containerConfigFact : facts . ContainerConfigFact = {
89+ type : "containerConfig" ,
90+ data : {
91+ ...( depsAnalysis . containerConfig . User !== undefined && {
92+ user : depsAnalysis . containerConfig . User ,
93+ } ) ,
94+ ...( depsAnalysis . containerConfig . ExposedPorts !== undefined && {
95+ exposedPorts : depsAnalysis . containerConfig . ExposedPorts
96+ ? Object . keys ( depsAnalysis . containerConfig . ExposedPorts )
97+ : null ,
98+ } ) ,
99+ ...( depsAnalysis . containerConfig . Env !== undefined && {
100+ env : depsAnalysis . containerConfig . Env ,
101+ } ) ,
102+ ...( depsAnalysis . containerConfig . Entrypoint !== undefined && {
103+ entrypoint : depsAnalysis . containerConfig . Entrypoint ,
104+ } ) ,
105+ ...( depsAnalysis . containerConfig . Cmd !== undefined && {
106+ cmd : depsAnalysis . containerConfig . Cmd ,
107+ } ) ,
108+ ...( depsAnalysis . containerConfig . Volumes !== undefined && {
109+ volumes : depsAnalysis . containerConfig . Volumes
110+ ? Object . keys ( depsAnalysis . containerConfig . Volumes )
111+ : null ,
112+ } ) ,
113+ ...( depsAnalysis . containerConfig . WorkingDir !== undefined && {
114+ workingDir : depsAnalysis . containerConfig . WorkingDir ,
115+ } ) ,
116+ ...( depsAnalysis . containerConfig . StopSignal !== undefined && {
117+ stopSignal : depsAnalysis . containerConfig . StopSignal ,
118+ } ) ,
119+ ...( depsAnalysis . containerConfig . ArgsEscaped !== undefined && {
120+ argsEscaped : depsAnalysis . containerConfig . ArgsEscaped ,
121+ } ) ,
122+ } ,
123+ } ;
124+ additionalFacts . push ( containerConfigFact ) ;
125+ }
126+
127+ if ( depsAnalysis . history && depsAnalysis . history . length > 0 ) {
128+ const historyFact : facts . HistoryFact = {
129+ type : "history" ,
130+ data : depsAnalysis . history . map ( ( entry ) => ( {
131+ ...( entry . created !== undefined && { created : entry . created } ) ,
132+ ...( entry . author !== undefined && { author : entry . author } ) ,
133+ ...( entry . created_by !== undefined && { createdBy : entry . created_by } ) ,
134+ ...( entry . comment !== undefined && { comment : entry . comment } ) ,
135+ ...( entry . empty_layer !== undefined && {
136+ emptyLayer : entry . empty_layer ,
137+ } ) ,
138+ } ) ) ,
139+ } ;
140+ additionalFacts . push ( historyFact ) ;
141+ }
142+
84143 if ( depsAnalysis . imageCreationTime ) {
85144 const imageCreationTimeFact : facts . ImageCreationTimeFact = {
86145 type : "imageCreationTime" ,
@@ -158,6 +217,28 @@ async function buildResponse(
158217 appDepsScanResult . facts . push ( imageIdFact ) ;
159218 }
160219
220+ if ( names && names . length > 0 ) {
221+ const imageNamesFact : facts . ImageNamesFact = {
222+ type : "imageNames" ,
223+ data : { names } ,
224+ } ;
225+ appDepsScanResult . facts . push ( imageNamesFact ) ;
226+ }
227+
228+ if ( ociDistributionMetadata ) {
229+ const metadataFact : facts . OCIDistributionMetadataFact = {
230+ type : "ociDistributionMetadata" ,
231+ data : ociDistributionMetadata ,
232+ } ;
233+ appDepsScanResult . facts . push ( metadataFact ) ;
234+ }
235+
236+ const appPluginVersionFact : facts . PluginVersionFact = {
237+ type : "pluginVersion" ,
238+ data : PLUGIN_VERSION ,
239+ } ;
240+ appDepsScanResult . facts . push ( appPluginVersionFact ) ;
241+
161242 return {
162243 ...appDepsScanResult ,
163244 target : {
@@ -199,6 +280,20 @@ async function buildResponse(
199280 additionalFacts . push ( metadataFact ) ;
200281 }
201282
283+ if ( depsAnalysis . platform ) {
284+ const platformFact : facts . PlatformFact = {
285+ type : "platform" ,
286+ data : depsAnalysis . platform ,
287+ } ;
288+ additionalFacts . push ( platformFact ) ;
289+ }
290+
291+ const pluginVersionFact : facts . PluginVersionFact = {
292+ type : "pluginVersion" ,
293+ data : PLUGIN_VERSION ,
294+ } ;
295+ additionalFacts . push ( pluginVersionFact ) ;
296+
202297 const scanResults : types . ScanResult [ ] = [
203298 {
204299 facts : [ depGraphFact , ...additionalFacts ] ,
@@ -217,8 +312,13 @@ async function buildResponse(
217312 ...applicationDependenciesScanResults ,
218313 ] ;
219314
315+ const truncatedScanResults = scanResults . map ( ( result ) => ( {
316+ ...result ,
317+ facts : truncateAdditionalFacts ( result . facts || [ ] ) ,
318+ } ) ) ;
319+
220320 return {
221- scanResults,
321+ scanResults : truncatedScanResults ,
222322 } ;
223323}
224324
0 commit comments