Giter VIP home page Giter VIP logo

cyclonedx-php-library's People

Contributors

dependabot[bot] avatar jkowalleck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cyclonedx-php-library's Issues

DOCS: list supported elements

have a list which XML/JSON properties are supported in the data model and in the serializers.

a list ala

| bom | Cyclonedx\Core\Models\Code |
| bom.component | Cyclonedx\Core\Models\Component |

etc ...

JSON normalizers returns object instead of associative arrays

Json normalizers returns object of stdClass instead of associative arrays

  • therefore revisit the serializes in general and simplify them !

benefit:

  • distinguish key-value stores from lists: lists/sets are arrays, key/value-stores are objects
  • this will help typing a lot !

clean up constructors

the concept of the constructors must be to accept only the mandatory properties of the object.
nothing more.

some model constructors accept unnecessary parameters.
This is to be changed.

perf: get rid of `iterator_to_array`

function a (Foo ...$items ): void { /* ... */}
function b (): Generator { yield new Foo(); }

no longer needed:

a(...iterator_to_array(b()));

can do:

a(...b());

IDEA: external refs selfheal on normalize

instead of throwing an exception if a type of an external reference was not supported, it might help to self-heal and try to use the type "other"
THis way, less information is lost, wen normalizing to a spec that does not support all external-reference-types

component's version is optional

make the component's version an optional propperty. as of SPEC 1.4 the bom.component.version can be omitted entirely.

when rendering/normalizing to XML/JSON: the empty version identifier is to be set as an empty string.

see CycloneDX/specification#90
see https://github.com/CycloneDX/specification/blob/ccbf7b5781ef534cd62616e3c4221004c7c82a66/schema/bom-1.4.schema.json#L266-L269
see https://github.com/CycloneDX/specification/blob/ccbf7b5781ef534cd62616e3c4221004c7c82a66/schema/bom-1.4.xsd#L281-L286

DOCS: gen & publish docs

a config for the phpdoc exists in a working state: phpdoc.dist.xml

when running phpdoc3
the docs are created as expected.

GOAL

  • have docs generated and published somewhere.

possible solution:

generating

hosting


related : https://github.com/CycloneDX/cyclonedx-python-lib/pull/10/files

data models' properties

A core feature of CycloneDX are annotations in the form of properties.
These are free key-value stores, that exist on certain data structures:

Goal:

  • have these new structures implemented and made available on the following existing data modes
  • have XML and JSON normalizer render these new structures
  • have tests for new data structures - 100% coverage -- #232

rename some namespaces

-[x] rename namespace CycloneDX\Core\Serialize to CycloneDX\Core\Serialization
-[x] rename namespace CycloneDX\Core\Validate to CycloneDX\Core\Validation

fix phpmd detections

there are some baselines ...
they need to be addressed. -> fixed or supressed

