백엔드 프로그래밍
도입됨
21:11
컴퓨팅 III: 데이터베이스 웹 앱 구축, 리 및 설명하기
컴퓨팅 III는 웹사이트와 데이터를 연결하고 SQL을 사용하여 의사결정을 지원하도록 요구합니다. 우리의 실습 문제는 어떤 교실에 자리가 남아 있는지입니다. 기록들은…
영어 내레이션 · 영어와 중국어 자막 전환 가능
이 수업의 내용
| English | 의미 |
|---|---|
| route/ruːt/ | 경로 |
| validate input/ˈvælɪdeɪt ˈɪnpʊt/ | 입력 검증 |
| status/ˈsteɪtəs/ | 상태 코드 |
| SQL injection/ˌes kjuː ˈel ɪnˈdʒekʃn/ | SQL 주입 공격 |
| parameterised query/ˌpærəˈmetəraɪzd ˈkwɪərɪ/ | 파라미터화 쿼리 |
A search string changes the query
- A name search receives
' OR 1=1 --. If code pastes it into SQL, the text may change the condition instead of remaining a name. - A route 路由 maps a request method and path to its handler. Keep the route contract clear before implementing the lookup.
Check shape and permission
- Validate input 校验输入 means checking required values, types, permitted lengths and ranges. Check the caller’s permission separately.
- A status 状态码 describes the result: 200 for this successful lookup, 400 for invalid input and 404 for a missing resource. Permission failures need the application’s agreed policy; they are not automatically bad input.
Implemented route 계약 하에 이러한 결과를 매칭하십시오.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
이 의미들은 자체적으로 개인 권한 실패가 어떻게 표현되어야 하는지를 정의하지 않습니다.
Keep values outside the SQL text
- SQL injection SQL 注入 happens when untrusted text becomes part of SQL syntax. A parameterised query 参数化查询 binds a value separately from the statement.
- Placeholders bind values, not arbitrary table names or sort directions. Choose such identifiers from a fixed server-side allowlist when a route needs them.

Which lookup keeps a submitted name separate from SQL syntax?
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
값 바인딩은 고정된 문장에서 값을 분리합니다.
SQL 플레이스홀더에 이름을 바인딩하는 것이 무엇을 변경하는지 설명하십시오.
난이도 3/5 · 200코인 + 오늘 첫 완료 시 작은 보너스 추가
명령문은 고정되어 있고, 별도로 바인딩된 값은 데이터로 남습니다.
플레이스홀더는 값을 바인딩하므로, 테이블명과 정렬 방향은 고정된 서버 측 허용 목록에서 가져와야 합니다.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
참. 플레이스홀더는 식별자를 안전하게 대변할 수 없으므로, 서버에서 알려진 안전한 옵션 중 동적 식별자를 선택해야 합니다.
Run a complete local example
- Save and run this Python example using SQLite. The unusual string is stored as a name, then searched as a bound value.
- The result contains only that named row. Binding prevents this value becoming SQL syntax; it does not establish permission or make every application secure.
import sqlite3
con = sqlite3.connect(":memory:")
con.execute("CREATE TABLE students (id INTEGER PRIMARY KEY, name TEXT)")
name = "' OR 1=1 --"
con.executemany("INSERT INTO students VALUES (?, ?)", [(1, "Mei"), (2, name)])
rows = con.execute("SELECT id FROM students WHERE name = ?", (name,)).fetchall()
print(rows) # [(2,)]
con.close()
완전한 SQLite 예제에서 출력되는 내용은 무엇인가?
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
특이한 문자열이 저장되고 리터럴 이름으로 매칭됩니다.
Keep failures useful and private
- Give the browser a clear message it can act on, such as an invalid field or a temporary failure. Do not return raw SQL errors, private credentials or stack traces.
- Record diagnostic details only in protected logs with sensitive values removed. Log enough context to investigate without copying every private request body.
일반 사용자에게 원본 데이터베이스 오류를 반환하여 SQL 디버깅을 할 수 있게 하십시오.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
유용하고 안전한 메시지를 반환하고; 진단 로그를 보호하며 민감한 값을 제거하십시오.
Verify more than a happy path
- Check valid, missing, wrong-type and oversized input; denied access; an empty match; and a simulated database failure. State the expected result for each.
- Keep every dynamic value bound, including dropdown values. The browser’s list does not prevent someone sending a different value directly.
Validate the request, authorize the caller and bind data values. These solve different problems; none replaces the others.
어떤 외부 입력에 대해 적절한 서버 검증이 필요한가? 모두 선택하십시오.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
평범해 보이는 외부 값도 잘못된 타입, 길이 또는 권한을 가질 수 있습니다.
쿼리가 파라미터화되었지만 모든 호출자가 개인 학생 행을 읽을 수 있습니다. Remaining(나머지)으로 빠진 것은 무엇인가?
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
바인딩은 값 주입의 주소를 지정할 뿐이며, 호출자의 권한을 부여하지 않습니다.
어떤 문제가 있었나요? 사이트 팀만 이 내용을 볼 수 있습니다.