Skip to content

Commit

Permalink
Add new license fields on Component and Package models #63
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Jun 10, 2024
1 parent 9e8f6c6 commit 8fa6df9
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 0 deletions.
133 changes: 133 additions & 0 deletions component_catalog/migrations/0005_license_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Generated by Django 5.0.6 on 2024-06-10 05:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("component_catalog", "0004_initial"),
]

operations = [
migrations.AddField(
model_name="component",
name="declared_license_expression",
field=models.TextField(
blank=True,
help_text="A license expression derived from statements in the key files of a software project, such as the NOTICE, COPYING, README, and LICENSE files.",
),
),
migrations.AddField(
model_name="component",
name="declared_license_expression_spdx",
field=models.TextField(
blank=True,
help_text="A declared license expression that uses the license identifiers defined by SPDX, as well as the “Licenseref” syntax for licenses not on the SPDX list.",
verbose_name="Declared license expression SPDX",
),
),
migrations.AddField(
model_name="component",
name="extracted_license_statement",
field=models.TextField(
blank=True,
help_text="The actual text extracted from a software project that supports the license detection process.",
),
),
migrations.AddField(
model_name="component",
name="license_detections",
field=models.JSONField(
blank=True,
default=list,
help_text="A list of specific license identifiers derived from statements in the key files of a software project, such as the NOTICE, COPYING, README, and LICENSE files.",
),
),
migrations.AddField(
model_name="component",
name="other_license_detections",
field=models.JSONField(
blank=True,
default=list,
help_text="A list of specific license identifiers derived from the non-key files of a software project, which are very often third-party software used by the project, or test, sample and documentation files.",
),
),
migrations.AddField(
model_name="component",
name="other_license_expression",
field=models.TextField(
blank=True,
help_text="A license expression derived from detected licenses in the non-key files of a software project, which are often third-party software used by the project, or test, sample and documentation files.",
),
),
migrations.AddField(
model_name="component",
name="other_license_expression_spdx",
field=models.TextField(
blank=True,
help_text="A license expression derived from detected licenses in the non-key files of a software project, using the license identifiers defined by SPDX, as well as the “Licenseref” syntax for licenses not on the SPDX list.",
verbose_name="Other license expression SPDX",
),
),
migrations.AddField(
model_name="package",
name="declared_license_expression",
field=models.TextField(
blank=True,
help_text="A license expression derived from statements in the key files of a software project, such as the NOTICE, COPYING, README, and LICENSE files.",
),
),
migrations.AddField(
model_name="package",
name="declared_license_expression_spdx",
field=models.TextField(
blank=True,
help_text="A declared license expression that uses the license identifiers defined by SPDX, as well as the “Licenseref” syntax for licenses not on the SPDX list.",
verbose_name="Declared license expression SPDX",
),
),
migrations.AddField(
model_name="package",
name="extracted_license_statement",
field=models.TextField(
blank=True,
help_text="The actual text extracted from a software project that supports the license detection process.",
),
),
migrations.AddField(
model_name="package",
name="license_detections",
field=models.JSONField(
blank=True,
default=list,
help_text="A list of specific license identifiers derived from statements in the key files of a software project, such as the NOTICE, COPYING, README, and LICENSE files.",
),
),
migrations.AddField(
model_name="package",
name="other_license_detections",
field=models.JSONField(
blank=True,
default=list,
help_text="A list of specific license identifiers derived from the non-key files of a software project, which are very often third-party software used by the project, or test, sample and documentation files.",
),
),
migrations.AddField(
model_name="package",
name="other_license_expression",
field=models.TextField(
blank=True,
help_text="A license expression derived from detected licenses in the non-key files of a software project, which are often third-party software used by the project, or test, sample and documentation files.",
),
),
migrations.AddField(
model_name="package",
name="other_license_expression_spdx",
field=models.TextField(
blank=True,
help_text="A license expression derived from detected licenses in the non-key files of a software project, using the license identifiers defined by SPDX, as well as the “Licenseref” syntax for licenses not on the SPDX list.",
verbose_name="Other license expression SPDX",
),
),
]
66 changes: 66 additions & 0 deletions component_catalog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,70 @@ def compliance_table_class(self):
return "table-warning"


class LicenseFieldsMixin(models.Model):
declared_license_expression = models.TextField(
blank=True,
help_text=_(
"A license expression derived from statements in the key files of a "
"software project, such as the NOTICE, COPYING, README, and LICENSE files."
),
)
declared_license_expression_spdx = models.TextField(
verbose_name=_("Declared license expression SPDX"),
blank=True,
help_text=_(
"A declared license expression that uses the license identifiers defined "
"by SPDX, as well as the “Licenseref” syntax for licenses not on the SPDX "
"list."
),
)
license_detections = models.JSONField(
default=list,
blank=True,
help_text=_(
"A list of specific license identifiers derived from statements in the "
"key files of a software project, such as the NOTICE, COPYING, README, "
"and LICENSE files."
),
)
other_license_expression = models.TextField(
blank=True,
help_text=_(
"A license expression derived from detected licenses in the non-key files "
"of a software project, which are often third-party software used by the "
"project, or test, sample and documentation files."
),
)
other_license_expression_spdx = models.TextField(
verbose_name=_("Other license expression SPDX"),
blank=True,
help_text=_(
"A license expression derived from detected licenses in the non-key files "
"of a software project, using the license identifiers defined by SPDX, "
"as well as the “Licenseref” syntax for licenses not on the SPDX list."
),
)
other_license_detections = models.JSONField(
default=list,
blank=True,
help_text=_(
"A list of specific license identifiers derived from the non-key files "
"of a software project, which are very often third-party software used "
"by the project, or test, sample and documentation files."
),
)
extracted_license_statement = models.TextField(
blank=True,
help_text=_(
"The actual text extracted from a software project that supports the "
"license detection process."
),
)

class Meta:
abstract = True


def get_cyclonedx_properties(instance):
"""
Return fields not supported natively by CycloneDX as properties.
Expand Down Expand Up @@ -819,6 +883,7 @@ class Component(
HolderMixin,
KeywordsMixin,
CPEMixin,
LicenseFieldsMixin,
ParentChildModelMixin,
BaseComponentMixin,
DataspacedModel,
Expand Down Expand Up @@ -1584,6 +1649,7 @@ class Package(
UsagePolicyMixin,
SetPolicyFromLicenseMixin,
LicenseExpressionMixin,
LicenseFieldsMixin,
RequestMixin,
HistoryFieldsMixin,
ReferenceNotesMixin,
Expand Down

0 comments on commit 8fa6df9

Please sign in to comment.