furthermore:

  • address baseline
  • remove baseline
  • move config to /.phpmd.xml
  • finaly: folder .phpmd was removed`

add pslam shepherd

the projects goal is to provide psalm hints,
and it scans itself during CI rnus.

lets report to shepherd.

we could then put a badge for it in the readme.

list-like are not nullable but empty objects/lists per default

to improve typing, all list-like elements become lists. always.
all map-like become maps. always.
no null values anymore.

motivation: simply call myStructure->get<ListLike>()->append() - no check needed, whether the get<ListLike>() returned null or something ...

this is considered a breaking change, as return types might change.

for renaming, see #66

reduce code duplication

  • have a tool that finds code duplications
  • reduce code duplications (in serializers) by using traits or method inheritances

switch JSON schema validator to 'opis/json-schema'

the decision paper has a section about switching to a better json schema validator, when possible.

this time has come: the schema files were fixed, php7.3 is no longer supported.
let's switched to opis/json-schema for JSON validation

acc / crit:

  • opis/json-schema is used for JSON validation in productive code
  • opis/json-schema is used for JSON validation in tests
  • other json schema validator dependencies were removed
  • updated decision paper describing the terms of the current schema validator, and hint to older version of the document.

❗ currently blocked by CycloneDX/specification#138

[IDEA] DOM normalizer: element names are injectable

current normalizers create elements with hardcoded tagNames.
The tag names are better to be injectable, so the normalizers are reusable.

background: in XML the definitions are applied by inheritance.
Therefore, the point where a definition is applied may decide what the tagName is.

[2021-11-28] drop support of php7.4

on 2022-11-28 the support for php7.4 will end. see https://www.php.net/supported-versions.php

lets take this for a change to switch the min-version of this lib to 8.0 .
see https://www.php.net/manual/en/migration80.new-features.php

so to use the new language features, a breaking change will happen:

  • all of #6
  • drop php7.4 from CI
  • drop php7.4 from composer manifest (php: ^8.0)
  • migrate to php80 via php-cs-fixer
  • remove public use of AbstractDisjunctiveLicense and use correct union type instead. the class is already marked as internal.
  • use union types where needed - so EVERYTHING is properly typed, finally

SBOM JSON result: add `$schema`

requires CycloneDX/specification#106


the current JSON result follows an existing schema, described in https://github.com/CycloneDX/specification/tree/master/schema

feature request: add the used schema as a property $schema of the resulting json.
the value must be the $id of the schema used.

spec schema-id
1.2 http://cyclonedx.org/schema/bom-1.2a.schema.json
1.3 http://cyclonedx.org/schema/bom-1.3.schema.json

example:

{
  "$schema": "http://cyclonedx.org/schema/bom-1.3.schema.json",
  "bomFormat": "CycloneDX",
  "specVersion": "1.3",
  "serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79",
  "version": 1,
  "components": [
    {
      "type": "library",
      "name": "acme-library",
      "version": "1.0.0"
    }
  ]
}

BC: UpperCamelCase enum names

the enum classes became native enums via #140

This means we dont have consts, but cases.
Constants were written in uppercase in the past, which originates to times when here when no IDEs, so people would easily know these were constants not properties ....

this is outdated foo.

Let's rename the cases and user UpperCamelCase for naming conventions.
And while on it, sort them alphabetically.

BC: rename `BOM`

CycloneDX changed since spec V1.3
it is not only a bill of materials, but is a document format for several purposes. See https://cyclonedx.org/capabilities/

Proposal: rename Models\BOM to something else.
name ideas:

  • Models\CycloneData
  • Models\CycloneDocument
  • Models\Document

add support for CDX "vulnerability" features

✋ issue: there is no JSON port for this extension - see CycloneDX/specification#37
🚧 unless we have a valid json schema for it, it is impossible to properly implement for all SBoM results

caused-by: CycloneDX/cyclonedx-php-composer#142

PROPOSAL: rename license-classes to match README

rename some classes so they match the already common names (that are also mentioned in the README alreeady)

  • DisjunctiveLicenseWithName -> NamedLicense
  • DisjunctiveLicenseWithId -> SpdxLicense

rename makeDisjunctiveWithName ??
rename makeDisjunctiveWithId ??

Spec: instances instead of classes for spec versions

currently every spec is an own class. ala class Spec14 implements Spec { }

proposal: have Spec be a class, and have a factory that creates implmentations for 1.4, 1.3, ...
this factory could use waek references, so t can cache already generated instances, without taking up to much memory.

[PHP8.1] use `readonly` properties

currently readonly properties are private, annotated as @readonly and available via a getter.

since php8.1 native support for readonly properties exists.

proposal

  • remove the getter
  • make the property public
  • make the property readonly - via #208

attention

  • there are issues when it comes to modifications in __clone() - -therefore, not fully rolled out
  • there are extended works needed to make the test cases aware ...
  • failed try: #207

assert correct URLs

caused by CycloneDX/cyclonedx-php-composer#158


have all the XML strings that are anyURI somehow fixed before rendering the XML.
affected elements:

  • component.purl
  • license.url
  • externalReterence.url
  • and so on ...

according to XML spec the anyURI needs to conform to https://www.ietf.org/rfc/rfc2396.txt

 * @see http://www.w3.org/TR/xmlschema-2/#anyURI
 * @see http://www.datypic.com/sc/xsd/t-xsd_anyURI.html


    /* URIs require that some characters be escaped with their hexadecimal Unicode code point preceded by the %
     * character. This includes non-ASCII characters and some ASCII characters, namely control characters, spaces,
     * and the following characters (unless they are used as deliimiters in the URI): <>#%{}|\^`.
     * [...]
     * The only values that are not accepted are ones that make inappropriate use of reserved characters, such as ones that contain multiple # characters or have % characters that are not followed by two hexadecimal digits.
     * -- as of http://www.datypic.com/sc/xsd/t-xsd_anyURI.html
     */

