-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from ilovenoah/136-add-return-403-forbidden-i…
…f-cgi-script-is-not-allowed-to-be-executed 136 add return 403 forbidden if cgi script is not allowed to be executed
- Loading branch information
Showing
6 changed files
with
76 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
tests/simple_server_function_test/request_file/cgi_invalid_unauthorized.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
host, localhost | ||
port, 8080 | ||
|
||
|
||
GET /cgi-bin/unauthorized_cgi_script.py HTTP/1.1 | ||
Host: test | ||
Connection: close |
5 changes: 5 additions & 0 deletions
5
tests/simple_server_function_test/response_file/cgi_invalid_unauthorized.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
HTTP/1.1 403 Forbidden | ||
Connection: close | ||
Content-Length: 9 | ||
|
||
Forbidden |
24 changes: 24 additions & 0 deletions
24
tests/simple_server_function_test/www/cgi-bin/unauthorized_cgi_script.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
|
||
# ステータスとコンテントタイプのヘッダーを出力 | ||
print("Status: 200 OK") | ||
print("Content-Type: text/html") | ||
print() # ヘッダーの終わりを示す空行 | ||
|
||
print("<!DOCTYPE html>") | ||
print("<html>") | ||
print("<head>") | ||
print("<title>CGI Environment Variables</title>") | ||
print("</head>") | ||
print("<body>") | ||
print("<h1>Environment Variables</h1>") | ||
print("<table border='1'>") | ||
print("<tr><th>Variable</th><th>Value</th></tr>") | ||
|
||
# 環境変数を取得してテーブルに表示 | ||
# for key, value in os.environ.items(): | ||
# print(f"<tr><td>{key}</td><td>{value}</td></tr>") | ||
|
||
print("</table>") | ||
print("</body>") | ||
print("</html>") |