Skip to content

Commit b7bac63

Browse files
committed
Initial commit
0 parents  commit b7bac63

File tree

390 files changed

+46693
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

390 files changed

+46693
-0
lines changed

.devcontainer/Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.202.1/containers/dotnet/.devcontainer/base.Dockerfile
2+
3+
# [Choice] .NET version: 6.0, 5.0, 3.1, 2.1
4+
ARG VARIANT="6.0"
5+
#FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}
6+
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:dev-6.0
7+
8+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
9+
ARG NODE_VERSION="none"
10+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
11+
12+
# [Option] Install Azure CLI
13+
ARG INSTALL_AZURE_CLI="false"
14+
COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/
15+
RUN if [ "$INSTALL_AZURE_CLI" = "true" ]; then bash /tmp/library-scripts/azcli-debian.sh; fi \
16+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
17+
18+
# [Optional] Uncomment this section to install additional OS packages.
19+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
20+
# && apt-get -y install --no-install-recommends <your-package-list-here>
21+
22+
# [Optional] Uncomment this line to install global node packages.
23+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/devcontainer.json

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.1/containers/dotnet
3+
{
4+
"name": "C# (.NET)",
5+
"runArgs": ["--init"],
6+
"build": {
7+
"dockerfile": "Dockerfile",
8+
"args": {
9+
// Update 'VARIANT' to pick a .NET Core version: 2.1, 3.1, 5.0, 6.0
10+
"VARIANT": "6.0",
11+
// Options
12+
"NODE_VERSION": "lts/*",
13+
"INSTALL_AZURE_CLI": "false"
14+
}
15+
},
16+
17+
// Set *default* container specific settings.json values on container create.
18+
"settings": {},
19+
20+
// Add the IDs of extensions you want installed when the container is created.
21+
"extensions": [
22+
"ms-dotnettools.csharp",
23+
"vsls-contrib.codetour"
24+
],
25+
26+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
27+
// "forwardPorts": [5000, 5001],
28+
29+
// [Optional] To reuse of your local HTTPS dev cert:
30+
//
31+
// 1. Export it locally using this command:
32+
// * Windows PowerShell:
33+
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
34+
// * macOS/Linux terminal:
35+
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
36+
//
37+
// 2. Uncomment these 'remoteEnv' lines:
38+
// "remoteEnv": {
39+
// "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere",
40+
// "ASPNETCORE_Kestrel__Certificates__Default__Path": "/home/vscode/.aspnet/https/aspnetapp.pfx",
41+
// },
42+
//
43+
// 3. Do one of the following depending on your scenario:
44+
// * When using GitHub Codespaces and/or Remote - Containers:
45+
// 1. Start the container
46+
// 2. Drag ~/.aspnet/https/aspnetapp.pfx into the root of the file explorer
47+
// 3. Open a terminal in VS Code and run "mkdir -p /home/vscode/.aspnet/https && mv aspnetapp.pfx /home/vscode/.aspnet/https"
48+
//
49+
// * If only using Remote - Containers with a local container, uncomment this line instead:
50+
// "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ],
51+
52+
// Use 'postCreateCommand' to run commands after the container is created.
53+
"postCreateCommand": "dotnet restore",
54+
55+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
56+
// "remoteUser": "vscode",
57+
"features": {
58+
"docker-from-docker": "latest", // This enables the linux detector
59+
// "git": "latest",
60+
// "github-cli": "latest",
61+
// "python": "latest",
62+
// "golang": "latest",
63+
// "java": "lts"
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
#!/usr/bin/env bash
2+
#-------------------------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
5+
#-------------------------------------------------------------------------------------------------------------
6+
#
7+
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/azcli.md
8+
# Maintainer: The VS Code and Codespaces Teams
9+
#
10+
# Syntax: ./azcli-debian.sh
11+
12+
set -e
13+
14+
AZ_VERSION=${1:-"latest"}
15+
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
16+
AZCLI_ARCHIVE_ARCHITECTURES="amd64"
17+
AZCLI_ARCHIVE_VERSION_CODENAMES="stretch buster bullseye bionic focal"
18+
19+
if [ "$(id -u)" -ne 0 ]; then
20+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
21+
exit 1
22+
fi
23+
24+
# Get central common setting
25+
get_common_setting() {
26+
if [ "${common_settings_file_loaded}" != "true" ]; then
27+
curl -sfL "https://aka.ms/vscode-dev-containers/script-library/settings.env" 2>/dev/null -o /tmp/vsdc-settings.env || echo "Could not download settings file. Skipping."
28+
common_settings_file_loaded=true
29+
fi
30+
if [ -f "/tmp/vsdc-settings.env" ]; then
31+
local multi_line=""
32+
if [ "$2" = "true" ]; then multi_line="-z"; fi
33+
local result="$(grep ${multi_line} -oP "$1=\"?\K[^\"]+" /tmp/vsdc-settings.env | tr -d '\0')"
34+
if [ ! -z "${result}" ]; then declare -g $1="${result}"; fi
35+
fi
36+
echo "$1=${!1}"
37+
}
38+
39+
# Function to run apt-get if needed
40+
apt_get_update_if_needed()
41+
{
42+
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
43+
echo "Running apt-get update..."
44+
apt-get update
45+
else
46+
echo "Skipping apt-get update."
47+
fi
48+
}
49+
50+
# Checks if packages are installed and installs them if not
51+
check_packages() {
52+
if ! dpkg -s "$@" > /dev/null 2>&1; then
53+
apt_get_update_if_needed
54+
apt-get -y install --no-install-recommends "$@"
55+
fi
56+
}
57+
58+
export DEBIAN_FRONTEND=noninteractive
59+
60+
# Soft version matching that resolves a version for a given package in the *current apt-cache*
61+
# Return value is stored in first argument (the unprocessed version)
62+
apt_cache_version_soft_match() {
63+
64+
# Version
65+
local variable_name="$1"
66+
local requested_version=${!variable_name}
67+
# Package Name
68+
local package_name="$2"
69+
# Exit on no match?
70+
local exit_on_no_match="${3:-true}"
71+
72+
# Ensure we've exported useful variables
73+
. /etc/os-release
74+
local architecture="$(dpkg --print-architecture)"
75+
76+
dot_escaped="${requested_version//./\\.}"
77+
dot_plus_escaped="${dot_escaped//+/\\+}"
78+
# Regex needs to handle debian package version number format: https://www.systutorials.com/docs/linux/man/5-deb-version/
79+
version_regex="^(.+:)?${dot_plus_escaped}([\\.\\+ ~:-]|$)"
80+
set +e # Don't exit if finding version fails - handle gracefully
81+
fuzzy_version="$(apt-cache madison ${package_name} | awk -F"|" '{print $2}' | sed -e 's/^[ \t]*//' | grep -E -m 1 "${version_regex}")"
82+
set -e
83+
if [ -z "${fuzzy_version}" ]; then
84+
echo "(!) No full or partial for package \"${package_name}\" match found in apt-cache for \"${requested_version}\" on OS ${ID} ${VERSION_CODENAME} (${architecture})."
85+
86+
if $exit_on_no_match; then
87+
echo "Available versions:"
88+
apt-cache madison ${package_name} | awk -F"|" '{print $2}' | grep -oP '^(.+:)?\K.+'
89+
exit 1 # Fail entire script
90+
else
91+
echo "Continuing to fallback method (if available)"
92+
return 1;
93+
fi
94+
fi
95+
96+
# Globally assign fuzzy_version to this value
97+
# Use this value as the return value of this function
98+
declare -g ${variable_name}="=${fuzzy_version}"
99+
echo "${variable_name} ${!variable_name}"
100+
}
101+
102+
install_using_apt() {
103+
# Install dependencies
104+
check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr
105+
# Import key safely (new 'signed-by' method rather than deprecated apt-key approach) and install
106+
get_common_setting MICROSOFT_GPG_KEYS_URI
107+
curl -sSL ${MICROSOFT_GPG_KEYS_URI} | gpg --dearmor > /usr/share/keyrings/microsoft-archive-keyring.gpg
108+
echo "deb [arch=${architecture} signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/azure-cli/ ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/azure-cli.list
109+
apt-get update
110+
111+
if [ "${AZ_VERSION}" = "latest" ] || [ "${AZ_VERSION}" = "lts" ] || [ "${AZ_VERSION}" = "stable" ]; then
112+
# Empty, meaning grab the "latest" in the apt repo
113+
AZ_VERSION=""
114+
else
115+
# Sets AZ_VERSION to our desired version, if match found.
116+
apt_cache_version_soft_match AZ_VERSION "azure-cli" false
117+
if [ "$?" != 0 ]; then
118+
return 1
119+
fi
120+
fi
121+
122+
if ! (apt-get install -yq azure-cli${AZ_VERSION}); then
123+
rm -f /etc/apt/sources.list.d/azure-cli.list
124+
return 1
125+
fi
126+
}
127+
128+
install_using_pip() {
129+
echo "(*) No pre-built binaries available in apt-cache. Installing via pip3."
130+
if ! dpkg -s python3-minimal python3-pip libffi-dev python3-venv > /dev/null 2>&1; then
131+
apt_get_update_if_needed
132+
apt-get -y install python3-minimal python3-pip libffi-dev python3-venv
133+
fi
134+
export PIPX_HOME=/usr/local/pipx
135+
mkdir -p ${PIPX_HOME}
136+
export PIPX_BIN_DIR=/usr/local/bin
137+
export PYTHONUSERBASE=/tmp/pip-tmp
138+
export PIP_CACHE_DIR=/tmp/pip-tmp/cache
139+
pipx_bin=pipx
140+
if ! type pipx > /dev/null 2>&1; then
141+
pip3 install --disable-pip-version-check --no-cache-dir --user pipx
142+
pipx_bin=/tmp/pip-tmp/bin/pipx
143+
fi
144+
145+
if [ "${AZ_VERSION}" = "latest" ] || [ "${AZ_VERSION}" = "lts" ] || [ "${AZ_VERSION}" = "stable" ]; then
146+
# Empty, meaning grab the "latest" in the apt repo
147+
ver=""
148+
else
149+
ver="==${AZ_VERSION}"
150+
fi
151+
152+
set +e
153+
${pipx_bin} install --system-site-packages --pip-args '--no-cache-dir --force-reinstall' -f azure-cli${ver}
154+
155+
# Fail gracefully
156+
if [ "$?" != 0 ]; then
157+
echo "Could not install azure-cli${ver} via pip"
158+
rm -rf /tmp/pip-tmp
159+
return 1
160+
fi
161+
set -e
162+
}
163+
164+
# See if we're on x86_64 and if so, install via apt-get, otherwise use pip3
165+
echo "(*) Installing Azure CLI..."
166+
. /etc/os-release
167+
architecture="$(dpkg --print-architecture)"
168+
if [[ "${AZCLI_ARCHIVE_ARCHITECTURES}" = *"${architecture}"* ]] && [[ "${AZCLI_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]]; then
169+
install_using_apt || use_pip="true"
170+
else
171+
use_pip="true"
172+
fi
173+
174+
if [ "${use_pip}" = "true" ]; then
175+
install_using_pip
176+
177+
if [ "$?" != 0 ]; then
178+
echo "Please provide a valid version for your distribution ${ID} ${VERSION_CODENAME} (${architecture})."
179+
echo
180+
echo "Valid versions in current apt-cache"
181+
apt-cache madison azure-cli | awk -F"|" '{print $2}' | grep -oP '^(.+:)?\K.+'
182+
exit 1
183+
fi
184+
fi
185+
186+
echo "Done!"

.gitattributes

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
*.sh text eol=lf
6+
package-lock.json text eol=lf
7+
package.json text eol=lf
8+
resources.resjson text eol=lf
9+
task.loc.json text eol=lf
10+
task.json text eol=lf
11+
12+
###############################################################################
13+
# Set default behavior for command prompt diff.
14+
#
15+
# This is need for earlier builds of msysgit that does not have it on by
16+
# default for csharp files.
17+
# Note: This is only used by command line
18+
###############################################################################
19+
#*.cs diff=csharp
20+
21+
###############################################################################
22+
# Set the merge driver for project and solution files
23+
#
24+
# Merging from the command prompt will add diff markers to the files if there
25+
# are conflicts (Merging from VS is not affected by the settings below, in VS
26+
# the diff markers are never inserted). Diff markers may cause the following
27+
# file extensions to fail to load in VS. An alternative would be to treat
28+
# these files as binary and thus will always conflict and require user
29+
# intervention with every merge. To do so, just uncomment the entries below
30+
###############################################################################
31+
#*.sln merge=binary
32+
#*.csproj merge=binary
33+
#*.vbproj merge=binary
34+
#*.vcxproj merge=binary
35+
#*.vcproj merge=binary
36+
#*.dbproj merge=binary
37+
#*.fsproj merge=binary
38+
#*.lsproj merge=binary
39+
#*.wixproj merge=binary
40+
#*.modelproj merge=binary
41+
#*.sqlproj merge=binary
42+
#*.wwaproj merge=binary
43+
44+
###############################################################################
45+
# behavior for image files
46+
#
47+
# image files are treated as binary by default.
48+
###############################################################################
49+
#*.jpg binary
50+
#*.png binary
51+
#*.gif binary
52+
53+
###############################################################################
54+
# diff behavior for common document formats
55+
#
56+
# Convert binary document formats to text before diffing them. This feature
57+
# is only available from the command line. Turn it on by uncommenting the
58+
# entries below.
59+
###############################################################################
60+
#*.doc diff=astextplain
61+
#*.DOC diff=astextplain
62+
#*.docx diff=astextplain
63+
#*.DOCX diff=astextplain
64+
#*.dot diff=astextplain
65+
#*.DOT diff=astextplain
66+
#*.pdf diff=astextplain
67+
#*.PDF diff=astextplain
68+
#*.rtf diff=astextplain
69+
#*.RTF diff=astextplain

.github/CODEOWNERS

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Relevant documentation for CODEOWNERS file: https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
2+
3+
# All files in this repo are owned by ose-component-detection-maintainers team.
4+
5+
# Reviewers are then assigned round-robin style: https://docs.github.com/en/github/setting-up-and-managing-organizations-and-teams/managing-code-review-assignment-for-your-team
6+
7+
* @microsoft/ose-component-detection-maintainers

.github/ISSUE_TEMPLATE/bug_report.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Bug report
2+
about: Create a report to help us improve
3+
title: "[Bug]: "
4+
labels: ['triage', 'bug']
5+
assignees: ''
6+
7+
body:
8+
- type: markdown
9+
attributes:
10+
value: |
11+
Thanks for taking the time to fill out this bug report!
12+
- type: input
13+
id: summary
14+
attributes:
15+
label: Describe the bug
16+
description: A clear and concise description of what the bug is.
17+
- type: textarea
18+
id: reproduce
19+
attributes:
20+
label: Steps To Reproduce
21+
description: Contents of folder being scanned - minimal data to reproduce the issue is preferred. Alternatively, you can provide a link to a public github repo or gist. You can also attach files to this issue.
22+
placeholder: Tell us what you see!
23+
validations:
24+
required: true
25+
- type: input
26+
id: version
27+
attributes:
28+
label: Which version of the tool was used?
29+
description: The version of the binaries or package, or a git commit hash from the branch if you're using the sources in this repo.
30+
- type: input
31+
id: cli
32+
attributes:
33+
label: Provide the full command line input that you used to invoke the tool.
34+
- type: textarea
35+
id: logs
36+
attributes:
37+
label: Steps To Reproduce
38+
description: 'These files are created by the tool and will provide valuable information: GovCompDisc_Log_{timestamp}.log, ScanManifest_{timestamp}.json, ScanTelemetry_{timestamp}.json You can usually find these in the %TEMP% location, or redirect them with the --Output parameter.'
39+
placeholder: Tell us what you see!

0 commit comments

Comments
 (0)