make spec 1.4 available

CycloneDX spec 1.4 was released.
lets download the schema files and make them available in this project.

[2021-12-06] drop support of php7.3

on 2021-12-06 the support for php7.3 ended. see https://www.php.net/supported-versions.php

lets take this for a change to switch the min-version of this lib to 7.4 .
see https://www.php.net/manual/en/migration74.new-features.php

so to use the new language features, a breaking change will happen:

  • drop php7.3 from CI
  • drop php7.3 from composer manifest (php: ^7.4)
  • migrate to php74 via php-cs-fixer
  • make class properties type-save
  • bump ergebnis/composer-normalize to a later version that does not need php7.3 - #46
  • review the proposals below

PROPOSAL: remove getters and setters, if a property can be made type safe and converted to public.

PRO

  • less methods to maintain

CON

  • no setters = cannot use chained setters ala $instance->setA(1)->setB(2);

code changes

from

class C {
  /** @var bool */
  private $prop = true;

  /** @return $this */
  public function setProp(bool $prop): self
  {
     $this->prop = $prop;
     return $this;
  }
}

to

class C {
  public bool $prop = true;
}

tests: introduce mutation tests

introduce mutation tests / test mutations

products:

acc / crit

  • have mutation testing avialable -- via #129
  • have mutation testing as part of CI/CT in github pipeline
  • have mutation testing as part of CI/CT in composer test suite
  • have mutation testing passing (no escapes and so on )

rename some stuff

some namespaces and structures can be renamed
as the actual usage showed that they are either wrong, or impractical or to long,or there are just other options with more actual meaning

see also: #5

namespaces

  • Repositories -> Collections as it contains maps, dictionaries and repositories

classes/interfaces

  • MetaData -> Metadata
  • HashRepository -> HashDictionary
  • ValidatorInterface -> Validator
  • Spdx\License -> Spdx\LicenseValidator
  • SerializerInterface -> Serializer

methods

  • {get,set}ComponentRepository() -> {get,set}Components()
  • {get,set}ExternalReferenceRepository() -> {get,set}ExternalReferences()
  • {get,set}HashRepository() -> {get,set}Hashes()
  • {get,set}DependenciesBomRefRepository() -> {get,set}Dependencies()
  • {get,set}MetaData() -> {get,set}Metadata()
  • all commection's methods should be streamlined to {add/get}Items instead of diffferent add<SomeItemType>

overall

  • every ocurrence of [mM]etaData with a capital "D' -> [mM]etadata (small "d")

rework serializers

current serializers generate the normalizers on their own.
but the normalizers should be injectable, so others can modify the normliazed output, before normalizing

support CycloneDX 1.5

CycloneDX spec v1.5 is in the making.
When it is final, it should be supported by the next upcoming major version of this library.

Implementations will require to interfaces and base implementation API, which results in breaking changes.

remove authors

nobody cares for the authors, as long as the commiter gave consent to the current cproject's license agreement.

so remove all the @author remarks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.