Nauka programowania php
Prosty kurs dla amatorów
Rozdział 27. Database Security
Nowadays, databases are cardinal components of any web based application by enabling websites to provide varying dynamic content. Since very sensitive or secret information can be stored in a database, you should strongly consider protecting your databases.
To retrieve or to store any information you need to connect to the database, send a legitimate query, fetch the result, and close the connection. Nowadays, the commonly used query language in this interaction is the Structured Query Language (SQL). See how an attacker can tamper with an SQL query.
As you can surmise, PHP cannot protect your database by itself. The following sections aim to be an introduction into the very basics of how to access and manipulate databases within PHP scripts.
Keep in mind this simple rule: defense in depth. The more places you take action to increase the protection of your database, the less probability of an attacker succeeding in exposing or abusing any stored information. Good design of the database schema and the application deals with your greatest fears.
Designing Databases
The first step is always to create the database, unless you want to use one from a third party. When a database is created, it is assigned to an owner, who executed the creation statement. Usually, only the owner (or a superuser) can do anything with the objects in that database, and in order to allow other users to use it, privileges must be granted.
Applications should never connect to the database as its owner or a superuser, because these users can execute any query at will, for example, modifying the schema (e.g. dropping tables) or deleting its entire content.
You may create different database users for every aspect of your application with very limited rights to database objects. The most required privileges should be granted only, and avoid that the same user can interact with the database in different use cases. This means that if intruders gain access to your database using your applications credentials, they can only effect as many changes as your application can.
You are encouraged not to implement all the business logic in the web application (i.e. your script), instead do it in the database schema using views, triggers or rules. If the system evolves, new ports will be intended to open to the database, and you have to re-implement the logic in each separate database client. Over and above, triggers can be used to transparently and automatically handle fields, which often provides insight when debugging problems with your application or tracing back transactions.
| Poprzedni | Spis treści | Następny |
| Filesystem Security | Początek rozdziału | Connecting to Database |
Newsy:
Nowości z listy dyskusyjnej
Mam taki test i co prawa ju¿ go pisa³em ale nie wiem jakie s± dobre odpowiedzi moze kto¶ mi pomo¿e??
http://www.kolejland.rail.pl/iz/Forum%20-%...wania/jipp2.jpg
Moje odpowiedzi to:
1. a
2. abc
3. bc
4. d
5. ad
Plisss bardzo potrzebny nam jest taki program!!!
Witam,
Jak w temacie zlecê napisanie od nowa lub zmodyfikowanie istniej±cej ju¿ wersji programu do obliczania sum md5. Zainteresowanych proszê o kontakt.
Autor strony Polishwords rozwa¿a przej¶cie na model Open Source. Aby u³atwiæ sobie decyzjê umie¶ci³ ankietê, w której mo¿na zag³osowaæ za albo przeciwko przej¶ciu na Open Source. Pomó¿my autorowi!
Strona Polishwords jest przeznaczona dla programistów i ogó³ informatyków. Zawiera filmy instrukta¿owe z programowania i zarz±dzania baz± danych. Autor rozwa¿a obecnie przej¶cie na model Open Source i opublikowanie kodu strony. Chcia³by przez to osi±gn±æ szybszy rozwój strony i zaanga¿owanie wiêkszej liczby programistów PHP.
W umieszczonej ankiecie mo¿na zag³osowaæ czy autor powinien przej¶æ na model Open Source. Pomó¿ podj±æ dobr± decyzjê autorowi.
Wiêcej na: http://polishwords.com.pl/blog/2008/polishwords-open-source/
Witam pisze program klient-serwer. Próba nr.1:
Skorzysta³em z najprostszech komponentów tego rodzaju czyli ClientSocket i ServerSocket. Posutawialem porty oraz ip w kliencie.
Je¿eli wpsize ip localhosta (127.0.0.1) to klient polaczy sie z serwerem. Jezeli wpisze IP wewnetrzne tez sie polaczy. Ale jezeli wpisze juz ip zewnetrzne to wyskauje blad asynohrous socket error 10061.
Podejscie nr.2
Zmieni³em komponenty na Indy. Wszystko zosta³o odpowiednio skofigurowane. Wiec sytuacja jest identyczna jak powyzej wszystko dziala na ip wewnetrznym i na localhoscie a na zewnetrznym juz. Prosze o pomoc w tej sprawie.
Mo¿e jeszcze dodam, ¿e jest w sieci typu WLan.
Pozdro
Prosze o jak najszybsza odpowiedz
Jak nie znasz jezyka C++ i wskaznikow i programowania obiektowego
Kurs
Kurs powstał w celu nauki podstawowych zagadnień z dziedziny php.
Losowe tagi:
commandlineapc
dba
lzf
oracle