49 return $this->generateLicense($licenseData);
61 'bomFormat' =>
'CycloneDX',
62 '$schema' =>
'http://cyclonedx.org/schema/bom-1.7.schema.json',
63 'specVersion' =>
'1.7',
65 'serialNumber' =>
'urn:uuid:'. uuid_create(UUID_TYPE_TIME),
67 'timestamp' => date(
'c'),
71 'type' =>
'application',
72 'vendor' =>
'FOSSology',
73 'name' =>
'FOSSology',
74 'version' => $bomdata[
'tool-version'],
75 'bom-ref' =>
'tool-fossology'
78 'type' =>
'application',
79 'vendor' =>
'FOSSology',
80 'name' =>
'FOSSology Scanners',
81 'version' => $bomdata[
'tool-version'],
82 'bom-ref' =>
'tool-fossology-scanners'
88 'name' =>
'FOSSology Analyst',
89 'bom-ref' =>
'person-fossology-analyst'
92 'component' => $bomdata[
'maincomponent']
94 'components' => $bomdata[
'components']
97 if (isset($bomdata[
'citations']) && !empty($bomdata[
'citations'])) {
98 $report[
'citations'] = $bomdata[
'citations'];
101 if (!empty($bomdata[
'externalReferences'])) {
102 $report[
'externalReferences'] = $bomdata[
'externalReferences'];
117 'type' => $componentData[
'type'],
118 'name' => $componentData[
'name']
121 if (array_key_exists(
'version', $componentData) && !empty($componentData[
'version'])) {
122 $component[
'version'] = $componentData[
'version'];
125 if (array_key_exists(
'mimeType', $componentData) && !empty($componentData[
'mimeType'])) {
126 $component[
'mime-type'] = $componentData[
'mimeType'];
129 if (array_key_exists(
'bomref', $componentData) && !empty($componentData[
'bomref'])) {
130 $component[
'bom-ref'] = $componentData[
'bomref'];
137 if (array_key_exists(
'scope', $componentData) && !empty($componentData[
'scope'])) {
138 $component[
'scope'] = $componentData[
'scope'];
140 $component[
'scope'] =
'required';
143 if (array_key_exists(
'hashes', $componentData) && !empty($componentData[
'hashes'])) {
144 $component[
'hashes'] = $componentData[
'hashes'];
147 if (array_key_exists(
'licenses', $componentData) && !empty($componentData[
'licenses'])) {
148 $component[
'licenses'] = $componentData[
'licenses'];
151 if (array_key_exists(
'copyright', $componentData) && !empty($componentData[
'copyright'])) {
152 $component[
'copyright'] = $componentData[
'copyright'];
155 if (array_key_exists(
'purl', $componentData) && !empty($componentData[
'purl'])) {
156 $component[
'purl'] = $componentData[
'purl'];
159 if (array_key_exists(
'description', $componentData) && !empty($componentData[
'description'])) {
160 $component[
'description'] = $componentData[
'description'];
163 if (array_key_exists(
'externalReferences', $componentData) && !empty($componentData[
'externalReferences'])) {
164 $component[
'externalReferences'] = $componentData[
'externalReferences'];
168 if (array_key_exists(
'acknowledgements', $componentData) && !empty($componentData[
'acknowledgements'])) {
170 'name' =>
'fossology:acknowledgement',
171 'value' => $componentData[
'acknowledgements']
174 if (array_key_exists(
'comments', $componentData) && !empty($componentData[
'comments'])) {
176 'name' =>
'fossology:comment',
177 'value' => $componentData[
'comments']
180 if (!empty($properties)) {
181 $component[
'properties'] = $properties;
187 private function generateLicense(array $licenseData): array
192 if (array_key_exists(
'id', $licenseData) && !empty($licenseData[
'id']) &&
193 stripos($licenseData[
'id'], LicenseRef::SPDXREF_PREFIX) === 0) {
194 if (array_key_exists(
'bom-ref', $licenseData) && !empty($licenseData[
'bom-ref'])) {
195 $license[
'expressionDetailed'] = [
196 'value' => $licenseData[
'id'],
197 'bom-ref' => $licenseData[
'bom-ref']
199 if (array_key_exists(
'acknowledgement', $licenseData) && !empty($licenseData[
'acknowledgement'])) {
200 $license[
'expressionDetailed'][
'acknowledgement'] = $licenseData[
'acknowledgement'];
203 $license[
'expression'] = $licenseData[
'id'];
208 if (array_key_exists(
'id', $licenseData) && !empty($licenseData[
'id'])) {
209 $license[
'license'][
'id'] = $licenseData[
'id'];
210 }
else if (array_key_exists(
'name', $licenseData) && !empty($licenseData[
'name'])) {
211 $license[
'license'][
'name'] = $licenseData[
'name'];
214 if (array_key_exists(
'bom-ref', $licenseData) && !empty($licenseData[
'bom-ref'])) {
215 $license[
'license'][
'bom-ref'] = $licenseData[
'bom-ref'];
218 if (array_key_exists(
'acknowledgement', $licenseData) && !empty($licenseData[
'acknowledgement'])) {
219 $license[
'license'][
'acknowledgement'] = $licenseData[
'acknowledgement'];
222 if (array_key_exists(
'url', $licenseData) && !empty($licenseData[
'url'])) {
223 $license[
'license'][
'url'] = $licenseData[
'url'];
226 if (array_key_exists(
'textContent', $licenseData) && !empty($licenseData[
'textContent'])) {
227 $license[
'license'][
'text'] = [
228 'content' => $licenseData[
'textContent'],
229 'contentType' => $licenseData[
'textContentType'],
230 'encoding' =>
'base64'
244 private function generateHash(
string $algorithm,
string $content): array
248 'content' => $content
createHash($algorithm, $content)
generateHash(string $algorithm, string $content)
createComponent(array $componentData)
createLicense(array $licenseData)
generateComponent(array $componentData)
Namespace used by CycloneDX agent.