Skip to content

Commit

Permalink
Added license headers to all source files. Added classifiers for Pyth…
Browse files Browse the repository at this point in the history
…on version to setup.py.
  • Loading branch information
madpah committed Sep 6, 2021
1 parent 03d03ed commit bb6bb24
Show file tree
Hide file tree
Showing 20 changed files with 316 additions and 10 deletions.
Empty file removed cyclonedx/generator.py
Empty file.
16 changes: 16 additions & 0 deletions cyclonedx/model/bom.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import datetime
from typing import List
from uuid import uuid4
Expand Down
30 changes: 30 additions & 0 deletions cyclonedx/model/component.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

from enum import Enum

PURL_TYPE_PREFIX = 'pypi'
Expand Down Expand Up @@ -28,6 +44,8 @@ class Component:
_qualifiers: str

_author: str = None
_description: str = None
_license: str = None

def __init__(self, name: str, version: str, qualifiers: str = None,
component_type: ComponentType = ComponentType.LIBRARY):
Expand All @@ -39,6 +57,12 @@ def __init__(self, name: str, version: str, qualifiers: str = None,
def get_author(self) -> str:
return self._author

def get_description(self) -> str:
return self._description

def get_license(self) -> str:
return self._license

def get_name(self) -> str:
return self._name

Expand All @@ -57,6 +81,12 @@ def get_version(self) -> str:
def set_author(self, author: str):
self._author = author

def set_description(self, description: str):
self._description = description

def set_license(self, license_str: str):
self._license = license_str

def __eq__(self, other):
return other.get_purl() == self.get_purl()

Expand Down
17 changes: 16 additions & 1 deletion cyclonedx/output/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
import importlib
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import importlib
from abc import ABC, abstractmethod
from enum import Enum

Expand Down
16 changes: 16 additions & 0 deletions cyclonedx/output/json.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import json

from . import BaseOutput
Expand Down
16 changes: 16 additions & 0 deletions cyclonedx/output/schema.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

from abc import ABC


Expand Down
16 changes: 16 additions & 0 deletions cyclonedx/output/xml.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

from xml.etree import ElementTree

from . import BaseOutput
Expand Down
16 changes: 16 additions & 0 deletions cyclonedx/parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

from abc import ABC
from typing import List

Expand Down
22 changes: 21 additions & 1 deletion cyclonedx/parser/environment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import sys

if sys.version_info >= (3, 8, 0):
Expand Down Expand Up @@ -25,8 +41,12 @@ def __init__(self):
c = Component(name=i.project_name, version=i.version)

i_metadata = self._get_metadata_for_package(i.project_name)
print(i_metadata.keys())
if 'Author' in i_metadata.keys():
c.set_author(i_metadata.get('Author'))
c.set_author(author=i_metadata.get('Author'))

if 'License' in i_metadata.keys():
c.set_license(license_str=i_metadata.get('License'))

self._components.append(c)

Expand Down
17 changes: 16 additions & 1 deletion cyclonedx/parser/requirements.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import pkg_resources

from . import BaseParser

from ..model.component import Component


Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
keywords=["BOM", "SBOM", "SCA", "OWASP"],
license="Apache-2.0",
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: Legal Industry',
Expand All @@ -26,7 +27,10 @@
'Topic :: Software Development',
'Topic :: System :: Software Distribution',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3'
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'
],
packages=find_packages(),
python_requires='>=3.6',
Expand Down
19 changes: 17 additions & 2 deletions tests/base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
import xml.etree.ElementTree
from unittest import TestCase
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import json
import xml.etree.ElementTree
from datetime import datetime, timezone
from unittest import TestCase
from uuid import uuid4
from xml.dom import minidom

Expand Down
17 changes: 16 additions & 1 deletion tests/test_bom.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
from unittest import TestCase
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import os
from unittest import TestCase

from cyclonedx.model.bom import Bom
from cyclonedx.model.component import Component
Expand Down
19 changes: 18 additions & 1 deletion tests/test_component.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

from unittest import TestCase

from cyclonedx.model.component import Component
from packageurl import PackageURL

from cyclonedx.model.component import Component


class TestComponent(TestCase):
_component: Component
Expand Down
16 changes: 16 additions & 0 deletions tests/test_e2e_environment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import json
from unittest import TestCase
from xml.etree import ElementTree
Expand Down
16 changes: 16 additions & 0 deletions tests/test_output_generic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

from unittest import TestCase

from cyclonedx.output import get_instance, OutputFormat, SchemaVersion
Expand Down
18 changes: 17 additions & 1 deletion tests/test_output_json.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# encoding: utf-8

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

from os.path import dirname, join
from tests.base import BaseJsonTestCase

from cyclonedx.model.bom import Bom
from cyclonedx.model.component import Component
from cyclonedx.output import get_instance, OutputFormat, SchemaVersion
from cyclonedx.output.json import JsonV1Dot3, JsonV1Dot2
from tests.base import BaseJsonTestCase


class TestOutputJson(BaseJsonTestCase):
Expand Down
Loading

0 comments on commit bb6bb24

Please sign in to comment.