gophish-ruby 1.1.1 → 1.1.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/README.md +13 -3
- data/docs/API_REFERENCE.md +108 -2
- data/docs/EXAMPLES.md +47 -3
- data/docs/GETTING_STARTED.md +68 -2
- data/lib/gophish/group.rb +15 -0
- data/lib/gophish/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f41c329a32ea585c7615788ab9d678f6b5c27f48b4042ef29d403e2067bc0de3
|
4
|
+
data.tar.gz: 571c89d538cf07c0b6229833c8c292e4ecd518945d88d0139430b878aa4fbb9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1b6333177655bba26e21db639ddd3dfa78d6d80cc6da947313d59704489182ca24952850151ff4039aa3f747c37ddf5cbea44021dc20dbd68b42dd1b9dcf698
|
7
|
+
data.tar.gz: 738d6ffa6e7642af68254013a79207724fc495cce323f90c3c86dd2b8abf768aff12a3a3004636015e9852d4622c254c98e3ee18b96efa833a21ad6440a06a78
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [1.1.2] - 2025-09-05
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- **Enhanced Target Management for Groups**
|
15
|
+
- New `#add_target(target)` method to add individual targets to existing groups
|
16
|
+
- New `#remove_target(target)` method to remove specific targets from groups
|
17
|
+
- New `#remove_target_by_email(email)` method to remove targets by email address
|
18
|
+
- Improved target manipulation workflow for dynamic group management
|
19
|
+
- Support for programmatic target list modifications without full replacement
|
20
|
+
|
21
|
+
### Changed
|
22
|
+
|
23
|
+
- Updated gem version to 1.1.2
|
24
|
+
- Enhanced Group class with additional target management capabilities
|
25
|
+
- Improved README.md with comprehensive examples of new target management methods
|
26
|
+
- Updated API reference documentation to include new Group instance methods
|
27
|
+
|
28
|
+
### Technical Details
|
29
|
+
|
30
|
+
- All new methods work with existing target array structure
|
31
|
+
- Methods maintain data integrity by working with copies of target arrays
|
32
|
+
- Email-based removal supports both symbol and string keys for flexible target structures
|
33
|
+
- Backward compatibility maintained with existing target management approaches
|
34
|
+
|
35
|
+
### Documentation Updates
|
36
|
+
|
37
|
+
- Added practical examples for add_target, remove_target, and remove_target_by_email methods
|
38
|
+
- Updated "Managing Group Targets" section in README with new workflow examples
|
39
|
+
- Enhanced API reference documentation with detailed method descriptions
|
40
|
+
- Included tested code examples for all new target management functionality
|
41
|
+
|
10
42
|
## [1.0.0] - 2025-09-01
|
11
43
|
|
12
44
|
### Added
|
data/README.md
CHANGED
@@ -131,20 +131,27 @@ group = Gophish::Group.find(1)
|
|
131
131
|
puts "Group: #{group.name} with #{group.targets.length} targets"
|
132
132
|
```
|
133
133
|
|
134
|
-
####
|
134
|
+
#### Managing Group Targets
|
135
135
|
|
136
136
|
```ruby
|
137
137
|
# Update group attributes
|
138
138
|
group = Gophish::Group.find(1)
|
139
139
|
group.name = "Updated Group Name"
|
140
140
|
|
141
|
-
# Add
|
142
|
-
|
141
|
+
# Add a single target
|
142
|
+
new_target = {
|
143
143
|
first_name: "New",
|
144
144
|
last_name: "User",
|
145
145
|
email: "new.user@company.com",
|
146
146
|
position: "Intern"
|
147
147
|
}
|
148
|
+
group.add_target(new_target)
|
149
|
+
|
150
|
+
# Remove a specific target
|
151
|
+
group.remove_target(new_target)
|
152
|
+
|
153
|
+
# Remove a target by email address
|
154
|
+
group.remove_target_by_email("old.user@company.com")
|
148
155
|
|
149
156
|
if group.save
|
150
157
|
puts "Group updated successfully"
|
@@ -885,6 +892,9 @@ Each target in the `targets` array should have:
|
|
885
892
|
**Instance Methods:**
|
886
893
|
|
887
894
|
- `#import_csv(csv_data)` - Import targets from CSV data
|
895
|
+
- `#add_target(target)` - Add a single target to the group
|
896
|
+
- `#remove_target(target)` - Remove a specific target from the group
|
897
|
+
- `#remove_target_by_email(email)` - Remove a target by email address
|
888
898
|
|
889
899
|
#### `Gophish::Template`
|
890
900
|
|
data/docs/API_REFERENCE.md
CHANGED
@@ -343,6 +343,82 @@ group.import_csv(csv_data)
|
|
343
343
|
puts group.targets.length # => 2
|
344
344
|
```
|
345
345
|
|
346
|
+
##### `#add_target(target)`
|
347
|
+
|
348
|
+
Add a single target to the group.
|
349
|
+
|
350
|
+
**Parameters:**
|
351
|
+
|
352
|
+
- `target` (Hash) - Target hash with required fields (first_name, last_name, email, position)
|
353
|
+
|
354
|
+
**Returns:** Void
|
355
|
+
|
356
|
+
**Side Effects:**
|
357
|
+
|
358
|
+
- Adds target to the current `targets` array
|
359
|
+
- Marks `targets` attribute as changed
|
360
|
+
|
361
|
+
**Example:**
|
362
|
+
|
363
|
+
```ruby
|
364
|
+
group = Gophish::Group.find(1)
|
365
|
+
new_target = {
|
366
|
+
first_name: "Alice",
|
367
|
+
last_name: "Cooper",
|
368
|
+
email: "alice@example.com",
|
369
|
+
position: "Developer"
|
370
|
+
}
|
371
|
+
group.add_target(new_target)
|
372
|
+
puts group.targets.length # Increased by 1
|
373
|
+
```
|
374
|
+
|
375
|
+
##### `#remove_target(target)`
|
376
|
+
|
377
|
+
Remove a specific target from the group.
|
378
|
+
|
379
|
+
**Parameters:**
|
380
|
+
|
381
|
+
- `target` (Hash) - Target hash to remove (must match exactly)
|
382
|
+
|
383
|
+
**Returns:** Void
|
384
|
+
|
385
|
+
**Side Effects:**
|
386
|
+
|
387
|
+
- Removes matching target from `targets` array
|
388
|
+
- Marks `targets` attribute as changed if target was found
|
389
|
+
|
390
|
+
**Example:**
|
391
|
+
|
392
|
+
```ruby
|
393
|
+
group = Gophish::Group.find(1)
|
394
|
+
target_to_remove = group.targets.first
|
395
|
+
group.remove_target(target_to_remove)
|
396
|
+
```
|
397
|
+
|
398
|
+
##### `#remove_target_by_email(email)`
|
399
|
+
|
400
|
+
Remove a target by email address.
|
401
|
+
|
402
|
+
**Parameters:**
|
403
|
+
|
404
|
+
- `email` (String) - Email address of target to remove
|
405
|
+
|
406
|
+
**Returns:** Void
|
407
|
+
|
408
|
+
**Side Effects:**
|
409
|
+
|
410
|
+
- Removes target(s) with matching email from `targets` array
|
411
|
+
- Marks `targets` attribute as changed if any targets were removed
|
412
|
+
- Supports both symbol and string keys in target hashes
|
413
|
+
|
414
|
+
**Example:**
|
415
|
+
|
416
|
+
```ruby
|
417
|
+
group = Gophish::Group.find(1)
|
418
|
+
group.remove_target_by_email("user@example.com")
|
419
|
+
puts "Removed target with email: user@example.com"
|
420
|
+
```
|
421
|
+
|
346
422
|
#### Usage Examples
|
347
423
|
|
348
424
|
##### Create a Group
|
@@ -377,17 +453,47 @@ end
|
|
377
453
|
group = Gophish::Group.find(1)
|
378
454
|
group.name = "Updated Marketing Team"
|
379
455
|
|
380
|
-
# Add new target
|
381
|
-
|
456
|
+
# Add new target using the add_target method
|
457
|
+
new_target = {
|
382
458
|
first_name: "Carol",
|
383
459
|
last_name: "Brown",
|
384
460
|
email: "carol@company.com",
|
385
461
|
position: "Marketing Intern"
|
386
462
|
}
|
463
|
+
group.add_target(new_target)
|
387
464
|
|
388
465
|
group.save
|
389
466
|
```
|
390
467
|
|
468
|
+
##### Managing Individual Targets
|
469
|
+
|
470
|
+
```ruby
|
471
|
+
group = Gophish::Group.find(1)
|
472
|
+
|
473
|
+
# Add a single target
|
474
|
+
group.add_target({
|
475
|
+
first_name: "David",
|
476
|
+
last_name: "Wilson",
|
477
|
+
email: "david@company.com",
|
478
|
+
position: "Designer"
|
479
|
+
})
|
480
|
+
|
481
|
+
# Remove a specific target (exact match required)
|
482
|
+
target_to_remove = group.targets.find { |t| t[:email] == "old@company.com" }
|
483
|
+
group.remove_target(target_to_remove) if target_to_remove
|
484
|
+
|
485
|
+
# Remove target by email address (more convenient)
|
486
|
+
group.remove_target_by_email("user@company.com")
|
487
|
+
|
488
|
+
# Save all changes
|
489
|
+
if group.save
|
490
|
+
puts "Group targets updated successfully"
|
491
|
+
puts "Current target count: #{group.targets.length}"
|
492
|
+
else
|
493
|
+
puts "Failed to update group: #{group.errors.full_messages}"
|
494
|
+
end
|
495
|
+
```
|
496
|
+
|
391
497
|
##### Import from CSV
|
392
498
|
|
393
499
|
```ruby
|
data/docs/EXAMPLES.md
CHANGED
@@ -91,12 +91,12 @@ group = Gophish::Group.find(1)
|
|
91
91
|
original_name = group.name
|
92
92
|
|
93
93
|
group.name = "Updated Engineering Team"
|
94
|
-
group.
|
94
|
+
group.add_target({
|
95
95
|
first_name: "Charlie",
|
96
96
|
last_name: "New",
|
97
97
|
email: "charlie@company.com",
|
98
98
|
position: "Junior Developer"
|
99
|
-
}
|
99
|
+
})
|
100
100
|
|
101
101
|
if group.save
|
102
102
|
puts "✓ Updated group from '#{original_name}' to '#{group.name}'"
|
@@ -106,6 +106,50 @@ else
|
|
106
106
|
end
|
107
107
|
```
|
108
108
|
|
109
|
+
### Managing Individual Targets
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
# Advanced target management example
|
113
|
+
group = Gophish::Group.find(1)
|
114
|
+
puts "Starting with #{group.targets.length} targets"
|
115
|
+
|
116
|
+
# Add multiple targets individually
|
117
|
+
new_hires = [
|
118
|
+
{ first_name: "Sarah", last_name: "Johnson", email: "sarah@company.com", position: "UX Designer" },
|
119
|
+
{ first_name: "Mike", last_name: "Chen", email: "mike@company.com", position: "Backend Developer" },
|
120
|
+
{ first_name: "Lisa", last_name: "Davis", email: "lisa@company.com", position: "Product Manager" }
|
121
|
+
]
|
122
|
+
|
123
|
+
new_hires.each do |hire|
|
124
|
+
group.add_target(hire)
|
125
|
+
puts "Added: #{hire[:first_name]} #{hire[:last_name]}"
|
126
|
+
end
|
127
|
+
|
128
|
+
# Remove a specific target by exact match
|
129
|
+
target_to_remove = group.targets.find { |t| t[:email] == "former.employee@company.com" }
|
130
|
+
if target_to_remove
|
131
|
+
group.remove_target(target_to_remove)
|
132
|
+
puts "Removed target: #{target_to_remove[:email]}"
|
133
|
+
end
|
134
|
+
|
135
|
+
# Remove targets by email (more convenient)
|
136
|
+
departing_employees = ["john.doe@company.com", "jane.smith@company.com"]
|
137
|
+
departing_employees.each do |email|
|
138
|
+
group.remove_target_by_email(email)
|
139
|
+
puts "Removed by email: #{email}"
|
140
|
+
end
|
141
|
+
|
142
|
+
# Save all changes
|
143
|
+
if group.save
|
144
|
+
puts "✓ Target management completed"
|
145
|
+
puts " Final target count: #{group.targets.length}"
|
146
|
+
puts " Added #{new_hires.length} new hires"
|
147
|
+
puts " Removed #{departing_employees.length + (target_to_remove ? 1 : 0)} former employees"
|
148
|
+
else
|
149
|
+
puts "✗ Failed to save changes: #{group.errors.full_messages}"
|
150
|
+
end
|
151
|
+
```
|
152
|
+
|
109
153
|
### Deleting Groups
|
110
154
|
|
111
155
|
```ruby
|
@@ -3114,7 +3158,7 @@ end
|
|
3114
3158
|
# Usage
|
3115
3159
|
group = Gophish::Group.find(1)
|
3116
3160
|
group.name = "Updated Team Name"
|
3117
|
-
group.
|
3161
|
+
group.add_target({ first_name: "New", last_name: "Person", email: "new@company.com", position: "Intern" })
|
3118
3162
|
|
3119
3163
|
GroupChangeTracker.log_and_save(group)
|
3120
3164
|
```
|
data/docs/GETTING_STARTED.md
CHANGED
@@ -740,17 +740,83 @@ end
|
|
740
740
|
group = Gophish::Group.find(1)
|
741
741
|
group.name = "Updated Group Name"
|
742
742
|
|
743
|
-
# Add new targets
|
744
|
-
|
743
|
+
# Add new targets using the add_target method
|
744
|
+
new_employee = {
|
745
745
|
first_name: "New",
|
746
746
|
last_name: "Employee",
|
747
747
|
email: "new.employee@company.com",
|
748
748
|
position: "Intern"
|
749
749
|
}
|
750
|
+
group.add_target(new_employee)
|
750
751
|
|
751
752
|
group.save
|
752
753
|
```
|
753
754
|
|
755
|
+
#### Managing Individual Targets
|
756
|
+
|
757
|
+
The SDK provides convenient methods for managing individual targets within groups:
|
758
|
+
|
759
|
+
```ruby
|
760
|
+
group = Gophish::Group.find(1)
|
761
|
+
puts "Current targets: #{group.targets.length}"
|
762
|
+
|
763
|
+
# Add a single target
|
764
|
+
group.add_target({
|
765
|
+
first_name: "Alice",
|
766
|
+
last_name: "Johnson",
|
767
|
+
email: "alice@company.com",
|
768
|
+
position: "Developer"
|
769
|
+
})
|
770
|
+
|
771
|
+
# Remove a specific target (exact match required)
|
772
|
+
target_to_remove = group.targets.find { |t| t[:email] == "old.employee@company.com" }
|
773
|
+
group.remove_target(target_to_remove) if target_to_remove
|
774
|
+
|
775
|
+
# Remove target by email address (more convenient)
|
776
|
+
group.remove_target_by_email("departed.employee@company.com")
|
777
|
+
|
778
|
+
# Save all changes
|
779
|
+
if group.save
|
780
|
+
puts "✓ Group updated successfully"
|
781
|
+
puts " New target count: #{group.targets.length}"
|
782
|
+
else
|
783
|
+
puts "✗ Failed to update group:"
|
784
|
+
group.errors.full_messages.each { |error| puts " - #{error}" }
|
785
|
+
end
|
786
|
+
```
|
787
|
+
|
788
|
+
#### Bulk Target Management Example
|
789
|
+
|
790
|
+
```ruby
|
791
|
+
# Example: Manage a department reorganization
|
792
|
+
group = Gophish::Group.find(1)
|
793
|
+
|
794
|
+
# Add new hires
|
795
|
+
new_hires = [
|
796
|
+
{ first_name: "John", last_name: "Smith", email: "john.smith@company.com", position: "Junior Developer" },
|
797
|
+
{ first_name: "Jane", last_name: "Doe", email: "jane.doe@company.com", position: "Senior Analyst" },
|
798
|
+
{ first_name: "Bob", last_name: "Wilson", email: "bob.wilson@company.com", position: "Project Manager" }
|
799
|
+
]
|
800
|
+
|
801
|
+
new_hires.each { |hire| group.add_target(hire) }
|
802
|
+
|
803
|
+
# Remove departing employees
|
804
|
+
departing_emails = ["old.employee1@company.com", "old.employee2@company.com"]
|
805
|
+
departing_emails.each { |email| group.remove_target_by_email(email) }
|
806
|
+
|
807
|
+
# Update group name to reflect changes
|
808
|
+
group.name = "#{group.name} - Updated #{Date.today}"
|
809
|
+
|
810
|
+
if group.save
|
811
|
+
puts "✓ Department reorganization complete"
|
812
|
+
puts " Final target count: #{group.targets.length}"
|
813
|
+
puts " Added #{new_hires.length} new employees"
|
814
|
+
puts " Removed #{departing_emails.length} former employees"
|
815
|
+
else
|
816
|
+
puts "✗ Update failed: #{group.errors.full_messages}"
|
817
|
+
end
|
818
|
+
```
|
819
|
+
|
754
820
|
### Deleting Groups
|
755
821
|
|
756
822
|
```ruby
|
data/lib/gophish/group.rb
CHANGED
@@ -24,6 +24,21 @@ module Gophish
|
|
24
24
|
self.targets = targets_array
|
25
25
|
end
|
26
26
|
|
27
|
+
def add_target(target)
|
28
|
+
current_targets = targets || []
|
29
|
+
self.targets = current_targets + [target]
|
30
|
+
end
|
31
|
+
|
32
|
+
def remove_target(target)
|
33
|
+
current_targets = targets || []
|
34
|
+
self.targets = current_targets.reject { |t| t == target }
|
35
|
+
end
|
36
|
+
|
37
|
+
def remove_target_by_email(email)
|
38
|
+
current_targets = targets || []
|
39
|
+
self.targets = current_targets.reject { |t| (t[:email] || t['email']) == email }
|
40
|
+
end
|
41
|
+
|
27
42
|
private
|
28
43
|
|
29
44
|
def validate_targets_structure
|
data/lib/gophish/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gophish-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Sebastian Herrera Aguilar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09-
|
11
|
+
date: 2025-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|