[StepSecurity] Apply security best practices (#21480)

* [StepSecurity] Apply security best practices

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>

* Update dependabot.yml

* Delete tools/releaseBuild/Images/microsoft_powershell_centos7 directory

* Delete tools/releaseBuild/Images/microsoft_powershell_ubuntu16.04 directory

* Delete tools/releaseBuild/Images/microsoft_powershell_ubuntu18.04 directory

* Delete tools/releaseBuild/Images/microsoft_powershell_windowsservercore/Dockerfile

---------

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
This commit is contained in:
StepSecurity Bot 2024-04-16 14:58:26 -07:00 committed by GitHub
parent d370d7d586
commit c19b65133c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 122 additions and 153 deletions

View File

@ -3,7 +3,7 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
FROM mcr.microsoft.com/powershell/test-deps:ubuntu-18.04
FROM mcr.microsoft.com/powershell/test-deps:ubuntu-18.04@sha256:20154a16708d4a92ebe81393361f27c7567e6553869e89dd6abdd198cc8ba309
# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

View File

@ -3,7 +3,7 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
FROM mcr.microsoft.com/powershell:preview-fedora-30
FROM mcr.microsoft.com/powershell:preview-fedora-30@sha256:f405d4d60f8d196532da75038c76c052084ef02121f8e2d3852080ff4a230a5a
# Configure apt and install packages
RUN dnf install -y git procps wget findutils \

View File

@ -58,3 +58,10 @@ updates:
interval: "daily"
labels:
- "CL-BuildPackaging"
- package-ecosystem: docker
directory: /
schedule:
interval: daily
labels:
- "CL-BuildPackaging"

View File

@ -2,6 +2,9 @@ name: Auto Assign PR Maintainer
on:
pull_request:
types: [opened, edited]
permissions:
contents: read
jobs:
run:
runs-on: ubuntu-latest
@ -9,7 +12,7 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: wow-actions/auto-assign@v3
- uses: wow-actions/auto-assign@67fafa03df61d7e5f201734a2fa60d1ab111880d # v3.0.2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# using the `org/team_slug` or `/team_slug` syntax to add git team as reviewers

View File

@ -37,13 +37,13 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: '0'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@df5a14dc28094dc936e103b37d749c6628682b60 # v3.25.0
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@ -66,4 +66,4 @@ jobs:
name: Build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@df5a14dc28094dc936e103b37d749c6628682b60 # v3.25.0

View File

@ -16,4 +16,4 @@ jobs:
steps:
- name: check for reminder
uses: agrc/create-reminder-action@v1
uses: agrc/create-reminder-action@922893a5705067719c4c4751843962f56aabf5eb # v1.1.13

22
.github/workflows/dependency-review.yml vendored Normal file
View File

@ -0,0 +1,22 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Request,
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
# Once installed, if the workflow run is marked as required,
# PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
name: 'Dependency Review'
on: [pull_request]
permissions:
contents: read
jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: 'Dependency Review'
uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1

View File

@ -12,8 +12,8 @@ jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gaurav-nelson/github-action-markdown-link-check@v1
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: gaurav-nelson/github-action-markdown-link-check@5c5dfc0ac2e225883c0e5f03a85311ec2830d368 # v1
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
@ -26,13 +26,13 @@ jobs:
statuses: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
# Full git history is needed to get a proper
# list of changed files within `super-linter`
fetch-depth: 0
- name: Lint Markdown
uses: super-linter/super-linter@v5
uses: super-linter/super-linter@a8150b40c89574adb5f68bf9502b890a236a06b3 # v5.7.2
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master

View File

@ -18,15 +18,15 @@ jobs:
if: github.repository == 'PowerShell/PowerShell'
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Check Links
uses: gaurav-nelson/github-action-markdown-link-check@v1
uses: gaurav-nelson/github-action-markdown-link-check@5c5dfc0ac2e225883c0e5f03a85311ec2830d368 # v1
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: .github/workflows/markdown-link/config.json
- name: Microsoft Teams Notifier
uses: skitionek/notify-microsoft-teams@master
uses: skitionek/notify-microsoft-teams@77cc88b484449e2318245a54c115c5dca0eae4ef # master
if: failure()
with:
webhook_url: ${{ secrets.PS_BUILD_TEAMS_CHANNEL }}

View File

@ -17,4 +17,4 @@ jobs:
steps:
- name: check reminders and notify
uses: agrc/reminder-action@v1
uses: agrc/reminder-action@e59091b4e9705a6108120cb50823108df35b5392 # v1.0.12

View File

@ -18,11 +18,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Post rebase started comment to pull request
uses: actions/github-script@v7
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
continue-on-error: true
with:
script: |
@ -34,6 +34,6 @@ jobs:
body: backport_start_body
});
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.8
uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 # 1.8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

