Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect: WAF Phase 3 #28046

Merged
merged 60 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
26cb154
[not verified] Update the WAF to support running the automatic and ma…
nateweller Dec 1, 2022
3c2ebab
[not verified] Check if rules enabled after defining constants and ad…
nateweller Dec 1, 2022
f978158
[not verified] Use IP rules enabled constant in IP list generation fo…
nateweller Dec 1, 2022
b49c21e
[not verified] Regenerate standalone bootstrap when rule options are …
nateweller Dec 1, 2022
1e68467
[not verified] Add support for automatic rules and ip lists enabled c…
nateweller Dec 1, 2022
346acb7
[not verified] Remove definition of constants for enabled rule types …
nateweller Dec 6, 2022
8321fe0
Update WAF settings UI to include automatic rule toggling
nateweller Dec 6, 2022
7687588
Changelog
nateweller Dec 6, 2022
7a7d45a
Remove regeneration of bootstrap file on option updates
nateweller Dec 6, 2022
5b625c4
Update plan upsell messaging and disable automatic rules toggle when …
nateweller Dec 6, 2022
4fce6bd
Merge branch 'add/waf-automatic-rule-toggle' into update/jetpack-waf-…
nateweller Dec 6, 2022
3f9c5b2
Merge branch 'add/protect-waf-phase-2' into add/waf-automatic-rule-to…
nateweller Dec 10, 2022
f355bc8
Merge branch 'add/waf-automatic-rule-toggle' into update/jetpack-waf-…
nateweller Dec 10, 2022
730b430
Activate WAF module on plugin activation
nateweller Dec 10, 2022
dbf78c4
[not verified] Revert "Activate WAF module on plugin activation"
nateweller Dec 10, 2022
e97a460
Ensure Waf_Runner::get_config() is backwards compatible
nateweller Dec 14, 2022
8f25a12
[not verified] Fix tests
nateweller Dec 15, 2022
576d5e1
changelog
nateweller Dec 15, 2022
374fbb2
Rename fix-waf-tests to update-waf-tests
nateweller Dec 15, 2022
9dd43f3
Merge branch 'add/waf-automatic-rule-toggle' into update/jetpack-waf-…
nateweller Dec 15, 2022
19e0383
Changelog
nateweller Dec 15, 2022
d4d07a8
Merge branch 'add/protect-waf-phase-2' into add/waf-automatic-rule-to…
nateweller Dec 15, 2022
76a2f4c
Merge branch 'add/waf-automatic-rule-toggle' into update/jetpack-waf-…
nateweller Dec 16, 2022
d078e6e
Fixes for backwards compatibility
nateweller Dec 16, 2022
d05500c
Update doc block
nateweller Dec 16, 2022
dfc6038
Merge branch 'add/protect-waf-phase-2' into add/waf-automatic-rule-to…
nateweller Dec 16, 2022
d816d30
Merge branch 'add/waf-automatic-rule-toggle' into update/jetpack-waf-…
nateweller Dec 16, 2022
a4b1a66
Use update_option instead of add_option
nateweller Dec 19, 2022
f00a566
Merge branch 'add/protect-waf-phase-2' into update/jetpack-waf-settin…
nateweller Dec 19, 2022
75320d9
Remove changes reintroduced from merge
nateweller Dec 19, 2022
ef292ce
Merge branch 'add/protect-waf-phase-2' into update/jetpack-waf-settin…
nateweller Dec 19, 2022
627c697
Add a dedicated automatic-rules.php file for storing firewall rules f…
nateweller Dec 20, 2022
a3d4f8c
Merge branch 'add/waf-automatic-rules-file' into update/jetpack-waf-s…
nateweller Dec 20, 2022
9540c1f
Allow automatic rules to be toggled when no plan but rules available
nateweller Dec 20, 2022
1e5cd85
Fix tests
nateweller Dec 20, 2022
0d7dee2
Merge branch 'add/waf-automatic-rules-file' into update/jetpack-waf-s…
nateweller Dec 20, 2022
22c89f2
[not verified] Merge branch 'add/protect-waf-phase-2' into update/jet…
nateweller Jan 4, 2023
666b215
[not verified] Remove unrelated changes
nateweller Jan 4, 2023
2efbe14
Update messaging
nateweller Jan 4, 2023
4d603c3
Remove missed merge conflict
nateweller Jan 4, 2023
2067e73
Remove mistake from merge conflict resolution
nateweller Jan 4, 2023
7982793
Add automatic rules enabled option on WAF activation
nateweller Jan 5, 2023
a20e8c3
Do not attempt to reset the rules entrypoint file if it does not exist
nateweller Jan 5, 2023
378c076
Ensure plugin activation has been performed so WAF module is available
nateweller Jan 5, 2023
215de03
Fix conditional
nateweller Jan 5, 2023
4a78ea0
Remove add_option activation hooks and move introduction of automatic…
nateweller Jan 6, 2023
00567df
Restore add option hooks
nateweller Jan 6, 2023
195f82e
Fix typo
nateweller Jan 6, 2023
a6367b5
Merge branch 'add/protect-waf-phase-2' into update/jetpack-waf-settin…
nateweller Jan 7, 2023
cf93258
Initialize project branch
nateweller Jan 7, 2023
d15f1b0
Add REST_Controller (#28217)
nateweller Jan 7, 2023
9c13ddc
Fix: incorrect class name used to access do_plugin_activation_activities
nateweller Jan 9, 2023
1dd039b
Fix: missing import of Waf_Runner class
nateweller Jan 9, 2023
994c607
Protect: Add WAF post upgrade messaging (#27787)
dkmyta Jan 10, 2023
c8f20ef
WAF: Add Waf_Stats class (#27970)
dkmyta Jan 11, 2023
0aa0935
Protect: Add WAF stats to controls (#28017)
dkmyta Jan 17, 2023
628d8fd
[not verified] Merge branch 'add/protect-waf-phase-2' into add/protec…
nateweller Jan 17, 2023
4961091
Update pnpm-lock.yaml
nateweller Jan 17, 2023
914301a
Fix issues from merge
nateweller Jan 17, 2023
604ecb5
Merge branch 'add/protect-waf-phase-2' into add/protect-waf-phase-3
nateweller Jan 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions projects/packages/waf/changelog/add-waf-stats-class
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add statistics to the firewall settings screen
2 changes: 1 addition & 1 deletion projects/packages/waf/src/class-waf-rules-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public static function generate_automatic_rules() {
* @param string $ips List of ips - example: "8.8.8.8\n4.4.4.4,2.2.2.2;1.1.1.1 9.9.9.9,5555.5555.5555.5555".
* @return array List of valid IP addresses. - example based on input example: array('8.8.8.8', '4.4.4.4', '2.2.2.2', '1.1.1.1', '9.9.9.9')
*/
private static function ip_option_to_array( $ips ) {
public static function ip_option_to_array( $ips ) {
$ips = (string) $ips;
$ips = preg_split( '/[\s,;]/', $ips );

Expand Down
66 changes: 66 additions & 0 deletions projects/packages/waf/src/class-waf-stats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* Class used to retrieve WAF stats
*
* @package automattic/jetpack-waf
*/

namespace Automattic\Jetpack\Waf;

/**
* Retrieves WAF stats.
*/
class Waf_Stats {

/**
* Get IP allow list count
*
* @return int The number of valid IP addresses in the allow list
*/
public static function get_ip_allow_list_count() {
$ip_allow_list = get_option( Waf_Rules_Manager::IP_ALLOW_LIST_OPTION_NAME );

if ( ! $ip_allow_list ) {
return 0;
}

$results = Waf_Rules_Manager::ip_option_to_array( $ip_allow_list );

return count( $results );
}

/**
* Get IP block list count
*
* @return int The number of valid IP addresses in the block list
*/
public static function get_ip_block_list_count() {
$ip_block_list = get_option( Waf_Rules_Manager::IP_BLOCK_LIST_OPTION_NAME );

if ( ! $ip_block_list ) {
return 0;
}

$results = Waf_Rules_Manager::ip_option_to_array( $ip_block_list );

return count( $results );
}

/**
* Get Rules version
*
* @return bool|string False if value is not found. The current stored rules version if cache is found.
*/
public static function get_rules_version() {
return get_option( Waf_Rules_Manager::VERSION_OPTION_NAME );
}

/**
* Get Automatic Rules last updated timestamp
*
* @return bool|string False if value is not found. The timestamp the current stored rules was last updated if cache is found.
*/
public static function get_automatic_rules_last_updated() {
return get_option( Waf_Rules_Manager::AUTOMATIC_RULES_LAST_UPDATED_OPTION_NAME );
}
}
3 changes: 2 additions & 1 deletion projects/plugins/protect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"prop-types": "15.8.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-router-dom": "6.6.2"
"react-router-dom": "6.2.2",
"moment": "2.29.4"
},
"devDependencies": {
"@automattic/jetpack-webpack-config": "workspace:*",
Expand Down
Loading