66
CHAPTER 3 | Continuous integration and deployment with Azure DevOps
{
"name": "UI:Index:Header",
"value": "${{ secrets.INDEX_HEADER }}",
"slotSetting": true
}
]
-
name
:
az cli logout
run
:
az logout
deploy_prod
:
needs
:
deploy_staging
runs-on
:
ubuntu-latest
environment
:
name
:
PROD
url
:
${{ steps.slot_swap.outputs.url }}
steps
:
-
name
:
Login via Azure CLI
uses
:
azure/login@v1
with
:
creds
:
${{ secrets.AZURE_CREDENTIALS }}
-
name
:
Swap staging slot into production
id
:
slot_swap
run
:
|
az webapp deployment slot swap -g ${{ env.rg-name }} -n ${{ env.app-name }} -s
staging url=$(az webapp show -g ${{ env.rg-name }} -n ${{ env.app-name }} --query
"defaultHostName" -o tsv)
echo "::set-output name=url::http://$url"
-
name
:
Update config
uses
:
Azure/appservice-settings@v1
with
:
app-name
:
${{ env.app-name }}
app-settings-json
:
|
[
{
"name": "UI:Index:Header",
"value": "${{ secrets.INDEX_HEADER }}",
"slotSetting": true
}
]
-
name
:
az cli logout
run
:
az logout
Secure .NET Code with CodeQL and
GitHub Actions
CodeQL
is a static code analysis engine that can automate security and quality checks. With CodeQL,
you can
perform
variant analysis
, which uses known vulnerabilities as seeds to find similar issues.
CodeQL is part of
GitHub Advanced Security
that includes:
•
Code
scanning
—
find potential security vulnerabilities in your code.
•
Secret scanning
—
detect secrets and tokens that are committed.
•
Dependency scanning
—
detect vulnerabilities in packages that you consume.
67
CHAPTER 3 | Continuous integration and deployment with Azure DevOps
CodeQL
supports some of the most popular programming languages and compilers
:
•
C/C++
•
Java
•
C#
•
Python
•
Go
•
JavaScript
•
TypeScript
CodeQL is a powerful language and security professionals can create custom queries using CodeQL.
However, teams can benefit immensely from the large open-source collection of queries that the
security community has created without having to write any custom CodeQL.
In
this article, you’ll set up a GitHub
workflow that will scan code in your repository using CodeQL.
You will:
•
Create a code scanning action.
•
Edit the workflow file to include custom scan settings.
•
See scanning results.
Note
To see security alerts
for your repository, you must be a repository owner.
Create the code scanning workflow
You can use a starter workflow for code scanning by
navigating to the
Security
tab of your repository.
1.
Navigate to your GitHub repository and select the
Security
>
Code Scanning Alerts
. The top
recommended workflow should be CodeQL Analysis.
Select
Do'stlaringiz bilan baham: