aird 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aird-0.1/LICENSE +21 -0
- aird-0.1/MANIFEST.in +4 -0
- aird-0.1/PKG-INFO +139 -0
- aird-0.1/README.md +113 -0
- aird-0.1/aird/__init__.py +0 -0
- aird-0.1/aird/__main__.py +4 -0
- aird-0.1/aird/main.py +486 -0
- aird-0.1/aird/templates/admin.html +42 -0
- aird-0.1/aird/templates/admin_login.html +29 -0
- aird-0.1/aird/templates/browse.html +461 -0
- aird-0.1/aird/templates/directory.html +144 -0
- aird-0.1/aird/templates/file.html +226 -0
- aird-0.1/aird/templates/login.html +34 -0
- aird-0.1/aird.egg-info/PKG-INFO +139 -0
- aird-0.1/aird.egg-info/SOURCES.txt +23 -0
- aird-0.1/aird.egg-info/dependency_links.txt +1 -0
- aird-0.1/aird.egg-info/entry_points.txt +2 -0
- aird-0.1/aird.egg-info/requires.txt +5 -0
- aird-0.1/aird.egg-info/top_level.txt +1 -0
- aird-0.1/requirements.txt +5 -0
- aird-0.1/setup.cfg +4 -0
- aird-0.1/setup.py +35 -0
- aird-0.1/tests/test_dos_large_file.py +53 -0
- aird-0.1/tests/test_path_traversal.py +60 -0
- aird-0.1/tests/test_websocket_origin.py +39 -0
aird-0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) 2024 Viswantha Srinivas P
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software for non-commercial purposes, without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
7
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom
|
|
8
|
+
the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
For commercial use, direct consent from Viswantha Srinivas P is required.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
aird-0.1/MANIFEST.in
ADDED
aird-0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aird
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: Aird - A lightweight web-based file browser and streamer
|
|
5
|
+
Author: Viswantha Srinivas P
|
|
6
|
+
Author-email:
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: pip==25.1.1
|
|
14
|
+
Requires-Dist: setuptools==80.3.1
|
|
15
|
+
Requires-Dist: tornado==6.5.1
|
|
16
|
+
Requires-Dist: wheel==0.45.1
|
|
17
|
+
Requires-Dist: ldap3==2.9.1
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: classifier
|
|
20
|
+
Dynamic: description
|
|
21
|
+
Dynamic: description-content-type
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
Dynamic: requires-dist
|
|
24
|
+
Dynamic: requires-python
|
|
25
|
+
Dynamic: summary
|
|
26
|
+
|
|
27
|
+
# Aird - A Web-Based File Browser and Streamer
|
|
28
|
+
|
|
29
|
+
Aird is a lightweight, web-based file browser built with Python and Tornado. It provides a simple and secure interface for browsing local directories, uploading files (including nested folders via drag-and-drop), and streaming file content in real-time, similar to `tail -f`.
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- **File & Directory Browsing:** Navigate your local filesystem through a clean, black-and-white themed web interface.
|
|
34
|
+
- **Drag-and-Drop Uploads:** Easily upload files and entire folder structures by dragging them into the browser window.
|
|
35
|
+
- **Real-Time File Streaming:** Open any file in streaming mode to see new lines appended in real-time, perfect for monitoring logs or other active files. The stream will also show the last 100 lines for immediate context.
|
|
36
|
+
- **Secure Access:** The entire application is protected by a token-based authentication system.
|
|
37
|
+
- **Admin Panel:** A separate admin panel to enable/disable features like file upload, delete, and rename.
|
|
38
|
+
- **Rename & Delete:** Quickly rename or remove files and folders directly from the directory listing.
|
|
39
|
+
- **Configurable:** Specify the root directory, port, and token via a JSON config file or command-line options.
|
|
40
|
+
|
|
41
|
+
## Setup and Installation
|
|
42
|
+
|
|
43
|
+
1. **Install Dependencies:**
|
|
44
|
+
```bash
|
|
45
|
+
pip install -r requirements.txt
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
2. **Run the Application:**
|
|
49
|
+
```bash
|
|
50
|
+
python -m aird --root /path/to/serve --port 8000 --token YOUR_TOKEN --admin-token YOUR_ADMIN_TOKEN
|
|
51
|
+
```
|
|
52
|
+
You can also create a JSON file with `root`, `port`, `token`, and `admin_token` keys and pass it using `--config config.json`.
|
|
53
|
+
If no token is provided, a random one will be generated and printed to the console.
|
|
54
|
+
|
|
55
|
+
## Endpoints
|
|
56
|
+
|
|
57
|
+
All endpoints (except the login page itself) require a valid authentication token, which is set as a secure cookie upon login.
|
|
58
|
+
|
|
59
|
+
### `GET /`
|
|
60
|
+
- **Description:** The main endpoint for browsing files and directories. It displays the contents of the configured root directory.
|
|
61
|
+
- **Usage:** Navigate to the root URL to start browsing.
|
|
62
|
+
|
|
63
|
+
### `GET /<path:path>`
|
|
64
|
+
- **Description:** Renders a directory listing or a file view, depending on the path.
|
|
65
|
+
- **Usage:**
|
|
66
|
+
- If `<path>` is a directory, it shows the contents of that directory.
|
|
67
|
+
- If `<path>` is a file, it displays the file's content and provides "Download" and "Stream" options.
|
|
68
|
+
|
|
69
|
+
### `GET /login`
|
|
70
|
+
- **Description:** Displays the login page where you can enter your access token.
|
|
71
|
+
|
|
72
|
+
### `POST /login`
|
|
73
|
+
- **Description:** Handles the authentication process.
|
|
74
|
+
- **Body:** `token=<your_access_token>`
|
|
75
|
+
- **On Success:** Sets a secure cookie and redirects to `/`.
|
|
76
|
+
- **On Failure:** Reloads the login page with an error message.
|
|
77
|
+
|
|
78
|
+
### `GET /admin/login`
|
|
79
|
+
- **Description:** Displays the admin login page.
|
|
80
|
+
|
|
81
|
+
### `POST /admin/login`
|
|
82
|
+
- **Description:** Handles admin authentication.
|
|
83
|
+
- **Body:** `token=<your_admin_token>`
|
|
84
|
+
- **On Success:** Sets a secure admin cookie and redirects to `/admin`.
|
|
85
|
+
- **On Failure:** Reloads the admin login page with an error message.
|
|
86
|
+
|
|
87
|
+
### `GET /admin`
|
|
88
|
+
- **Description:** Displays the admin panel with feature flags.
|
|
89
|
+
|
|
90
|
+
### `POST /admin`
|
|
91
|
+
- **Description:** Updates the feature flags.
|
|
92
|
+
- **Body:** `file_upload=on/off&file_delete=on/off&file_rename=on/off`
|
|
93
|
+
|
|
94
|
+
### `POST /upload`
|
|
95
|
+
- **Description:** Handles file and folder uploads. This endpoint is used by the drag-and-drop interface.
|
|
96
|
+
- **Body:** `multipart/form-data` containing the files and the target directory.
|
|
97
|
+
- **Usage:** Drag files/folders into the drop zone on the directory listing page. The frontend handles the request automatically.
|
|
98
|
+
|
|
99
|
+
### `POST /delete`
|
|
100
|
+
- **Description:** Deletes a file or directory.
|
|
101
|
+
- **Body:** `path=<target_path>`
|
|
102
|
+
- **Usage:** Triggered via the "Delete" button next to each item in the directory listing.
|
|
103
|
+
|
|
104
|
+
### `POST /rename`
|
|
105
|
+
- **Description:** Renames a file or directory.
|
|
106
|
+
- **Body:** `path=<target_path>&new_name=<new_name>`
|
|
107
|
+
- **Usage:** Triggered via the "Rename" button next to each item in the directory listing.
|
|
108
|
+
|
|
109
|
+
### `WS /stream/<path:path>`
|
|
110
|
+
- **Description:** A WebSocket endpoint for real-time file streaming.
|
|
111
|
+
- **Authentication:** Requires a valid session cookie.
|
|
112
|
+
- **Usage:** When a user clicks the "Stream" button, a WebSocket connection is established to this endpoint. The server will first send the last 100 lines of the file and then continue to send new lines as they are appended.
|
|
113
|
+
|
|
114
|
+
## Security TODO
|
|
115
|
+
|
|
116
|
+
This section tracks known security vulnerabilities that should be addressed.
|
|
117
|
+
|
|
118
|
+
- [ ] **Path Traversal on Upload:** The single-file upload handler in `UploadHandler` does not properly sanitize the `filename`. An attacker could use a filename like `../../malicious.txt` to write files to arbitrary locations on the server. The `os.path.join` and `os.path.abspath` combination needs to be carefully validated to ensure the final path is within the intended directory.
|
|
119
|
+
- [ ] **Denial of Service (DoS) via Large Files:** The application reads entire files into memory for both viewing and uploading without any size limits. An attacker could upload or request to view a very large file, exhausting server memory and causing a crash. Implement file size limits for uploads and consider streaming or paginating large files for viewing.
|
|
120
|
+
- [ ] **Missing CSRF Protection:** The application does not use Cross-Site Request Forgery (CSRF) protection. This makes `POST` endpoints, like file uploads, vulnerable. An attacker could trick a logged-in user into visiting a malicious site that forges a request to upload a file to the server without the user's consent. Tornado's built-in `xsrf_cookies=True` setting should be enabled.
|
|
121
|
+
- [ ] **Disabled WebSocket Origin Check:** The `FileStreamHandler` allows WebSocket connections from any origin (`check_origin` always returns `True`). This should be restricted to only allow connections from the application's own domain to prevent cross-site WebSocket hijacking attacks.
|
|
122
|
+
|
|
123
|
+
## Future Enhancements
|
|
124
|
+
|
|
125
|
+
### UI/UX Improvements
|
|
126
|
+
- [ ] **Modern UI:** Enhance the interface with a lightweight CSS framework like Bootstrap or Tailwind CSS.
|
|
127
|
+
- [ ] **File Previews:** Add support for in-browser previews for common file types (images, PDFs, Markdown).
|
|
128
|
+
- [ ] **Search and Sort:** Add a search bar and make the directory listing sortable by name, size, or modification date.
|
|
129
|
+
|
|
130
|
+
### Core Functionality
|
|
131
|
+
- [ ] **Multi-File Operations:** Allow users to select multiple files/folders for batch actions (e.g., delete, download as zip).
|
|
132
|
+
- [ ] **In-Browser File Editor:** Embed a code editor like CodeMirror or Monaco to allow for in-browser text file editing.
|
|
133
|
+
- [ ] **User Management:** Expand to a full user management system with different roles and permissions.
|
|
134
|
+
- [ ] **Advanced Permissions:** Implement a role-based permission system (e.g., read-only users, upload-only users).
|
|
135
|
+
- [ ] **Create Files and Folders:** Add UI elements to create new empty files and folders.
|
|
136
|
+
|
|
137
|
+
### Performance
|
|
138
|
+
- [ ] **Asynchronous File I/O:** Use `aiofiles` to perform file operations asynchronously.
|
|
139
|
+
- [ ] **Pagination for Large Directories:** Implement pagination for directories with a large number of files.
|
aird-0.1/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Aird - A Web-Based File Browser and Streamer
|
|
2
|
+
|
|
3
|
+
Aird is a lightweight, web-based file browser built with Python and Tornado. It provides a simple and secure interface for browsing local directories, uploading files (including nested folders via drag-and-drop), and streaming file content in real-time, similar to `tail -f`.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **File & Directory Browsing:** Navigate your local filesystem through a clean, black-and-white themed web interface.
|
|
8
|
+
- **Drag-and-Drop Uploads:** Easily upload files and entire folder structures by dragging them into the browser window.
|
|
9
|
+
- **Real-Time File Streaming:** Open any file in streaming mode to see new lines appended in real-time, perfect for monitoring logs or other active files. The stream will also show the last 100 lines for immediate context.
|
|
10
|
+
- **Secure Access:** The entire application is protected by a token-based authentication system.
|
|
11
|
+
- **Admin Panel:** A separate admin panel to enable/disable features like file upload, delete, and rename.
|
|
12
|
+
- **Rename & Delete:** Quickly rename or remove files and folders directly from the directory listing.
|
|
13
|
+
- **Configurable:** Specify the root directory, port, and token via a JSON config file or command-line options.
|
|
14
|
+
|
|
15
|
+
## Setup and Installation
|
|
16
|
+
|
|
17
|
+
1. **Install Dependencies:**
|
|
18
|
+
```bash
|
|
19
|
+
pip install -r requirements.txt
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
2. **Run the Application:**
|
|
23
|
+
```bash
|
|
24
|
+
python -m aird --root /path/to/serve --port 8000 --token YOUR_TOKEN --admin-token YOUR_ADMIN_TOKEN
|
|
25
|
+
```
|
|
26
|
+
You can also create a JSON file with `root`, `port`, `token`, and `admin_token` keys and pass it using `--config config.json`.
|
|
27
|
+
If no token is provided, a random one will be generated and printed to the console.
|
|
28
|
+
|
|
29
|
+
## Endpoints
|
|
30
|
+
|
|
31
|
+
All endpoints (except the login page itself) require a valid authentication token, which is set as a secure cookie upon login.
|
|
32
|
+
|
|
33
|
+
### `GET /`
|
|
34
|
+
- **Description:** The main endpoint for browsing files and directories. It displays the contents of the configured root directory.
|
|
35
|
+
- **Usage:** Navigate to the root URL to start browsing.
|
|
36
|
+
|
|
37
|
+
### `GET /<path:path>`
|
|
38
|
+
- **Description:** Renders a directory listing or a file view, depending on the path.
|
|
39
|
+
- **Usage:**
|
|
40
|
+
- If `<path>` is a directory, it shows the contents of that directory.
|
|
41
|
+
- If `<path>` is a file, it displays the file's content and provides "Download" and "Stream" options.
|
|
42
|
+
|
|
43
|
+
### `GET /login`
|
|
44
|
+
- **Description:** Displays the login page where you can enter your access token.
|
|
45
|
+
|
|
46
|
+
### `POST /login`
|
|
47
|
+
- **Description:** Handles the authentication process.
|
|
48
|
+
- **Body:** `token=<your_access_token>`
|
|
49
|
+
- **On Success:** Sets a secure cookie and redirects to `/`.
|
|
50
|
+
- **On Failure:** Reloads the login page with an error message.
|
|
51
|
+
|
|
52
|
+
### `GET /admin/login`
|
|
53
|
+
- **Description:** Displays the admin login page.
|
|
54
|
+
|
|
55
|
+
### `POST /admin/login`
|
|
56
|
+
- **Description:** Handles admin authentication.
|
|
57
|
+
- **Body:** `token=<your_admin_token>`
|
|
58
|
+
- **On Success:** Sets a secure admin cookie and redirects to `/admin`.
|
|
59
|
+
- **On Failure:** Reloads the admin login page with an error message.
|
|
60
|
+
|
|
61
|
+
### `GET /admin`
|
|
62
|
+
- **Description:** Displays the admin panel with feature flags.
|
|
63
|
+
|
|
64
|
+
### `POST /admin`
|
|
65
|
+
- **Description:** Updates the feature flags.
|
|
66
|
+
- **Body:** `file_upload=on/off&file_delete=on/off&file_rename=on/off`
|
|
67
|
+
|
|
68
|
+
### `POST /upload`
|
|
69
|
+
- **Description:** Handles file and folder uploads. This endpoint is used by the drag-and-drop interface.
|
|
70
|
+
- **Body:** `multipart/form-data` containing the files and the target directory.
|
|
71
|
+
- **Usage:** Drag files/folders into the drop zone on the directory listing page. The frontend handles the request automatically.
|
|
72
|
+
|
|
73
|
+
### `POST /delete`
|
|
74
|
+
- **Description:** Deletes a file or directory.
|
|
75
|
+
- **Body:** `path=<target_path>`
|
|
76
|
+
- **Usage:** Triggered via the "Delete" button next to each item in the directory listing.
|
|
77
|
+
|
|
78
|
+
### `POST /rename`
|
|
79
|
+
- **Description:** Renames a file or directory.
|
|
80
|
+
- **Body:** `path=<target_path>&new_name=<new_name>`
|
|
81
|
+
- **Usage:** Triggered via the "Rename" button next to each item in the directory listing.
|
|
82
|
+
|
|
83
|
+
### `WS /stream/<path:path>`
|
|
84
|
+
- **Description:** A WebSocket endpoint for real-time file streaming.
|
|
85
|
+
- **Authentication:** Requires a valid session cookie.
|
|
86
|
+
- **Usage:** When a user clicks the "Stream" button, a WebSocket connection is established to this endpoint. The server will first send the last 100 lines of the file and then continue to send new lines as they are appended.
|
|
87
|
+
|
|
88
|
+
## Security TODO
|
|
89
|
+
|
|
90
|
+
This section tracks known security vulnerabilities that should be addressed.
|
|
91
|
+
|
|
92
|
+
- [ ] **Path Traversal on Upload:** The single-file upload handler in `UploadHandler` does not properly sanitize the `filename`. An attacker could use a filename like `../../malicious.txt` to write files to arbitrary locations on the server. The `os.path.join` and `os.path.abspath` combination needs to be carefully validated to ensure the final path is within the intended directory.
|
|
93
|
+
- [ ] **Denial of Service (DoS) via Large Files:** The application reads entire files into memory for both viewing and uploading without any size limits. An attacker could upload or request to view a very large file, exhausting server memory and causing a crash. Implement file size limits for uploads and consider streaming or paginating large files for viewing.
|
|
94
|
+
- [ ] **Missing CSRF Protection:** The application does not use Cross-Site Request Forgery (CSRF) protection. This makes `POST` endpoints, like file uploads, vulnerable. An attacker could trick a logged-in user into visiting a malicious site that forges a request to upload a file to the server without the user's consent. Tornado's built-in `xsrf_cookies=True` setting should be enabled.
|
|
95
|
+
- [ ] **Disabled WebSocket Origin Check:** The `FileStreamHandler` allows WebSocket connections from any origin (`check_origin` always returns `True`). This should be restricted to only allow connections from the application's own domain to prevent cross-site WebSocket hijacking attacks.
|
|
96
|
+
|
|
97
|
+
## Future Enhancements
|
|
98
|
+
|
|
99
|
+
### UI/UX Improvements
|
|
100
|
+
- [ ] **Modern UI:** Enhance the interface with a lightweight CSS framework like Bootstrap or Tailwind CSS.
|
|
101
|
+
- [ ] **File Previews:** Add support for in-browser previews for common file types (images, PDFs, Markdown).
|
|
102
|
+
- [ ] **Search and Sort:** Add a search bar and make the directory listing sortable by name, size, or modification date.
|
|
103
|
+
|
|
104
|
+
### Core Functionality
|
|
105
|
+
- [ ] **Multi-File Operations:** Allow users to select multiple files/folders for batch actions (e.g., delete, download as zip).
|
|
106
|
+
- [ ] **In-Browser File Editor:** Embed a code editor like CodeMirror or Monaco to allow for in-browser text file editing.
|
|
107
|
+
- [ ] **User Management:** Expand to a full user management system with different roles and permissions.
|
|
108
|
+
- [ ] **Advanced Permissions:** Implement a role-based permission system (e.g., read-only users, upload-only users).
|
|
109
|
+
- [ ] **Create Files and Folders:** Add UI elements to create new empty files and folders.
|
|
110
|
+
|
|
111
|
+
### Performance
|
|
112
|
+
- [ ] **Asynchronous File I/O:** Use `aiofiles` to perform file operations asynchronously.
|
|
113
|
+
- [ ] **Pagination for Large Directories:** Implement pagination for directories with a large number of files.
|
|
File without changes
|