SlideShare a Scribd company logo
How to encourage software engineers to adhere* standards
Tokarev Alexander
* But not limited
Who am I
• Sberbank cloud center of excellence head
• Certified Amazon solution architect
• Tons of AWS and GCP finished projects
Agenda
• Standards in software development
• Open Policy Agent
• Rego
• Tools
• OPA for policy based control
• OPA use cases
• Q&A
•
Current state
• 100 OpenShift applications in production
• Monthly basis releases
• Microservices
Result
• Reinventing the wheel
• Overloaded security software
Solution
• Create requirements and recommendations
• Create containerization standards
• Create cloud best practices
Risks
• Manual compliance checks
• Software delivery pace is slow
Compliance maturity levels
1. Base validation
2. Version control integration
3. Reusable validations
4. Automatic validation
5. Validation-based mutations
6. Advanced validations
Compliance maturity levels
1. Base validation
2. Version control integration
3. Reusable validations
4. Automatic validation
5. Validation-based mutations
6. Advanced validations
Open Policy Agent for governance as a code
Kubetest
https://github.com/garethr/kubetest
Kyverno
https://github.com/nirmata/kyverno
https://kyverno.io/
1. CRD is too verbose
2. Nailed to k8s
3. There is no DSL
4. All validations are regexp’s
5. No debug option
Kyverno
CPU and memory limit validation
Sonar custom rules
A lot of stuff!
And don’t forget to compile!
7
What is OPA
• Policy engine
• Go language
• In-memory speed
• Could validate anything
• Declarative Rego language
• SQL-like
• External data processing
• Perfect integration
• Customizable response format
Simplest policy “Limits are populated”
3 lines!
Get all K8S containers
“For each” validation
Prepare output
Package name
Rule name
K8S advanced policy “Readiness probe exists”
Another type of probes
Only deployments should be checked
All attributes are populated
“For each” validation
Prepare output
Open Policy Agent for governance as a code
What else
• Maven
• NPM
• Terraform
• ER diagrams – Power Designer XML inside
JSON only!
Sberbank OPA
+ =
Any configuration:
K8S YAML
Pom.xml
.properties
.ini
…………………………………..
+ UI
Plugin system
Sberbank OPA
Policy example
Policy example
Required library exists
Policy
• Check permitted image list:
fluentbit2, envoy3, nginx:1.7.9
• Output prohibited image list
Examples
InvalidValid
Not related with search condition at all
Let’s try this one! We should trust AWS!
Policy implementation example
19 lines!!!
WTF?!
Object comprehension:
Translate array as is to object
key
Condition
Policy implementation example “Sberbank naive”
13 lines!
Still too complicated!
Object!!!
Policy implementation example “Sberbank native”
The best!
7 lines!!!
Get all K8S containers
All containers out of permitted
Tools
https://play.openpolicyagent.org/
Tools
That’s it 
https://github.com/tsandall/vscode-opa
1. Syntax check
2. Highlighting
3. Evaluation
4. Trace
5. Profile
6. Unit tests
Compliance maturity levels
1. Base validation
2. Version control integration
3. Reusable validations
4. Automatic validation
5. Validation-based mutations
6. Advanced validations
OPA integration modes
• Push – OPA API
1. curl -X PUT http://localhost:8181/v1/data/checks/ --data-binary @check_packages.rego
2. curl -X PUT http://localhost:8181/v1/data/checks/packages --data-binary @permitted_packages.json
• Pull – OPA bundle server
Load data
OPA server
Bundle server
http GET Request
*.gzip
Rego + dataETAG cache header
• Run validation
• Process results via Jenkins, admission controller, UI, whatever…
Validation
curl -X POST http://localhost:8181/v1/data/checks/npm/valid_package --data-binary
'{ "input": { "private": true,"dependencies": { "clickstream": "^4.6.1" } } }'
An object to check
Package name Rule name
Features nobody use
• Unit tests
• Tracing, profiling and benchmarking
• Conditional evaluation
• HTTP requests
• JWT
• Nobody explains features intension
• No chance to fine using Google
Open Policy Agent for governance as a code
Search result
Proper trace
Found occasionally!
CNCF project
It’s alive
It’s alive
Conftest
• OPA-based tool to check config files
• Data format conversion plugins
• Plugins are auto-applied based on files extension
Conftest
Conftest
+
• Data conversion plugins: YAML, INI, TOML, HOCON, HCL, HCL1, CUE, Dockerfile, EDN, VCL, XML
• Full of Rego samples
-
• Plugins are written using Go
• Validation rules are stored in Docker registry
• Not stable
• Single-thread
• Command-line tool
Compliance maturity levels
1. Base validation
2. Version control integration
3. Reusable validations
4. Automatic validation
5. Validation-based mutations
6. Advanced validations
Gatekeeper
1. Admission controller
2. Mutating admission controller
1
4
3
2
5
Examples
Examples
Pros
• Validations reuse using templates approach
• Huge library of examples
• Tight integration with K8S
Cons
• K8S cluster is required
• No unit tests for templates and constraints
• Rather verbose CRD
• UI is absent
• No options to invoke external services
• No options to use bundle server
• Mutation admission controller is in development stage
Gatekeeper
Recommended validations
+
Not K8S validations
Bundle server
Solution architecture
GateKeeper
Open Policy Agent
BitBucket
Governance as a code
repository
K8S
Policies
Java
configs
CI/CD
artifacts
Jenkins
K8S
config
Rules
metadata
Governance as a code UI
Sber-made 
Sber-made 
Policies
unit tests
templates
constraints
BitBucket
Software
repository
K8S
config
BitBucket
Whatever we need
repository
Any
artifact
tar
Mandatory validations
Results
1. 24 mandatory rules
2. 12 recommended rules
3. 120 rules are planned
4. 10 seconds – 1 project validation
“Opensource or not opensource,
that is the question
Compliance maturity levels
1. Base validation
2. Version control integration
3. Reusable validations
4. Automatic validation
5. Validation-based mutations
6. Advanced validations
Goldman Sachs
• 12 shared clusters on VMs
• 150 namespace per cluster
• 1800 namespace total
Inventory
Per-namespace management:
1. Security inventory: Roles, RoleBindings, ClusterRoles,
ClusterRoleBindings
2. Capacity Inventory: cpu, memory for ResourceQuotas and
LimitRange
3. NFS inventory: Persistent volumes and Persistent volume claims
Solution design
• Pull-mode for inventory objects using bundle server
• K8S objects are created based on OPA validation output
• Hand-made mutation admission controller
Monitoring
1. Go routine and thread counts
2. Memory in use (stack vs heap)
3. Memory allocated (stack vs heap)
4. GC stats
5. Pointer lookup count
6. Roundtrip time by http method
7. Percentage of requests under 500ms, 200ms, 50ms
8. Mean API request latency
9. Recommendations for alerting
10. Number of OPA instances up at any given time
11. OPA responding under 200ms for 95% of requests
Miguel.Uzcategui@ny.email.gs.com @tlhinrichs
Provisioning
Controller Manager
Policy
(Rego)
GS Inventory
Provision
Request data
Kube-mgmt
GIT
Cluster state
Bundle server
Notify changes
Request data
Results
• 24 validations
• 1 Mb security reference data – 3500 rules
• 2 Mb PV, CPU and memory quotas – 8000 rules
• Cluster target state after any change –2-5 minutes
Compliance maturity levels
1. Base validation
2. Version control integration
3. Reusable validations
4. Automatic validation
5. Validation-based mutations
6. Advanced validations
Fugue
• Governance as a code as a service
• Multi-cloud validation - Amazon, Azure, GCP
• Implemented as a mutation admission controller
• Rollback process for erroneous configuration
• Presets for PSI DSS, HIPAA, SOC
• OPA-based engine
• Self-made Rego interpreter
• https://www.fugue.co/
• https://github.com/fugue/fregot
• https://github.com/fugue/custom-rules
Fugue
Fugue
RDS HA rule
Elastic web UI limitation rule
Fregot
Fregot
• Simplified debug
• Breakpoints
• Watch variables
• Extended troubleshooting
What should I do?!
Compliance maturity levels
1. Base validation
2. Version control integration
3. Reusable validations
4. Automatic validation
5. Validation-based mutations
6. Advanced validations
Validation toolkit
1. Base validations
2. Version control integration
3. Reusable validations
4. Automatic validation
5. Validation-based mutations
6. Advanced validations
OPA use cases
• Any structured data validation
• Mutating validated data
• Authorization
• Database row level security – SQL databases, ElasticSearch
• And games  https://medium.com/@KevinHoffman/corrupting-the-open-policy-agent-to-run-my-game-711f340adb5a
Pinterest
1. Zero-trust security
2. OPA-based authorization
3. K8S + VM
4. Kafka
5. Envoy
6. 4.1M QPS avg
7. 8.5M QPS peak
8. Authorization result cache – 5 min TTL
9. 204K QPS – OPA
10. 437K QPS peak – OPA
Performance
• Network footprint
• OPA library single-thread
• Use OPA server instead – multi-thread
• Memory for data – 20x from raw data
• Partial evaluation – ms to ns
• Extra memory consumption for partial evaluation cache
• Beware arrays
• Use objects instead
OPA as a sidecar
Policy delivery
Service
Sidecar
Container
S3
Zookeper
Bitbucket
K8S cluster
Commit hook
OPA authorization
OPA authorization
OPA authorization
Gloo enterprise edition only!
Envoy
1. L3/4/7 proxy
2. C++
3. Filters chains
4. http/2 support
5. Dynamic configuration update
6. Cloud native patterns implementation
1. Service mesh
2. Envoy fleet
3. Configuration distribution
4. Good CRD
5. Observability and security
OPA authorization
OPA authorization
OPA authorization
OPA authorization
Penetration testing
Conclusions
The results of this Cure53 security assessment of the OPA compound are positive.
Having said that, Cure53 specifically finds that the provided examples of implementations were very
minimal and straightforward, which resulted in a small attack surface and absence of security-
relevant issues
OPA is perfect for authorization purpose!
Penetration testing
Identified Vulnerabilities
OPA-01-001 Server: Insecure Default Config allows to bypass Policies
(Medium)
OPA-01-005 Server: OPA Query Interface is vulnerable to XSS (High)
Miscellaneous Issues
OPA-01-002 Server: Query Interface can be abused for SSRF (Medium)
OPA-01-003 Server: Unintended Behavior due to unclear Documentation
(Medium)
OPA-01-004 Server: Denial of Service via GZip Bomb in Bundle (Info)
OPA-01-006 Server: Path Mismatching via HTTP Redirects (Info) Conclusions
Introduct
Penetration testing
What is more, the shared documentation was unclear and misleading
at times (see OPA-01-001), so that arriving at a secure configuration
and integration would require a user to have an extensive and nearly-
internal-level of knowledge. As people normally cannot be expected
“to know what to look for”, this poses a risk of insecure configurations.
Conclusion
• Deadly hard to find proper code samples
• Even though documentation is huge
• Active development phase
• A lot of use cases not limited to configuration checks
• Safety confirmed by penetration tests
• UI is absent
• Native language is perfect to express policies
• Try to learn Rego
• Fregot is perfect for debug
Q&A
We are hiring!
Mail: shtock@mail.ru
Socials: https://www.linkedin.com/in/alexander-tokarev-14bab230/

