Skip to content

Commit 562b5a4

Browse files
committed
Added some more instructions adjustments
1 parent a037ee2 commit 562b5a4

File tree

7 files changed

+56
-137
lines changed

7 files changed

+56
-137
lines changed

.cursor/copilot-instructions.md

Whitespace-only changes.

.cursor/rules/project-overview.mdc

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -117,94 +117,66 @@ Flight is highly extensible. Here are some recommended packages and plugins for
117117

118118
Choose the packages that best fit your project's needs. Official FlightPHP packages are recommended for core functionality.
119119

120-
## Security Best Practices
120+
## Security Best Practices (Condensed)
121121

122-
All code implemented in this project must follow secure coding best practices. Insecure code will not be accepted. Always assume user input is hostile and never trust data from users or external sources. The following guidelines and examples are required for all code contributions:
122+
All code must follow secure coding practices. Always treat user input as untrusted. Key requirements:
123123

124124
### Cross Site Scripting (XSS)
125-
- Always escape output from users before rendering in views.
126-
- Use Flight's view class or a templating engine like Latte, which auto-escapes variables.
127-
125+
- Always escape user output in views.
126+
- Use Flight’s view class or a templating engine (e.g., Latte) for auto-escaping.
128127
```php
129-
// Example: Escaping user input in views
130-
$name = '<script>alert("XSS")</script>';
131-
Flight::view()->set('name', $name); // Escapes output
132-
Flight::view()->render('template', ['name' => $name]); // Latte auto-escapes
128+
Flight::view()->set('name', $name);
129+
Flight::view()->render('template', ['name' => $name]);
133130
```
134131

135132
### SQL Injection
136-
- Never concatenate user input into SQL queries.
133+
- Never concatenate user input in SQL.
137134
- Always use prepared statements or parameterized queries.
138-
139135
```php
140-
// Secure: Using prepared statements
141136
$statement = Flight::db()->prepare('SELECT * FROM users WHERE username = :username');
142137
$statement->execute([':username' => $username]);
143-
$users = $statement->fetchAll();
144-
145-
// Or with PdoWrapper
146-
$users = Flight::db()->fetchAll('SELECT * FROM users WHERE username = :username', [ 'username' => $username ]);
147138
```
148139

149-
### CORS (Cross-Origin Resource Sharing)
150-
- Set CORS headers using a utility or middleware before Flight::start().
140+
### CORS
141+
- Set CORS headers via utility or middleware before `Flight::start()`.
151142
- Only allow trusted origins.
152-
153143
```php
154-
// Example: app/utils/CorsUtil.php
155-
namespace app\utils;
156-
class CorsUtil {
157-
public function set(array $params): void { /* ...see docs for full example... */ }
158-
private function allowOrigins(): void { /* ... */ }
159-
}
160-
// In index.php
161-
$CorsUtil = new CorsUtil();
162-
Flight::before('start', [ $CorsUtil, 'set' ]);
144+
Flight::before('start', [ (new CorsUtil()), 'set' ]);
163145
```
164146

165147
### Error Handling
166-
- Never display sensitive error details in production.
167-
- Log errors instead and use Flight::halt() for controlled responses.
168-
148+
- Don’t display sensitive errors in production; log them instead.
149+
- Use `Flight::halt()` for controlled responses.
169150
```php
170-
$environment = ENVIRONMENT;
171-
if ($environment === 'production') {
151+
if (ENVIRONMENT === 'production') {
172152
ini_set('display_errors', 0);
173153
ini_set('log_errors', 1);
174-
ini_set('error_log', '/path/to/error.log');
175154
}
176-
// Controlled error response
177155
Flight::halt(403, 'Access denied');
178156
```
179157

180158
### Input Sanitization
181-
- Always sanitize and validate user input before processing.
182-
159+
- Sanitize and validate all user input.
183160
```php
184161
$clean_input = filter_var(Flight::request()->data->input, FILTER_SANITIZE_STRING);
185-
$clean_email = filter_var(Flight::request()->data->email, FILTER_SANITIZE_EMAIL);
186162
```
187163

188164
### Password Hashing
189-
- Always hash passwords using PHP's built-in functions. Never store plain text passwords.
190-
165+
- Always hash passwords; never store plain text.
191166
```php
192167
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
193168
if (password_verify($password, $stored_hash)) { /* Password matches */ }
194169
```
195170

196171
### Rate Limiting
197-
- Use caching or middleware to limit repeated requests and prevent brute force attacks.
198-
172+
- Use caching or middleware to limit repeated requests.
199173
```php
200174
Flight::before('start', function() {
201175
$cache = Flight::cache();
202176
$ip = Flight::request()->ip;
203177
$key = "rate_limit_{$ip}";
204178
$attempts = (int) $cache->retrieve($key);
205-
if ($attempts >= 10) {
206-
Flight::halt(429, 'Too many requests');
207-
}
179+
if ($attempts >= 10) Flight::halt(429, 'Too many requests');
208180
$cache->set($key, $attempts + 1, 60);
209181
});
210182
```

.github/copilot-instructions.md

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -117,94 +117,66 @@ Flight is highly extensible. Here are some recommended packages and plugins for
117117

118118
Choose the packages that best fit your project's needs. Official FlightPHP packages are recommended for core functionality.
119119

120-
## Security Best Practices
120+
## Security Best Practices (Condensed)
121121

122-
All code implemented in this project must follow secure coding best practices. Insecure code will not be accepted. Always assume user input is hostile and never trust data from users or external sources. The following guidelines and examples are required for all code contributions:
122+
All code must follow secure coding practices. Always treat user input as untrusted. Key requirements:
123123

124124
### Cross Site Scripting (XSS)
125-
- Always escape output from users before rendering in views.
126-
- Use Flight's view class or a templating engine like Latte, which auto-escapes variables.
127-
125+
- Always escape user output in views.
126+
- Use Flight’s view class or a templating engine (e.g., Latte) for auto-escaping.
128127
```php
129-
// Example: Escaping user input in views
130-
$name = '<script>alert("XSS")</script>';
131-
Flight::view()->set('name', $name); // Escapes output
132-
Flight::view()->render('template', ['name' => $name]); // Latte auto-escapes
128+
Flight::view()->set('name', $name);
129+
Flight::view()->render('template', ['name' => $name]);
133130
```
134131

135132
### SQL Injection
136-
- Never concatenate user input into SQL queries.
133+
- Never concatenate user input in SQL.
137134
- Always use prepared statements or parameterized queries.
138-
139135
```php
140-
// Secure: Using prepared statements
141136
$statement = Flight::db()->prepare('SELECT * FROM users WHERE username = :username');
142137
$statement->execute([':username' => $username]);
143-
$users = $statement->fetchAll();
144-
145-
// Or with PdoWrapper
146-
$users = Flight::db()->fetchAll('SELECT * FROM users WHERE username = :username', [ 'username' => $username ]);
147138
```
148139

149-
### CORS (Cross-Origin Resource Sharing)
150-
- Set CORS headers using a utility or middleware before Flight::start().
140+
### CORS
141+
- Set CORS headers via utility or middleware before `Flight::start()`.
151142
- Only allow trusted origins.
152-
153143
```php
154-
// Example: app/utils/CorsUtil.php
155-
namespace app\utils;
156-
class CorsUtil {
157-
public function set(array $params): void { /* ...see docs for full example... */ }
158-
private function allowOrigins(): void { /* ... */ }
159-
}
160-
// In index.php
161-
$CorsUtil = new CorsUtil();
162-
Flight::before('start', [ $CorsUtil, 'set' ]);
144+
Flight::before('start', [ (new CorsUtil()), 'set' ]);
163145
```
164146

165147
### Error Handling
166-
- Never display sensitive error details in production.
167-
- Log errors instead and use Flight::halt() for controlled responses.
168-
148+
- Don’t display sensitive errors in production; log them instead.
149+
- Use `Flight::halt()` for controlled responses.
169150
```php
170-
$environment = ENVIRONMENT;
171-
if ($environment === 'production') {
151+
if (ENVIRONMENT === 'production') {
172152
ini_set('display_errors', 0);
173153
ini_set('log_errors', 1);
174-
ini_set('error_log', '/path/to/error.log');
175154
}
176-
// Controlled error response
177155
Flight::halt(403, 'Access denied');
178156
```
179157

180158
### Input Sanitization
181-
- Always sanitize and validate user input before processing.
182-
159+
- Sanitize and validate all user input.
183160
```php
184161
$clean_input = filter_var(Flight::request()->data->input, FILTER_SANITIZE_STRING);
185-
$clean_email = filter_var(Flight::request()->data->email, FILTER_SANITIZE_EMAIL);
186162
```
187163

188164
### Password Hashing
189-
- Always hash passwords using PHP's built-in functions. Never store plain text passwords.
190-
165+
- Always hash passwords; never store plain text.
191166
```php
192167
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
193168
if (password_verify($password, $stored_hash)) { /* Password matches */ }
194169
```
195170

196171
### Rate Limiting
197-
- Use caching or middleware to limit repeated requests and prevent brute force attacks.
198-
172+
- Use caching or middleware to limit repeated requests.
199173
```php
200174
Flight::before('start', function() {
201175
$cache = Flight::cache();
202176
$ip = Flight::request()->ip;
203177
$key = "rate_limit_{$ip}";
204178
$attempts = (int) $cache->retrieve($key);
205-
if ($attempts >= 10) {
206-
Flight::halt(429, 'Too many requests');
207-
}
179+
if ($attempts >= 10) Flight::halt(429, 'Too many requests');
208180
$cache->set($key, $attempts + 1, 60);
209181
});
210182
```

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ vendor/
33
app/config/config.php
44
composer.lock
55
.vagrant/
6-
runway
76
.runway-creds.json

.windsurfrules

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -117,94 +117,66 @@ Flight is highly extensible. Here are some recommended packages and plugins for
117117

118118
Choose the packages that best fit your project's needs. Official FlightPHP packages are recommended for core functionality.
119119

120-
## Security Best Practices
120+
## Security Best Practices (Condensed)
121121

122-
All code implemented in this project must follow secure coding best practices. Insecure code will not be accepted. Always assume user input is hostile and never trust data from users or external sources. The following guidelines and examples are required for all code contributions:
122+
All code must follow secure coding practices. Always treat user input as untrusted. Key requirements:
123123

124124
### Cross Site Scripting (XSS)
125-
- Always escape output from users before rendering in views.
126-
- Use Flight's view class or a templating engine like Latte, which auto-escapes variables.
127-
125+
- Always escape user output in views.
126+
- Use Flight’s view class or a templating engine (e.g., Latte) for auto-escaping.
128127
```php
129-
// Example: Escaping user input in views
130-
$name = '<script>alert("XSS")</script>';
131-
Flight::view()->set('name', $name); // Escapes output
132-
Flight::view()->render('template', ['name' => $name]); // Latte auto-escapes
128+
Flight::view()->set('name', $name);
129+
Flight::view()->render('template', ['name' => $name]);
133130
```
134131

135132
### SQL Injection
136-
- Never concatenate user input into SQL queries.
133+
- Never concatenate user input in SQL.
137134
- Always use prepared statements or parameterized queries.
138-
139135
```php
140-
// Secure: Using prepared statements
141136
$statement = Flight::db()->prepare('SELECT * FROM users WHERE username = :username');
142137
$statement->execute([':username' => $username]);
143-
$users = $statement->fetchAll();
144-
145-
// Or with PdoWrapper
146-
$users = Flight::db()->fetchAll('SELECT * FROM users WHERE username = :username', [ 'username' => $username ]);
147138
```
148139

149-
### CORS (Cross-Origin Resource Sharing)
150-
- Set CORS headers using a utility or middleware before Flight::start().
140+
### CORS
141+
- Set CORS headers via utility or middleware before `Flight::start()`.
151142
- Only allow trusted origins.
152-
153143
```php
154-
// Example: app/utils/CorsUtil.php
155-
namespace app\utils;
156-
class CorsUtil {
157-
public function set(array $params): void { /* ...see docs for full example... */ }
158-
private function allowOrigins(): void { /* ... */ }
159-
}
160-
// In index.php
161-
$CorsUtil = new CorsUtil();
162-
Flight::before('start', [ $CorsUtil, 'set' ]);
144+
Flight::before('start', [ (new CorsUtil()), 'set' ]);
163145
```
164146

165147
### Error Handling
166-
- Never display sensitive error details in production.
167-
- Log errors instead and use Flight::halt() for controlled responses.
168-
148+
- Don’t display sensitive errors in production; log them instead.
149+
- Use `Flight::halt()` for controlled responses.
169150
```php
170-
$environment = ENVIRONMENT;
171-
if ($environment === 'production') {
151+
if (ENVIRONMENT === 'production') {
172152
ini_set('display_errors', 0);
173153
ini_set('log_errors', 1);
174-
ini_set('error_log', '/path/to/error.log');
175154
}
176-
// Controlled error response
177155
Flight::halt(403, 'Access denied');
178156
```
179157

180158
### Input Sanitization
181-
- Always sanitize and validate user input before processing.
182-
159+
- Sanitize and validate all user input.
183160
```php
184161
$clean_input = filter_var(Flight::request()->data->input, FILTER_SANITIZE_STRING);
185-
$clean_email = filter_var(Flight::request()->data->email, FILTER_SANITIZE_EMAIL);
186162
```
187163

188164
### Password Hashing
189-
- Always hash passwords using PHP's built-in functions. Never store plain text passwords.
190-
165+
- Always hash passwords; never store plain text.
191166
```php
192167
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
193168
if (password_verify($password, $stored_hash)) { /* Password matches */ }
194169
```
195170

196171
### Rate Limiting
197-
- Use caching or middleware to limit repeated requests and prevent brute force attacks.
198-
172+
- Use caching or middleware to limit repeated requests.
199173
```php
200174
Flight::before('start', function() {
201175
$cache = Flight::cache();
202176
$ip = Flight::request()->ip;
203177
$key = "rate_limit_{$ip}";
204178
$attempts = (int) $cache->retrieve($key);
205-
if ($attempts >= 10) {
206-
Flight::halt(429, 'Too many requests');
207-
}
179+
if ($attempts >= 10) Flight::halt(429, 'Too many requests');
208180
$cache->set($key, $attempts + 1, 60);
209181
});
210182
```

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
"scripts": {
3535
"start": "php -S localhost:8000 -t public",
3636
"post-create-project-cmd": [
37-
"@php -r \"symlink('vendor/bin/runway', 'runway');\"",
3837
"@php -r \"copy('app/config/config_sample.php', 'app/config/config.php');\"",
3938
"@php -r \"mkdir('app/middlewares/');\"",
39+
"@php -r \"mkdir('app/models/');\"",
40+
"@php -r \"mkdir('app/utils/');\"",
4041
"@php -r \"mkdir('app/cache/');\"",
4142
"@php -r \"mkdir('app/log/');\""
4243
]

runway

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env php
2+
<?php
3+
require __DIR__ . '/vendor/bin/runway';

0 commit comments

Comments
 (0)