Dev Sec Ops
Dev Sec Ops
Dev Sec Ops
Agenda
• DevSecOps • Modern continuous delivery
o What is DevOps? o Trunk base development
o Feature flags
o The Transition to DevOps o Microservices
o Why DevOps? o Serverless
o DevSecOps o Docker and Kubernetes
o Security testing
• About CI/CD o Other techniques and tools
o What’s CI/CD • Demo & Practice
o CI/CD in DevOps o Azure Pipeline
o Azure Pipeline & Google Cloud
o Why’s CI/CD Platform
• Data-driven Design
DevSecOps
“If you fear to release your system at any time, you are not
DevOps yet”
Gene Kim, co-founder of DevOps
What is DevOps
The Transition to DevOps
DevOps Team Formation
Why DevOps?
DevSecOps?
•Security is not just a STEP
in a pipeline!
•Involves everything we do,
from the CEO to the
developers
About CI/CD
What’s CI/CD
Continuous Delivery
CI/CD In DevOps
SOURCE BUILD TEST PACKAGE DEVELOPMENT
CONTROL
T
F
V
C
STAGING
Pain_of_merge =
fun (size_of_merge, “Branches create distance between developers and
duration_since_last_merge) we do not want that”
Frank Compagner, Guerrilla Games
Feature-flag-driven
development
• Allows you to quickly release iterations of your
features to market, receive feedback, improve, and
redeploy
• Based on real market feedback and make the
necessary improvements to drive the product
forward.
• Control deep functional features and then target
user segments
• Analyze these feature tests using your Optimizely
or New Relic goals.
Microservices
• Independent deployments.
• Independent development
• Small, focused teams.
• Fault isolation.
• Can make use of the latest
technologies.
• Mixed technology stacks
• Pair well with containers
• Granular scaling
Mastering Chaos - A Netflix Guide to
Microservices
Serverless
Serverless web application on Azure
Functions as a service (FaaS). In this model, a "function" is a piece of code that is deployed to the
cloud and runs inside a hosting environment that completely abstracts the servers that run the
code.
Docker and Kubernetes
Security Testing
• Static Application Security Testing (SAST)
• Dynamic Application Security Testing (DAST)
Monitor and react, learn and proact
• PowerBI
• Centralize and visualize important
indicators for any aspect of our
organization
Ongoing
Feature teams
Other techniques and tools
• Branch by abstraction
• Monolith decomposition patterns
• Deployment strategies: rolling update, blue green, canary
• Infrastructure as code
• Mutation testing
Practice &
Demo
Azure Pipelines
• Cloud-hosted pipelines for Linux, Windows
and macOS, with unlimited minutes for open
source
Any language, any platform, any cloud
Build, test, and deploy Node.js, Python, Java, PHP,
Ruby, C/C++, .NET, Android, and iOS apps. Run in
parallel on Linux, macOS, and Windows. Deploy to
Azure, AWS, GCP or on-premises
Extensible
Explore and implement a wide range of community-
built build, test, and deployment tasks, along with
hundreds of extensions from Slack to SonarCloud.
Support for YAML, reporting and more
.NET Core Azure Repos Azure Pipelines Sonar Cloud Azure App Service
Visual Studio Visual Studio Code Source Tree GIT YAML Ain't Markup
Language
Tool – Technology (cont.)
Azure DevOps account (MUST) (
https://azure.microsoft.com/en-in/services/devops/)
• Access https://sonarcloud.io/sessions/new
• Login with Microsoft account
Generate SonarCloud user token
1
Create project
Import sample repository
Import sample repository
• Clone URL: https://dinhnc0201@dev.azure.com/dinhnc0201/MyToDo/_git/MyToDo
Import sample repository
Change default branch
Build
Pipeline
Configuratio
n
Code
Artifact Build
Create New Pipeline
Create New Pipeline
Select your repository
Select a template
Configure property
.Net Core restore task
.Net Core restore task
Clone task
.Net Core build task
$(SourceBranchName)-$(Date:yyyyMMdd)$(Rev:.r)
Save & Queue
Execute the pipeline
Check The Logs
Check The Summary
Check The Artifacts
Check The Artifacts
Code
Automate build, UT
execution Artifact Build
and artifact creation
Test
Add Coverlet Tool
Add Coverlet Tool
tests/MyToDo.tests/coverage.cobertura.xml
Execute the pipeline and check the result
Tests Result
Code Coverage Result
Code
Artifact Build
Automate build, UT
execution, code analyze
and artifact creation
Analyze Test
Add SonarCloud Plugin To AzureDevops
• Access: https://marketplace.visualstudio.com/azuredevops
Add SonarQube Plugin To AzureDevops
• Additional Properties:
sonar.organization=workshop
sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/tests/MyToDo.Tests/coverage.opencover.xml
SonarQube – Add SonarCloud Connection
• Token: 8a335aa96ba934941bad101a1e72a77e227b12e3
SonarQube – Prepare Analysis Configuration
• Because of sonarqube license,
the Pipeline will analyze on
default branch only (develop)
• In this workshop we will not set Check For Linked Work Items
Check For Comment Resolution
Limit Merge Types
Build Validation
Automatically Include Code Reviewers
Save Policies
Modify the code to make the pipeline fail
• Clone repository to your local
• Create and checkout new branch: `feature/update-done-status`
Modify the code to make the pipeline fail
• Add new test case: ToDo Item mark complete should set Is Done To
True
Modify the code to make the pipeline fail
Implement feature:
Deploy
Artifacts
DEV
• Releases should be trigger to the RC, staging environment on a successful update to the “release” branch
• Configuration Pre-deployment approvals: Select the users who can approve or reject deployments to this
stage
Clone Stage
Configuration of Pre-Deployment Conditions
Create Stage For Pre-Confirmation
Environment
• Because of the limitation of App Service so in this work shop we will use
the same deploy URL for all environment
Configuration For Testing Stage
Performance
Artifacts Deploy DEV IT Deploy RC UAT Deploy STG Deploy PROD
Test
https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema
🡺
Pipelines as Code with YAML
YAML Based
Build on existing VSTS Build &
Release model, including
extensions
Support templating via Mustache
Makes it easy to share examples,
samples etc
Scales from very simple to very
complex
Version control better
New Pipeline From YAML File
New Pipeline From YAML File
Checking New Pipeline
Azure Pipeline For Front-end
Sample ReactJS repository
• https://dinhnc0201@dev.azure.com/dinhnc0201/MyToDo/_git/MyToDoApp
Checking The Pipeline using YAML
Checking The Pipeline using YAML
Create New Pipeline From YAML And Execute
The Pipeline
SonarQube build breaker
and quality protection
An extension that breaks your build whenever the quality gate in
SonarQube failed
🡺 https://marketplace.visualstudio.com/items?itemName=SimondeLang.sonar-buildbreaker
Usage
• It is recommended to place the task after the 'Publish Quality Gate' task from
SonarSource, this is because the official task has better error handling and you
probably want to browse to SonarQube if this task makes your build fail
Usage
• The task requires one input, your SonarQube endpoint. This is required
in order to authenticate to the SonarQube instance
Configuration For Quality Gate
The pipeline will fail whenever the quality gate in
SonarQube failed
SonarQube pull request analysis
(SonarQube developer edition)
An extension that breaks your build whenever the quality gate in
SonarQube failed
🡺 https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-azure-devops/
SonarQube pull request analysis and line
comments (SonarQube developer edition)
• SonarQube can analyze the code of the new features and annotate your pull requests in TFS
with comments to highlight issues that were found.
• Pull request analysis is supported for any type of Git repositories. To activate it:
1. In the Branch policies page of your main development branches (e.g. "master"), add a
build policy that runs your build definition
2. Create an Azure DevOps token with "Code (read and write)" scope
3. In SonarQube, in the Administration > General Settings > Pull Requests page, set
this token in the VSTS/TFS section
• Next time some code is pushed in the branch of a pull request, the build definition will execute
a scan on the code and publish the results in SonarQube which will decorate the pull request
in TFS.
SonarQube pull request analysis and line
comments (SonarQube developer edition)
Azure Pipelines with
Microsoft Teams
https://docs.microsoft.com/en-us/azure/devops/pipelines/integrations/microsoft-teams?view=azure-devops
🡺
Azure Pipelines with Microsoft Teams
Azure Pipelines automation test with
BDD, Azure Test Plan, Test Suite
https://docs.microsoft.com/en-us/azure/devops/test/run-automated-tests-from-test-hub?view=azure-devops
🡺
Azure Test Plans
Azure Pipelines automation test with BDD,
Azure Test Plan, Test Suite
SpecFlow Build pipeline
https://www.visualstudiogeeks.com/DevOps/SpecflowPlusSpecRunVstsPipelineForBddStyleAutomatedGherkinFunctionalTests
Azure Pipelines automation test with BDD,
Azure Test Plan, Test Suite
Test evidence (screenshot, videos,…) from automation test can attach to test result
Azure
DevOps with
& GCP
products
Data-driven
Design
PROFIT PRODUCTIVE