Skip to content

Commit 82d9770

Browse files
authored
Generate dash input as clearlydefined bom (#24)
* Generate dash input as clearlydefined bom
1 parent b24cc2b commit 82d9770

18 files changed

+345
-46
lines changed

.devcontainer/Dockerfile

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# /********************************************************************************
2-
# * Copyright (c) 2022 Contributors to the Eclipse Foundation
2+
# * Copyright (c) 2022-2023 Contributors to the Eclipse Foundation
33
# *
44
# * See the NOTICE file(s) distributed with this work for additional
55
# * information regarding copyright ownership.
@@ -22,7 +22,7 @@ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/
2222

2323
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
2424
COPY ./src/requirements.txt /tmp/pip-tmp/
25-
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
25+
RUN pip3 install --upgrade pip && pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
2626
&& rm -rf /tmp/pip-tmp
2727

2828
# [Optional] Uncomment this section to install additional OS packages.
@@ -35,3 +35,8 @@ RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requ
3535
RUN apt-get update && apt-get install -y ruby && gem install license_finder && gembin=`(gem env | sed -n "s/.*EXECUTABLE DIRECTORY: \(.*\)/\1/p")` && export PATH=$gembin:$PATH
3636

3737
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y
38+
39+
# Enable proxy, if set in local environment
40+
COPY ./.devcontainer/scripts/*.sh /tmp/script/
41+
RUN find /tmp/script/ -type f -iname "*.sh" -exec chmod +x {} \;
42+
RUN /bin/bash /tmp/script/configure-proxies.sh

.devcontainer/devcontainer.json

+28-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// /********************************************************************************
2-
// * Copyright (c) 2022 Contributors to the Eclipse Foundation
2+
// * Copyright (c) 2022-2023 Contributors to the Eclipse Foundation
33
// *
44
// * See the NOTICE file(s) distributed with this work for additional
55
// * information regarding copyright ownership.
@@ -26,31 +26,35 @@
2626
"NODE_VERSION": "lts/*"
2727
}
2828
},
29+
30+
"customizations": {
31+
"vscode": {
32+
// Set *default* container specific settings.json values on container create.
33+
"settings": {
34+
"python.defaultInterpreterPath": "/usr/local/bin/python",
35+
"python.linting.enabled": true,
36+
"python.linting.pylintEnabled": true,
37+
"python.formatting.provider": "black",
38+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
39+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
40+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
41+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
42+
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
43+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
44+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
45+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
46+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
47+
},
2948

30-
// Set *default* container specific settings.json values on container create.
31-
"settings": {
32-
"python.defaultInterpreterPath": "/usr/local/bin/python",
33-
"python.linting.enabled": true,
34-
"python.linting.pylintEnabled": true,
35-
"python.formatting.provider": "black",
36-
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
37-
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
38-
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
39-
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
40-
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
41-
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
42-
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
43-
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
44-
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
49+
// Add the IDs of extensions you want installed when the container is created.
50+
"extensions": [
51+
"ms-python.python",
52+
"ms-python.vscode-pylance",
53+
"njpwerner.autodocstring"
54+
]
55+
}
4556
},
4657

47-
// Add the IDs of extensions you want installed when the container is created.
48-
"extensions": [
49-
"ms-python.python",
50-
"ms-python.vscode-pylance",
51-
"njpwerner.autodocstring"
52-
],
53-
5458
// Use 'forwardPorts' to make a list of ports inside the container available locally.
5559
// "forwardPorts": [],
5660

@@ -60,6 +64,6 @@
6064
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
6165
"remoteUser": "vscode",
6266
"features": {
63-
"docker-in-docker": "latest"
67+
"ghcr.io/devcontainers/features/docker-in-docker:2.1.0": {}
6468
}
6569
}
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
# Copyright (c) 2023 Robert Bosch GmbH and Microsoft Corporation
3+
#
4+
# This program and the accompanying materials are made available under the
5+
# terms of the Apache License, Version 2.0 which is available at
6+
# https://www.apache.org/licenses/LICENSE-2.0.
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
#
14+
# SPDX-License-Identifier: Apache-2.0
15+
16+
echo "#######################################################"
17+
echo "### Configure-proxies ###"
18+
echo "#######################################################"
19+
20+
if [ "$HTTP_PROXY" != "" ]; then
21+
USE_PROXIES="true"
22+
CONFIGURE_GIT="true"
23+
CONFIGURE_DOCKER_IN_DOCKER_PROXY="true"
24+
FTP_PROXY=$HTTP_PROXY
25+
ALL_PROXY=$HTTP_PROXY
26+
NO_PROXY="localhost,127.0.0.1,0.0.0.0,10.0.0.0/8,192.168.122.0/24,172.0.0.0/8,cattle-system.svc,.svc,.cluster.local"
27+
fi
28+
29+
echo "Use proxies: $USE_PROXIES"
30+
echo "Http-proxy: $HTTP_PROXY"
31+
echo "Https-proxy: $HTTPS_PROXY"
32+
echo "Ftp-proxy: $FTP_PROXY"
33+
echo "All proxy: $ALL_PROXY"
34+
echo "No proxy: $NO_PROXY"
35+
echo "Configure git: $CONFIGURE_GIT"
36+
37+
set -e
38+
39+
if [ "$(id -u)" -ne 0 ]; then
40+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
41+
exit 1
42+
fi
43+
44+
# Determine the appropriate non-root user
45+
# This recognizes the same possible user names found in Microsoft base Docker images
46+
# as the scripts in the ../library-scripts directory
47+
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
48+
USERNAME=""
49+
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
50+
for CURRENT_USER in ${POSSIBLE_USERS[@]}; do
51+
if id -u ${CURRENT_USER} > /dev/null 2>&1; then
52+
USERNAME=${CURRENT_USER}
53+
break
54+
fi
55+
done
56+
elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
57+
USERNAME=root
58+
fi
59+
60+
if [ "${USERNAME}" = "" ]; then
61+
USERNAME=vscode
62+
fi
63+
echo "Selected user name is ${USERNAME}"
64+
65+
if [ "${USE_PROXIES}" = "true" ]; then
66+
echo "Configuring proxies"
67+
68+
mkdir -p /home/${USERNAME}
69+
echo "export HTTP_PROXY=\"${HTTP_PROXY}\"" >> /home/${USERNAME}/.profile
70+
echo "export http_proxy=\"${HTTP_PROXY}\"" >> /home/${USERNAME}/.profile
71+
echo "export HTTPS_PROXY=\"${HTTPS_PROXY}\"" >> /home/${USERNAME}/.profile
72+
echo "export https_proxy=\"${HTTPS_PROXY}\"" >> /home/${USERNAME}/.profile
73+
echo "export FTP_PROXY=\"${FTP_PROXY}\"" >> /home/${USERNAME}/.profile
74+
echo "export ftp_proxy=\"${FTP_PROXY}\"" >> /home/${USERNAME}/.profile
75+
echo "export ALL_PROXY=\"${ALL_PROXY}\"" >> /home/${USERNAME}/.profile
76+
echo "export all_proxy=\"${ALL_PROXY}\"" >> /home/${USERNAME}/.profile
77+
echo "export NO_PROXY=\"${NO_PROXY}\"" >> /home/${USERNAME}/.profile
78+
echo "export no_proxy=\"${NO_PROXY}\"" >> /home/${USERNAME}/.profile
79+
80+
echo "# Proxy settings" >> /etc/wgetrc
81+
echo "http_proxy=${HTTP_PROXY}" >> /etc/wgetrc
82+
echo "https_proxy=${HTTPS_PROXY}" >> /etc/wgetrc
83+
echo "ftp_proxy=${FTP_PROXY}" >> /etc/wgetrc
84+
echo "no_proxy=${NO_PROXY}" >> /etc/wgetrc
85+
echo "use_proxy=on" >> /etc/wgetrc
86+
87+
# enable root user to "apt-get" via proxy
88+
echo "Acquire::http::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf
89+
echo "Acquire::https::proxy \"${HTTPS_PROXY}\";" >> /etc/apt/apt.conf
90+
fi
91+
92+
exit 0

.gitattributes

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Automatically normalize line endings for all text-based files
2+
# http://git-scm.com/docs/gitattributes#_end_of_line_conversion
3+
* text=auto
4+
5+
# For the following file types, normalize line endings to LF on
6+
# checkin and prevent conversion to CRLF when they are checked out
7+
# (this is required in order to prevent newline related issues like,
8+
# for example, after the build script is run)
9+
.* text eol=lf
10+
*.css text eol=lf
11+
*.html text eol=lf
12+
*.js text eol=lf
13+
*.json text eol=lf
14+
*.md text eol=lf
15+
*.sh text eol=lf
16+
*.txt text eol=lf
17+
*.xml text eol=lf
18+
19+
# Source files
20+
# ============
21+
*.pxd text diff=python
22+
*.py text diff=python
23+
*.py3 text diff=python
24+
*.pyw text diff=python
25+
*.pyx text diff=python
26+
*.pyz text diff=python
27+
*.pyi text diff=python
28+
29+
# Binary files
30+
# ============
31+
*.db binary
32+
*.p binary
33+
*.pkl binary
34+
*.pickle binary
35+
*.pyc binary export-ignore
36+
*.pyo binary export-ignore
37+
*.pyd binary
38+
39+
# Jupyter notebook
40+
*.ipynb text
41+
42+
# Note: .db, .p, and .pkl files are associated
43+
# with the python modules ``pickle``, ``dbm.*``,
44+
# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
45+
# (among others).

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
.DS_Store
1515
NOTICE-GENERATED.md
16+
clearlydefined.input
1617
**/dependency_decisions.yml
1718

1819
# Python related

.pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ indent-after-paren=4
440440
indent-string=' '
441441

442442
# Maximum number of characters on a single line.
443-
max-line-length=100
443+
max-line-length=120
444444

445445
# Maximum number of lines in a module.
446446
max-module-lines=1000

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"."
1616
],
1717
"python.testing.unittestEnabled": false,
18-
"python.testing.pytestEnabled": true
18+
"python.testing.pytestEnabled": true,
19+
"editor.rulers": [120]
1920
}

NOTICE-3RD-PARTY-CONTENT.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
|PyYAML|6.0|MIT|
1212
|requests|2.28.2|Apache 2.0|
1313
|smmap|5.0.0|BSD|
14+
|str2bool|1.1|BSD|
1415
|urllib3|1.26.15|MIT|
1516
## Workflows
1617
| Dependency | Version | License |

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Shall the action fail if a license violation is detected? Default `false`
2828

2929
**Required** Path to the config file for the license checker.
3030

31+
### `generate-dash`
32+
33+
This option enables the capability to generate the input file for [Eclipse Dash License Tool](https://github.com/eclipse/dash-licenses) based on `NOTICE-3RD-PARTY-CONTENT` file in ClearlyDefined format based on [ClearDefined Schema](https://docs.clearlydefined.io/using-data).
34+
3135
## Config file syntax
3236

3337
### `whitelist-file-path` (string)

action.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# /********************************************************************************
2-
# * Copyright (c) 2022 Contributors to the Eclipse Foundation
2+
# * Copyright (c) 2022-2023 Contributors to the Eclipse Foundation
33
# *
44
# * See the NOTICE file(s) distributed with this work for additional
55
# * information regarding copyright ownership.
@@ -29,6 +29,10 @@ inputs:
2929
github-token:
3030
description: GitHub token to overcome API rate limiting
3131
default: ${{ github.token }}
32+
generate-dash:
33+
description: Generate clearlydefined.input based on ClearDefined Scheme
34+
required: false
35+
default: false
3236

3337
runs:
3438
using: 'docker'
@@ -40,3 +44,4 @@ runs:
4044
- ${{ inputs.config-file-path }}
4145
- '--github-token'
4246
- ${{ inputs.github-token }}
47+
- ${{ inputs.generate-dash }}

run-container.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright (c) 2022 Contributors to the Eclipse Foundation
2+
# Copyright (c) 2022-2023 Contributors to the Eclipse Foundation
33
#
44
# This program and the accompanying materials are made available under the
55
# terms of the Apache License, Version 2.0 which is available at
@@ -15,5 +15,9 @@
1515

1616
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
1717

18-
docker build . -t license-checker:latest && docker run --workdir /github/workspace -v "${SCRIPT_DIR}/testbench/multilang":"/github/workspace" --rm license-checker:latest \
19-
"true" "NOTICE-GENERATED" false ".lc.config.yml"
18+
docker build . \
19+
-t license-checker:latest && \
20+
docker run --workdir /github/workspace \
21+
-v "${SCRIPT_DIR}/testbench/multilang":"/github/workspace" \
22+
--rm license-checker:latest \
23+
"true" "NOTICE-GENERATED" false ".lc.config.yml" true

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
long_description=long_description,
1111
long_description_content_type="text/markdown",
1212
url="https://github.com/eclipse-velocitas/license-check",
13-
packages=["licensevalidator", "licensevalidator.lib"],
13+
packages=["licensevalidator", "licensevalidator.lib", "dash"],
1414
package_data={"licensevalidator": ["py.typed"]},
1515
include_package_data=True,
1616
install_requires=[],

0 commit comments

Comments
 (0)