Ejemplo n.º 1
0
class LicenseScanDetails(jsl.Document):
    class Options(object):
        definition_id = "license_scan_details"
        additional_properties = True

    with removed_in(ROLE_v3_0_0) as removed_in_v3_0_0:
        removed_in_v3_0_0.files = jsl.ArrayField(
            jsl.DocumentField(FileDetails, as_ref=True))
        removed_in_v3_0_0.license_stats = jsl.ArrayField(
            jsl.DocumentField(LicenseDetailsPre30, as_ref=True))
        removed_in_v3_0_0.oslc_stats = jsl.DocumentField(OSLCStats,
                                                         as_ref=True)

    with added_in(ROLE_v3_0_0) as added_in_v3_0_0:
        added_in_v3_0_0.files_count = jsl.IntField(required=True)
        added_in_v3_0_0.licenses = jsl.DictField(pattern_properties=jsl.Var({
            'role': {
                '*': jsl.DocumentField(LicenseDetails,
                                       as_ref=True,
                                       required=True),
            }
        }),
                                                 required=True)
        added_in_v3_0_0.scancode_notice = jsl.StringField(required=True)
        added_in_v3_0_0.scancode_version = jsl.StringField(required=True)
class ComponentAnalysis(JSLSchemaBaseWithRelease):
    class Options(object):
        definition_id = "component_analysis"
        description = "Software component analysis"

    ecosystem = jsl.StringField(
        description="Language ecosystem providing the component",
        required=True)
    package = jsl.StringField(description="Component name", required=True)
    version = jsl.StringField(description="Component version", required=True)
    latest_version = jsl.OneOfField(
        [jsl.StringField(), jsl.NullField()],
        description=
        "Latest version available of this component (null if unknown)",
        required=True)
    started_at = jsl.DateTimeField(
        description="Date/time component analysis was started", required=True)
    finished_at = jsl.DateTimeField(
        description="Date/time component analysis was finished", required=True)
    access_count = jsl.NumberField(
        description="Number of times this component has been queried",
        required=True)
    dependents_count = jsl.Var({
        lambda v: v >= ROLE_v1_1_0:
        jsl.NumberField(description="Number of dependent GitHub projects",
                        required=True)
    })

    analyses = jsl.DocumentField(AnalysisSet, as_ref=True, required=True)
    package_info = jsl.DictField(
        description="Additional information related to the package",
        additional_properties=True,
        required=False)
class AnalysisSet(jsl.Document):
    class Options(object):
        definition_id = "analysis_set"
        description = "Set of named component analyses"

    digests = jsl.DictField(additional_properties=True)
    security_issues = jsl.DictField(additional_properties=True)
    source_licenses = jsl.DictField(additional_properties=True)
    crypto_algorithms = jsl.DictField(additional_properties=True)
    languages = jsl.DictField(additional_properties=True)
    binary_data = jsl.DictField(additional_properties=True)
    static_analysis = jsl.DictField(additional_properties=True)
    metadata = jsl.DictField(additional_properties=True)
    github_details = jsl.DictField(additional_properties=True)
    redhat_downstream = jsl.DictField(additional_properties=True)
    blackduck = jsl.Var({
        lambda v: v == ROLE_v1_0_1 or v >= ROLE_v1_1_1:
        jsl.DictField(additional_properties=True)
    })
    with jsl.Scope(lambda v: v >= ROLE_v1_1_2) as added_in_v1_1_2:
        added_in_v1_1_2.dependency_snapshot = jsl.DictField(
            additional_properties=True)
    with jsl.Scope(lambda v: v >= ROLE_v1_1_3) as added_in_v1_1_3:
        added_in_v1_1_3.code_metrics = jsl.DictField(
            additional_properties=True)
Ejemplo n.º 4
0
 def __init__(
         self,
         name='_link_',
         pattern=jsl.
     Var({
         DocumentRole:
         r"^(({URL})|(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}))(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?$"
     }),
         format=jsl.Var({jsl.not_(DocumentRole): 'uri'}),
         max_length=512,
         min_length=None,
         **kwargs):
     super(LinkField, self).__init__(name=name,
                                     pattern=pattern,
                                     format=format,
                                     max_length=max_length,
                                     min_lenght=min_length,
                                     **kwargs)
Ejemplo n.º 5
0
    ROLE_v2_1_0: "Package Metadata v2-1-0",
    ROLE_v2_1_1: "Package Metadata v2-1-1",
    # switching to mercator-go
    ROLE_v3_0_0: "Package Metadata v3-0-0",
    # Make code repository type field optional
    ROLE_v3_0_1: "Package Metadata v3-0-1",
    # Add 'status' and 'summary'
    ROLE_v3_1_0: "Package Metadata v3-1-0",
    # Add 'path', optional
    ROLE_v3_1_1: "Package Metadata v3-1-0",
    # declared_license (str) -> declared_licenses (list)
    ROLE_v3_2_0: "Package Metadata v3-2-0",
})

_type_field_required = jsl.Var(
    [(lambda r: r >= ROLE_v3_0_1, False)],
    default=True
)


class CodeRepository(jsl.Document):
    """JSL schema for code repository description."""

    class Options(object):
        """JSL schema for code repository description."""

        definition_id = "metadata_code_repository"
        description = "Code repository description"

    type = jsl.StringField(required=_type_field_required)
    url = jsl.StringField(required=True)
Ejemplo n.º 6
0
import jsl

from concur.constants import ROLES

# common JSL variables
true_if_creator = jsl.Var({ROLES.CREATOR: True})


class Document(jsl.Document):
    pass


class User(Document):
    email = jsl.EmailField(required=true_if_creator)
    password = jsl.StringField(required=true_if_creator)


class Option(Document):
    text = jsl.StringField(required=true_if_creator)


class Poll(Document):
    prompt = jsl.StringField(required=true_if_creator)
    options = jsl.ArrayField(items=jsl.DocumentField(Option),
                             required=true_if_creator,
                             min_items=2)


class Vote(Document):
    option_id = jsl.StringField(required=true_if_creator)
    is_public = jsl.BooleanField(required=False)