More Related Content

PPTX
PPTX
Cloud DWH deep dive
PDF
SQL in the Hybrid World
PPTX
Relational databases for BigData
PPTX
Oracle InMemory hardcore edition
PDF
Avoid boring work_v2
PPTX
Gs08 modernize your data platform with sql technologies wash dc
PPTX
Tagging search solution design
Cloud DWH deep dive
SQL in the Hybrid World
Relational databases for BigData
Oracle InMemory hardcore edition
Avoid boring work_v2
Gs08 modernize your data platform with sql technologies wash dc
Tagging search solution design

What's hot (20)

PPTX
TPC-H in MongoDB
PPTX
Sql server 2016 it just runs faster sql bits 2017 edition
PDF
Why we love pgpool-II and why we hate it!
PDF
GNW01: In-Memory Processing for Databases
PPTX
SQL Server It Just Runs Faster
PPTX
Evolving Streaming Applications
PPTX
Enhancements that will make your sql database roar sp1 edition sql bits 2017
PPTX
Drupal commerce performance profiling and tunning using loadstorm experiments...
PDF
Oracle 12c Parallel Execution New Features
PDF
Serverless and you - where do i run my stateless code
PPTX
SQL Server In-Memory OLTP: What Every SQL Professional Should Know
PPTX
Brk3288 sql server v.next with support on linux, windows and containers was...
PPTX
Faceted search with Oracle InMemory option
PDF
Developing PostgreSQL Performance, Simon Riggs
PPTX
Inside SQL Server In-Memory OLTP
PDF
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
PDF
Oracle GoldenGate Presentation from OTN Virtual Technology Summit - 7/9/14 (PDF)
KEY
Hibernate performance tuning
PDF
User Defined Partitioning on PlazmaDB
PDF
Lessons PostgreSQL learned from commercial databases, and didn’t
TPC-H in MongoDB
Sql server 2016 it just runs faster sql bits 2017 edition
Why we love pgpool-II and why we hate it!
GNW01: In-Memory Processing for Databases
SQL Server It Just Runs Faster
Evolving Streaming Applications
Enhancements that will make your sql database roar sp1 edition sql bits 2017
Drupal commerce performance profiling and tunning using loadstorm experiments...
Oracle 12c Parallel Execution New Features
Serverless and you - where do i run my stateless code
SQL Server In-Memory OLTP: What Every SQL Professional Should Know
Brk3288 sql server v.next with support on linux, windows and containers was...
Faceted search with Oracle InMemory option
Developing PostgreSQL Performance, Simon Riggs
Inside SQL Server In-Memory OLTP
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Oracle GoldenGate Presentation from OTN Virtual Technology Summit - 7/9/14 (PDF)
Hibernate performance tuning
User Defined Partitioning on PlazmaDB
Lessons PostgreSQL learned from commercial databases, and didn’t
Ad

