Lesson 14 / الدرس 14
Other people's code, running as you / كود غيرك، يعمل بصفتك
Every library you install runs with your application's full permissions, and every one you do not update accumulates published vulnerabilities. Both facts point the same way: take fewer dependencies, and update the ones you take.
كل مكتبة تثبّتها تعمل بصلاحيات تطبيقك كاملة، وكل واحدة لا تحدّثها تراكم ثغرات منشورة. والحقيقتان تشيران إلى الجهة نفسها: خذ اعتماديات أقل، وحدّث ما تأخذه.
A dependency is not a tool you use; it is code that runs inside your application with the same access you have. It can read your configuration, query your database and make network requests, and so can everything it depends on — a list you have usually never read and that grows without your involvement.
The question to ask before installing anything
-
How much of this do I need? A package to check whether a string is empty is a real thing that real projects install. If the answer is a few lines, write the few lines. كم أحتاج من هذا؟ فحزمةٌ لفحص أنصٌّ فارغ أم لا شيءٌ حقيقي تثبّته مشاريع حقيقية. وإن كان الجواب بضعة أسطر، فاكتب البضعة أسطر.
-
What does it bring with it? One package can pull in forty. Look at the count before installing, not after, because removing it later removes only the one you named. وماذا تجلب معها؟ فحزمة واحدة قد تجرّ أربعين. انظر إلى العدد قبل التثبيت لا بعده، لأن إزالتها لاحقًا لا تزيل إلا ما سمّيته.
-
Is anyone maintaining it? Last release, open issues, how many people can publish a new version. A widely used package with one maintainer is a risk to that person as much as to you. وأيصونها أحد؟ آخر إصدار، والمسائل المفتوحة، وكم شخصًا يستطيع نشر إصدار جديد. فالحزمة واسعة الاستخدام بصائن واحد خطرٌ على ذلك الشخص بقدر ما هي عليك.
-
What happens if it stops? Not hypothetical — packages get abandoned, renamed, and occasionally deleted. Something you could replace in a day is a different proposition from something woven through every file. وماذا لو توقفت؟ ليس افتراضيًا — فالحزم تُهجر وتُعاد تسميتها وتُحذف أحيانًا. وما تستطيع استبداله في يوم أمرٌ مختلف عمّا هو منسوج في كل ملف.
# What am I actually running, and is any of it known-vulnerable?
$ composer show --tree | head -40
$ composer audit
# What would updating change? Read this before running it.
$ composer outdated --direct
# composer.lock is COMMITTED. It records the exact versions that were
# tested, so the server installs what you tested rather than whatever
# is newest at the moment it happens to deploy.
$ composer install --no-dev --optimize-autoloader
# NOT 'composer update' on the server. That resolves fresh versions
# nobody has run, during a deploy, which is the worst possible moment
# to first meet a breaking change.
install reproduces what you tested; update decides something new. Updating is a change like any other — it happens on your machine, the tests run, and it goes out as its own deploy. install تعيد إنتاج ما اختبرته؛ وupdate تقرر شيئًا جديدًا. والتحديث تغييرٌ كأي تغيير — يقع على جهازك، وتعمل الاختبارات، ويخرج نشرًا مستقلًّا.Updating is a risk; not updating is a bigger one
Teams avoid updates because an update can break something, and end up two years behind with an upgrade nobody can afford to attempt. Meanwhile every vulnerability found in those two years is published, with the version numbers affected, in a database anyone can search. Staying current is not about new features; it is that the alternative is a public list of ways into your site.
Check yourself / اختبر نفسك
1. What permissions does a library you install run with?
There is no permission boundary between your code and a dependency. That is why the number of them, and who can publish a new version of each, is worth knowing.
2. Why run composer install rather than composer update on the server?
A deploy is the worst possible moment to first meet a breaking change. Updating is a change like any other: it happens locally, the tests run, and it ships on its own.
3. Why is staying two years behind on updates dangerous?
Not updating feels like avoiding risk and is accumulating a different one — a public, searchable list of ways into your site.
Score / النتيجة: 0 / 3