71
.github/workflows/scorecards.yml vendored Normal file
View File

@ -0,0 +1,71 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '20 7 * * 2'
push:
branches: ["master"]
# Declare default permissions as read only.
permissions: read-all
jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
contents: read
actions: read
steps:
- name: "Checkout code"
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # v2.0.6
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecards on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@f72882a05ba58122a44b17f2fce8fb50e5c79a59 # v2.25.0
with:
sarif_file: results.sarif

View File

@ -1,5 +1,5 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2022
FROM mcr.microsoft.com/windows/servercore:ltsc2022@sha256:5d09ffa90d91a46e2fe7652b0a37cbf5217f34a819c3d71cbe635dae8226061b
SHELL ["pwsh.exe","-command"]

View File

@ -1,30 +0,0 @@
# Docker image file that describes an Centos7 image with PowerShell installed from Microsoft YUM Repo
FROM mcr.microsoft.com/powershell:centos-7
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>"
# Install dependencies and clean up
RUN yum install -y \
glibc \
libcurl \
ca-certificates \
libgcc \
libicu \
openssl \
libstdc++ \
ncurses-base \
libunwind \
uuid \
zlib \
which \
curl \
git \
wget \
&& yum clean all
COPY PowerShellPackage.ps1 /
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# Use PowerShell as the default shell
ENTRYPOINT [ "pwsh" ]

View File

@ -1,37 +0,0 @@
# Docker image file that describes an Ubuntu16.04 image with PowerShell installed from Microsoft APT Repo
FROM mcr.microsoft.com/powershell:ubuntu-16.04
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>"
# Install dependencies and clean up
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
apt-utils \
libc6 \
libcurl3 \
ca-certificates \
libgcc1 \
libicu55 \
libssl1.0.0 \
libstdc++6 \
libtinfo5 \
libunwind8 \
libuuid1 \
libcroco3 \
libgraphite2-3 \
zlib1g \
curl \
git \
apt-transport-https \
locales \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY PowerShellPackage.ps1 /
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# Use PowerShell as the default shell
ENTRYPOINT [ "pwsh" ]

View File

@ -1,37 +0,0 @@
# Docker image file that describes an Ubuntu16.04 image with PowerShell installed from Microsoft APT Repo
FROM mcr.microsoft.com/powershell:ubuntu-18.04
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>"
# Install dependencies and clean up
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
apt-utils \
libc6 \
libcurl4 \
ca-certificates \
libgcc1 \
libicu60 \
libssl1.0.0 \
libstdc++6 \
libtinfo5 \
libunwind8 \
libuuid1 \
libcroco3 \
libgraphite2-3 \
zlib1g \
curl \
git \
apt-transport-https \
locales \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY PowerShellPackage.ps1 /
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# Use PowerShell as the default shell
ENTRYPOINT [ "pwsh" ]

View File

@ -1,30 +0,0 @@
# escape=`
#0.3.6 (no powershell 6)
FROM mcr.microsoft.com/powershell:windowsservercore
LABEL maintainer='PowerShell Team <powershellteam@hotmail.com>'
LABEL description="This Dockerfile for Windows Server Core with git installed via chocolatey."
SHELL ["C:\\Program Files\\PowerShell\\latest\\pwsh.exe", "-command"]
# Install Git, and NuGet
# Git installs to C:\Program Files\Git
# nuget installs to C:\ProgramData\chocolatey\bin\NuGet.exe
COPY dockerInstall.psm1 containerFiles/dockerInstall.psm1
RUN Import-Module ./containerFiles/dockerInstall.psm1; `
Install-ChocolateyPackage -PackageName git -Executable git.exe; `
Install-ChocolateyPackage -PackageName nuget.commandline -Executable nuget.exe -Cleanup
# Install WIX
ADD https://github.com/wixtoolset/wix3/releases/download/wix311rtm/wix311-binaries.zip /wix.zip
COPY wix.psm1 containerFiles/wix.psm1
RUN Import-Module ./containerFiles/wix.psm1; `
Install-WixZip -zipPath \wix.Zip
# Install makeappx and makepri
ADD https://pscoretestdata.blob.core.windows.net/build-files/makeappx/makeappx.zip?sp=r&st=2019-04-05T18:02:52Z&se=2020-04-06T02:02:52Z&spr=https&sv=2018-03-28&sig=t07uC1K3uFLtINQsmorHobgPh%2B%2BBgjFnmHEJGNZT6Hk%3D&sr=b /makeappx.zip
RUN Expand-Archive /makeappx.zip
COPY PowerShellPackage.ps1 /
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
ENTRYPOINT ["C:\\Program Files\\PowerShell\\latest\\pwsh.exe", "-command"]