Similar to Open Policy Agent for governance as a code (20)

PPTX
Automating Your Salt Tests
PDF
Agile infrastructure
PPTX
Change management in hybrid landscapes
PPTX
Cerberus_Presentation1
PPTX
Cerberus : Framework for Manual and Automated Testing (Web Application)
PPTX
Webinar June 2017 l Apica LoadTest to compliment HP Loadrunner
PDF
Building Awesome APIs with Lumen
PPTX
Apache Cloudstack QA Strategy
PDF
stackconf 2024 | How to hack and defend (your) open source by Roman Zhukov.pdf
PPTX
Cloud Platform Symantec Meetup Nov 2014
PDF
Tame the Mesh An intro to cross-platform tracing and troubleshooting.pdf
PDF
TestMaker Object Designer Training - Basics
PPTX
Test-Driven-Development for Networking: Making CI Work for You by Colin McNam...
PDF
DrupalCamp LA 2014 - A Perfect Launch, Every Time
PPTX
API Testing with Open Source Code and Cucumber
PPTX
Version Control and Continuous Integration
PPTX
What's new in NGINX Plus R19
PDF
What Is New In TestMaker 6.5
PPTX
Simplifying Hyper-V Management for VMware Administrators
PDF
Middleware in Golang: InVision's Rye
Automating Your Salt Tests
Agile infrastructure
Change management in hybrid landscapes
Cerberus_Presentation1
Cerberus : Framework for Manual and Automated Testing (Web Application)
Webinar June 2017 l Apica LoadTest to compliment HP Loadrunner
Building Awesome APIs with Lumen
Apache Cloudstack QA Strategy
stackconf 2024 | How to hack and defend (your) open source by Roman Zhukov.pdf
Cloud Platform Symantec Meetup Nov 2014
Tame the Mesh An intro to cross-platform tracing and troubleshooting.pdf
TestMaker Object Designer Training - Basics
Test-Driven-Development for Networking: Making CI Work for You by Colin McNam...
DrupalCamp LA 2014 - A Perfect Launch, Every Time
API Testing with Open Source Code and Cucumber
Version Control and Continuous Integration
What's new in NGINX Plus R19
What Is New In TestMaker 6.5
Simplifying Hyper-V Management for VMware Administrators
Middleware in Golang: InVision's Rye
Ad

