Skip to content

Commit 86da97d

Browse files
authored
Add copyright notices and licensing information to various scripts and Terraform files (#293)
- Added copyright and license information to shell scripts in the .devcontainer and azd-hooks directories. - Included copyright and license information in PowerShell scripts for pre- and post-deployment hooks. - Updated Terraform files in the infra directory to include copyright and license information. - Added copyright and license information to Python scripts in the src/search directory. - Included copyright and license information in C# test files in the tests/Copilot directory.
1 parent 48e2b35 commit 86da97d

Some content is hidden

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

45 files changed

+449
-316
lines changed

.devcontainer/features/dev-tools/install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/sh
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT license.
4+
25
set -eux
36

47
echo "Installing development tools for Copilot Studio with Azure AI Search..."

.devcontainer/postCreate.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/sh
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT license.
4+
25
set -eux
36

47
echo "Running post-create setup for interactive operations..."
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT license.
3+
14
Write-Host "Execute Post-Deploy Hook"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT license.
3+
14
Write-Host "Execute Post-Package Hook"

azd-hooks/scripts/hooks/postprovision/deploy_power_platform_solution.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env pwsh
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT license.
4+
25
<#
36
47
#region Overview
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT license.
3+
14
Write-Host "Execute Post-provision Hook"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT license.
3+
14
Write-Host "Execute Pre-Deploy Hook"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT license.
3+
14
Write-Host "Execute Pre-Package Hook"
Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,56 @@
1-
function Check-Checkov {
2-
Write-Host "Checking if Checkov is installed...`n"
3-
4-
# Check if Checkov exists in system path
5-
$checkovPath = Get-Command checkov -ErrorAction SilentlyContinue
6-
7-
if ($null -eq $checkovPath) {
8-
Write-Error "Checkov is not installed or not found in PATH!`n"
9-
exit 1
10-
} else {
11-
Write-Host "Checkov is installed at: $($checkovPath.Source)`n"
12-
13-
# Ensure /usr/local/bin is in PATH (for Linux/macOS)
14-
$env:PATH += ":/usr/local/bin"
15-
16-
# Check if Checkov is executable
17-
if (-not (Test-Path $checkovPath.Source)) {
18-
Write-Error "Checkov is not executable!`n"
19-
exit 1
20-
} else {
21-
Write-Host "Checkov is executable.`n"
22-
}
23-
}
24-
}
25-
26-
function Run-Checkov { param (
27-
[string]$ReportFormat,
28-
[string]$TfDirectory = "./infra")
29-
Write-Host "Running Checkov...`n"
30-
31-
# Define checkov result file name
32-
$CheckovResFileName= "checkov-results.$ReportFormat"
33-
34-
# Run Checkov and capture output
35-
checkov -d $TfDirectory --quiet --framework terraform -o $ReportFormat --output-file "./$CheckovResFileName" --soft-fail
36-
$exitCode = $LASTEXITCODE
37-
38-
# Check if lint result file exists
39-
if ($exitCode -ne 0) {
40-
Write-Error "checkov failed`n"
41-
exit 1
42-
}
43-
else {
44-
Write-Host "checkov passed`n"
45-
exit 0
46-
}
47-
}
48-
49-
# First, check if Checkov is installed
50-
Check-Checkov
51-
52-
#Run Checkov
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT license.
3+
4+
function Check-Checkov {
5+
Write-Host "Checking if Checkov is installed...`n"
6+
7+
# Check if Checkov exists in system path
8+
$checkovPath = Get-Command checkov -ErrorAction SilentlyContinue
9+
10+
if ($null -eq $checkovPath) {
11+
Write-Error "Checkov is not installed or not found in PATH!`n"
12+
exit 1
13+
} else {
14+
Write-Host "Checkov is installed at: $($checkovPath.Source)`n"
15+
16+
# Ensure /usr/local/bin is in PATH (for Linux/macOS)
17+
$env:PATH += ":/usr/local/bin"
18+
19+
# Check if Checkov is executable
20+
if (-not (Test-Path $checkovPath.Source)) {
21+
Write-Error "Checkov is not executable!`n"
22+
exit 1
23+
} else {
24+
Write-Host "Checkov is executable.`n"
25+
}
26+
}
27+
}
28+
29+
function Run-Checkov { param (
30+
[string]$ReportFormat,
31+
[string]$TfDirectory = "./infra")
32+
Write-Host "Running Checkov...`n"
33+
34+
# Define checkov result file name
35+
$CheckovResFileName= "checkov-results.$ReportFormat"
36+
37+
# Run Checkov and capture output
38+
checkov -d $TfDirectory --quiet --framework terraform -o $ReportFormat --output-file "./$CheckovResFileName" --soft-fail
39+
$exitCode = $LASTEXITCODE
40+
41+
# Check if lint result file exists
42+
if ($exitCode -ne 0) {
43+
Write-Error "checkov failed`n"
44+
exit 1
45+
}
46+
else {
47+
Write-Host "checkov passed`n"
48+
exit 0
49+
}
50+
}
51+
52+
# First, check if Checkov is installed
53+
Check-Checkov
54+
55+
#Run Checkov
5356
Run-Checkov -ReportFormat sarif
Lines changed: 112 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,112 @@
1-
function Check-Gitleaks {
2-
Write-Host "Checking if Gitleaks is installed...`n"
3-
4-
# Check if Gitleaks exists in system path
5-
$gitleaksPath = Get-Command gitleaks -ErrorAction SilentlyContinue
6-
7-
if ($null -eq $gitleaksPath) {
8-
Write-Error "Gitleaks is not installed or not found in PATH!`n"
9-
exit 1
10-
} else {
11-
Write-Host "Gitleaks is installed at: $($gitleaksPath.Source)`n"
12-
# Ensure /usr/local/bin is in PATH
13-
$env:PATH += ":/usr/local/bin"
14-
# Check if Gitleaks is executable
15-
if (-not (Test-Path $gitleaksPath.Source)) {
16-
Write-Error "Gitleaks is not executable!`n"
17-
exit 1
18-
} else {
19-
Write-Host "Gitleaks is executable.`n"
20-
}
21-
22-
}
23-
}
24-
25-
function Run-Gitleaks {
26-
param (
27-
[string]$ReportFormat,
28-
[string]$LogLevel,
29-
[switch]$Redact,
30-
[switch]$Verbose,
31-
[switch]$NoGit
32-
)
33-
34-
Write-Host "Run Gitleaks detect cmd...`n"
35-
36-
$SourcePath = (Get-Location)
37-
38-
# Get current git branch and check if repository has commits
39-
$currentBranch = $null
40-
$hasCommits = $false
41-
42-
try {
43-
Write-Host "Getting current git branch..."
44-
$currentBranch = git branch --show-current
45-
if ($LASTEXITCODE -ne 0) {
46-
Write-Warning "Failed to get git branch, defaulting to 'unknown'"
47-
$currentBranch = "unknown"
48-
} else {
49-
Write-Host "Current git branch: $currentBranch"
50-
51-
# Check if the repository has any commits
52-
try {
53-
git rev-parse HEAD 2>$null | Out-Null
54-
if ($LASTEXITCODE -eq 0) {
55-
$hasCommits = $true
56-
Write-Host "Repository has commits, will use branch reference in log options."
57-
} else {
58-
Write-Host "Repository has no commits yet, will skip branch reference in log options."
59-
}
60-
} catch {
61-
Write-Host "Cannot determine commit history, will skip branch reference in log options."
62-
}
63-
}
64-
} catch {
65-
Write-Warning "Error getting git branch: $_"
66-
$currentBranch = "unknown"
67-
}
68-
69-
# Construct command options as an array
70-
$cmdOptions = @(
71-
"detect"
72-
"--config", "$SourcePath/.gitleaks.toml"
73-
"--source", "$SourcePath"
74-
"--report-path", "./gitleaks-report.$ReportFormat"
75-
"--report-format", "$ReportFormat"
76-
"--log-level", "$LogLevel"
77-
)
78-
79-
# Only add log-opts if we have a valid branch name and the repository has commits.
80-
if ($currentBranch -ne "unknown" -and $hasCommits) {
81-
$cmdOptions += "--log-opts"
82-
$cmdOptions += "$currentBranch"
83-
}
84-
85-
if ($Redact) { $cmdOptions += "--redact" }
86-
if ($Verbose) { $cmdOptions += "--verbose" }
87-
88-
Write-Verbose "gitleaks $($cmdOptions -join ' ')`n"
89-
90-
# Run Gitleaks command
91-
gitleaks @cmdOptions
92-
$exitCode = $LASTEXITCODE
93-
94-
if ($exitCode -ne 0) {
95-
Write-Error "gitleaks failed`n"
96-
exit 1
97-
}
98-
else {
99-
Write-Host "gitleaks passed`n"
100-
exit 0
101-
}
102-
103-
}
104-
105-
# First, check if Gitleaks is installed
106-
Check-Gitleaks
107-
108-
# Then, run Gitleaks scan
109-
Run-Gitleaks -ReportFormat "sarif" -LogLevel "info" -Redact -Verbose
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT license.
3+
4+
function Check-Gitleaks {
5+
Write-Host "Checking if Gitleaks is installed...`n"
6+
7+
# Check if Gitleaks exists in system path
8+
$gitleaksPath = Get-Command gitleaks -ErrorAction SilentlyContinue
9+
10+
if ($null -eq $gitleaksPath) {
11+
Write-Error "Gitleaks is not installed or not found in PATH!`n"
12+
exit 1
13+
} else {
14+
Write-Host "Gitleaks is installed at: $($gitleaksPath.Source)`n"
15+
# Ensure /usr/local/bin is in PATH
16+
$env:PATH += ":/usr/local/bin"
17+
# Check if Gitleaks is executable
18+
if (-not (Test-Path $gitleaksPath.Source)) {
19+
Write-Error "Gitleaks is not executable!`n"
20+
exit 1
21+
} else {
22+
Write-Host "Gitleaks is executable.`n"
23+
}
24+
25+
}
26+
}
27+
28+
function Run-Gitleaks {
29+
param (
30+
[string]$ReportFormat,
31+
[string]$LogLevel,
32+
[switch]$Redact,
33+
[switch]$Verbose,
34+
[switch]$NoGit
35+
)
36+
37+
Write-Host "Run Gitleaks detect cmd...`n"
38+
39+
$SourcePath = (Get-Location)
40+
41+
# Get current git branch and check if repository has commits
42+
$currentBranch = $null
43+
$hasCommits = $false
44+
45+
try {
46+
Write-Host "Getting current git branch..."
47+
$currentBranch = git branch --show-current
48+
if ($LASTEXITCODE -ne 0) {
49+
Write-Warning "Failed to get git branch, defaulting to 'unknown'"
50+
$currentBranch = "unknown"
51+
} else {
52+
Write-Host "Current git branch: $currentBranch"
53+
54+
# Check if the repository has any commits
55+
try {
56+
git rev-parse HEAD 2>$null | Out-Null
57+
if ($LASTEXITCODE -eq 0) {
58+
$hasCommits = $true
59+
Write-Host "Repository has commits, will use branch reference in log options."
60+
} else {
61+
Write-Host "Repository has no commits yet, will skip branch reference in log options."
62+
}
63+
} catch {
64+
Write-Host "Cannot determine commit history, will skip branch reference in log options."
65+
}
66+
}
67+
} catch {
68+
Write-Warning "Error getting git branch: $_"
69+
$currentBranch = "unknown"
70+
}
71+
72+
# Construct command options as an array
73+
$cmdOptions = @(
74+
"detect"
75+
"--config", "$SourcePath/.gitleaks.toml"
76+
"--source", "$SourcePath"
77+
"--report-path", "./gitleaks-report.$ReportFormat"
78+
"--report-format", "$ReportFormat"
79+
"--log-level", "$LogLevel"
80+
)
81+
82+
# Only add log-opts if we have a valid branch name and the repository has commits.
83+
if ($currentBranch -ne "unknown" -and $hasCommits) {
84+
$cmdOptions += "--log-opts"
85+
$cmdOptions += "$currentBranch"
86+
}
87+
88+
if ($Redact) { $cmdOptions += "--redact" }
89+
if ($Verbose) { $cmdOptions += "--verbose" }
90+
91+
Write-Verbose "gitleaks $($cmdOptions -join ' ')`n"
92+
93+
# Run Gitleaks command
94+
gitleaks @cmdOptions
95+
$exitCode = $LASTEXITCODE
96+
97+
if ($exitCode -ne 0) {
98+
Write-Error "gitleaks failed`n"
99+
exit 1
100+
}
101+
else {
102+
Write-Host "gitleaks passed`n"
103+
exit 0
104+
}
105+
106+
}
107+
108+
# First, check if Gitleaks is installed
109+
Check-Gitleaks
110+
111+
# Then, run Gitleaks scan
112+
Run-Gitleaks -ReportFormat "sarif" -LogLevel "info" -Redact -Verbose

0 commit comments

Comments
 (0)