0Pricing
Secure Coding & OWASP Top 10 for Backend · درس

أمان البنية التحتية كتعليمات برمجية

تعلّم كيفية تأمين البنية التحتية السحابية المعرّفة كتعليمات برمجية باستخدام Terraform، وفحص القوالب بحثًا عن أخطاء الإعداد، ومنع الانحراف والإعدادات الافتراضية غير الآمنة.

أمان البنية التحتية كتعليمات برمجية درس مجاني في Secure Coding & OWASP Top 10 for Backend على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Secure Coding & OWASP Top 10 for Backend، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Secure Coding & OWASP Top 10 for Backend 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

What Is IaC?

Infrastructure as Code (IaC) defines cloud resources in declarative files (Terraform, CloudFormation, Bicep) instead of clicking through consoles. It makes infrastructure repeatable, reviewable, and version-controlled.

That same automation means a single mistake can be deployed everywhere instantly.

Security Benefits of IaC

IaC enables security at scale:

  • Changes go through code review and version history
  • Configurations are consistent across environments
  • Security policies can be enforced automatically

The goal is to catch insecure config before it ever reaches the cloud.

Common Misconfigurations

The most frequent IaC security mistakes include:

  • Storage buckets open to the public
  • Security groups allowing 0.0.0.0/0 on sensitive ports
  • Unencrypted volumes and databases
  • Overly broad IAM permissions

An Insecure Example

This Terraform snippet exposes a database port to the entire internet.

resource 'aws_security_group_rule' 'db' {
  type        = 'ingress'
  from_port   = 5432
  to_port     = 5432
  protocol    = 'tcp'
  cidr_blocks = ['0.0.0.0/0']  # INSECURE: open to all
}

The Secure Version

Restrict access to a known private range and enforce encryption by default.

resource 'aws_security_group_rule' 'db' {
  type        = 'ingress'
  from_port   = 5432
  to_port     = 5432
  protocol    = 'tcp'
  cidr_blocks = ['10.0.1.0/24']  # private app subnet only
}

Static Scanning

Tools like Checkov, tfsec, and Terrascan scan IaC files for insecure patterns before deployment. Run them in CI so risky templates fail the build automatically.

# Example CI step (conceptual)
# checkov -d ./infra --quiet
rules_failed = ['CKV_AWS_24: SSH open to 0.0.0.0/0']
for r in rules_failed:
    print('FAIL', r)

Policy as Code

Policy as Code tools like Open Policy Agent (OPA) and Sentinel let you write rules such as 'no public buckets' that block non-compliant plans automatically, turning security standards into enforceable code.

Securing State Files

Terraform state can contain secrets and resource details. Store it in an encrypted, access-controlled backend (such as an encrypted S3 bucket with locking), never in the git repository.

  • Encrypt state at rest
  • Restrict who can read it
  • Enable state locking to prevent corruption

Avoiding Hardcoded Secrets

Never put credentials directly in IaC files. Reference a secrets manager or inject values at apply time so secrets never land in version control or state.

Detecting Drift

Drift happens when someone changes infrastructure manually, diverging from the code. Run drift detection regularly so unauthorized or accidental changes are caught and reconciled.

Least-Privilege Modules

Build reusable modules with secure defaults: encryption on, public access off, minimal IAM. Teams that consume hardened modules inherit good security without having to be experts.

Quick Check

Test your understanding of IaC security.

Recap

You learned how to secure Infrastructure as Code: review changes, scan templates with tools like Checkov, enforce policy as code, protect state files, keep secrets out of templates, and detect drift. Catching misconfiguration in code stops it before it reaches production.

الأسئلة الشائعة

هل درس «أمان البنية التحتية كتعليمات برمجية» مجاني؟

نعم — نص درس «أمان البنية التحتية كتعليمات برمجية» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Secure Coding & OWASP Top 10 for Backend، انتقل إلى CoddyKit PRO. تتضمن دورة Secure Coding & OWASP Top 10 for Backend 4 دروس في المجموع.

ماذا ستتعلم في «أمان البنية التحتية كتعليمات برمجية»؟

تعلّم كيفية تأمين البنية التحتية السحابية المعرّفة كتعليمات برمجية باستخدام Terraform، وفحص القوالب بحثًا عن أخطاء الإعداد، ومنع الانحراف والإعدادات الافتراضية غير الآمنة. تتمرن على Secure Coding & OWASP Top 10 for Backend مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Secure Coding & OWASP Top 10 for Backend؟

لا تُشترط خبرة سابقة. Secure Coding & OWASP Top 10 for Backend على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «أمان البنية التحتية كتعليمات برمجية»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Secure Coding & OWASP Top 10 for Backend هذا؟

نعم. كل درس في Secure Coding & OWASP Top 10 for Backend يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. النشر الآمن على السحابة (AWS/Azure/GCP)
  2. أمان الحاويات (Docker/Kubernetes)
  3. أفضل ممارسات أمان Serverless
  4. أمان البنية التحتية كتعليمات برمجية
← العودة إلى Secure Coding & OWASP Top 10 for Backend