More from Alexander Tokarev (18)

PPTX
Rate limits and all about
PPTX
rnd teams.pptx
PPTX
FinOps for private cloud
PPTX
Graph ql and enterprise
PPTX
FinOps introduction
PPTX
P9 speed of-light faceted search via oracle in-memory option by alexander tok...
PPTX
Row Level Security in databases advanced edition
PPTX
Row level security in enterprise applications
PPTX
Inmemory BI based on opensource stack
PPTX
Tagging search solution design Advanced edition
PPTX
Oracle JSON treatment evolution - from 12.1 to 18 AOUG-2018
PPTX
Oracle JSON internals advanced edition
PPTX
Oracle Result Cache deep dive
PPTX
Oracle result cache highload 2017
PPTX
Oracle json caveats
PPTX
Apache Solr for begginers
PPTX
Data structures for cloud tag storage
PPT
Oracle High Availabiltity for application developers
Rate limits and all about
rnd teams.pptx
FinOps for private cloud
Graph ql and enterprise
FinOps introduction
P9 speed of-light faceted search via oracle in-memory option by alexander tok...
Row Level Security in databases advanced edition
Row level security in enterprise applications
Inmemory BI based on opensource stack
Tagging search solution design Advanced edition
Oracle JSON treatment evolution - from 12.1 to 18 AOUG-2018
Oracle JSON internals advanced edition
Oracle Result Cache deep dive
Oracle result cache highload 2017
Oracle json caveats
Apache Solr for begginers
Data structures for cloud tag storage
Oracle High Availabiltity for application developers

Recently uploaded (20)

PPTX
Fundamentals of Mechanical Engineering.pptx
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PPT
Total quality management ppt for engineering students
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PPTX
Feature types and data preprocessing steps
PPTX
Management Information system : MIS-e-Business Systems.pptx
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PPTX
Information Storage and Retrieval Techniques Unit III
PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PDF
Soil Improvement Techniques Note - Rabbi
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PPTX
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
PPTX
Software Engineering and software moduleing
PDF
737-MAX_SRG.pdf student reference guides
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PPT
Occupational Health and Safety Management System
Fundamentals of Mechanical Engineering.pptx
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Total quality management ppt for engineering students
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
Feature types and data preprocessing steps
Management Information system : MIS-e-Business Systems.pptx
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Categorization of Factors Affecting Classification Algorithms Selection
Information Storage and Retrieval Techniques Unit III
"Array and Linked List in Data Structures with Types, Operations, Implementat...
Soil Improvement Techniques Note - Rabbi
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
Software Engineering and software moduleing
737-MAX_SRG.pdf student reference guides
R24 SURVEYING LAB MANUAL for civil enggi
Exploratory_Data_Analysis_Fundamentals.pdf
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
Occupational Health and Safety Management System

Open Policy Agent for governance as a code