Compare commits

...

4 Commits

Author SHA1 Message Date
Prasoon Dwivedi 3f142ba0c3
Merge 99f1b9d3c4 into 9561846979 2024-11-21 01:14:03 +00:00
Jordan Wright 9561846979
Update workflow actions and Go versions (#3245)
This PR:

* Updates the versions of various actions used by the CI and release workflows
* Updates the release workflow to use Go version 1.22
* Updates the test matrix to use Go versions 1.21, 1.22, and 1.23

It also updates the CI workflow to run when pull requests are created or changed. This will help give feedback when formatting or tests are broken during a PR.

As a good example of why this is useful, you'll see that I needed to run `gofmt` to get this to pass! We should have caught that earlier and now we'll catch it moving forward.
2024-09-22 23:24:43 -05:00
Caetan 908886f2cd
Enforce account locks when creating new users (#3173)
Properly enforce account locks when new users are created

---------

Co-authored-by: Caetan Tojeiro Carpente <caetan.tojeiro@tier8.com>
2024-09-22 22:53:08 -05:00
Prasoon Dwivedi 99f1b9d3c4 Add feature to export group targets as CSV
A new feature has been added through which targets in a group can be
exported as CSV. For this a new button has been added to the group page
for every group. On clicking this button for a group, group targets will
be downloaded as CSV file.

This will enable an admin to download group targets from one system and
import them on other to create a group.
2021-06-15 23:16:27 +05:30
6 changed files with 58 additions and 21 deletions

View File

@ -1,5 +1,7 @@
name: CI name: CI
on: [push] on:
- pull_request
- push
jobs: jobs:
build: build:
@ -7,17 +9,17 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
goVer: [1.16, 1.17, 1.18] goVer: [1.21, 1.22, 1.23]
steps: steps:
- name: Set up Go ${{ matrix.goVer }} - name: Set up Go ${{ matrix.goVer }}
uses: actions/setup-go@v1 uses: actions/setup-go@v5
with: with:
go-version: ${{ matrix.goVer }} go-version: ${{ matrix.goVer }}
id: go id: go
- name: Check out code into the Go module directory - name: Check out code into the Go module directory
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Get dependencies - name: Get dependencies
run: | run: |
@ -31,4 +33,4 @@ jobs:
run: diff -u <(echo -n) <(gofmt -d .) run: diff -u <(echo -n) <(gofmt -d .)
- name: Test - name: Test
run: go test -v ./... run: go test ./...

View File

@ -38,7 +38,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.14 go-version: 1.22
- if: matrix.os == 'ubuntu-latest' - if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y gcc-multilib run: sudo apt-get update && sudo apt-get install -y gcc-multilib
- if: matrix.arch == '386' - if: matrix.arch == '386'
@ -47,7 +47,7 @@ jobs:
run: echo "RELEASE=gophish-${{ github.event.release.tag_name }}-${{ matrix.releaseos }}-64bit" >> $GITHUB_ENV run: echo "RELEASE=gophish-${{ github.event.release.tag_name }}-${{ matrix.releaseos }}-64bit" >> $GITHUB_ENV
- if: matrix.os == 'windows-latest' - if: matrix.os == 'windows-latest'
run: echo "RELEASE=gophish-${{ github.event.release.tag_name }}-${{ matrix.releaseos }}-64bit" | Out-File -FilePath $env:GITHUB_ENV -Append # https://github.com/actions/runner/issues/1636 run: echo "RELEASE=gophish-${{ github.event.release.tag_name }}-${{ matrix.releaseos }}-64bit" | Out-File -FilePath $env:GITHUB_ENV -Append # https://github.com/actions/runner/issues/1636
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Build ${{ matrix.goos }}/${{ matrix.arch }} - name: Build ${{ matrix.goos }}/${{ matrix.arch }}
run: go build -o ${{ matrix.bin }} run: go build -o ${{ matrix.bin }}
env: env:
@ -55,7 +55,7 @@ jobs:
GOARCH: ${{ matrix.arch }} GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 1 CGO_ENABLED: 1
- name: Upload to artifacts - name: Upload to artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v4
with: with:
name: ${{ env.RELEASE }} name: ${{ env.RELEASE }}
path: ${{ matrix.bin }} path: ${{ matrix.bin }}
@ -65,8 +65,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- uses: actions/download-artifact@v2 - uses: actions/download-artifact@v4
with: with:
path: bin path: bin
- name: Package Releases - name: Package Releases
@ -96,7 +96,7 @@ jobs:
done done
done done
- name: Upload to artifacts - name: Upload to artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v4
with: with:
name: releases name: releases
path: releases/*.zip path: releases/*.zip
@ -106,7 +106,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: package needs: package
steps: steps:
- uses: actions/download-artifact@v2 - uses: actions/download-artifact@v4
with: with:
name: releases name: releases
path: releases/ path: releases/

View File

@ -109,6 +109,7 @@ func (as *Server) Users(w http.ResponseWriter, r *http.Request) {
Role: role, Role: role,
RoleID: role.ID, RoleID: role.ID,
PasswordChangeRequired: ur.PasswordChangeRequired, PasswordChangeRequired: ur.PasswordChangeRequired,
AccountLocked: ur.AccountLocked,
} }
err = models.PutUser(&user) err = models.PutUser(&user)
if err != nil { if err != nil {

View File

@ -115,8 +115,8 @@ func (im *Monitor) Shutdown() error {
return nil return nil
} }
// checkForNewEmails logs into an IMAP account and checks unread emails // checkForNewEmails logs into an IMAP account and checks unread emails for the
// for the rid campaign identifier. // rid campaign identifier.
func checkForNewEmails(im models.IMAP) { func checkForNewEmails(im models.IMAP) {
im.Host = im.Host + ":" + strconv.Itoa(int(im.Port)) // Append port im.Host = im.Host + ":" + strconv.Itoa(int(im.Port)) // Append port
mailServer := Mailbox{ mailServer := Mailbox{

View File

@ -609,7 +609,7 @@ func PostCampaign(c *Campaign, uid int64) error {
return tx.Commit().Error return tx.Commit().Error
} }
//DeleteCampaign deletes the specified campaign // DeleteCampaign deletes the specified campaign
func DeleteCampaign(id int64) error { func DeleteCampaign(id int64) error {
log.WithFields(logrus.Fields{ log.WithFields(logrus.Fields{
"campaign_id": id, "campaign_id": id,

View File

@ -241,12 +241,16 @@ function load() {
escapeHtml(group.name), escapeHtml(group.name),
escapeHtml(group.num_targets), escapeHtml(group.num_targets),
moment(group.modified_date).format('MMMM Do YYYY, h:mm:ss a'), moment(group.modified_date).format('MMMM Do YYYY, h:mm:ss a'),
"<div class='pull-right'><button class='btn btn-primary' data-toggle='modal' data-backdrop='static' data-target='#modal' onclick='edit(" + group.id + ")'>\ "<div class='pull-right'>\
<i class='fa fa-pencil'></i>\ <button class='btn btn-info' id='exportGroupButton" + group.id + "' onclick='exportGroupAsCSV(" + group.id + ',\"' + group.name +"\")'>\
</button>\ <i class='fa fa-file-excel-o'></i>\
<button class='btn btn-danger' onclick='deleteGroup(" + group.id + ")'>\ </button>\
<i class='fa fa-trash-o'></i>\ <button class='btn btn-primary' data-toggle='modal' data-backdrop='static' data-target='#modal' onclick='edit(" + group.id + ")'>\
</button></div>" <i class='fa fa-pencil'></i>\
</button>\
<button class='btn btn-danger' onclick='deleteGroup(" + group.id + ")'>\
<i class='fa fa-trash-o'></i>\
</button></div>"
]) ])
}) })
groupTable.rows.add(groupRows).draw() groupTable.rows.add(groupRows).draw()
@ -294,3 +298,33 @@ $(document).ready(function () {
}); });
$("#csv-template").click(downloadCSVTemplate) $("#csv-template").click(downloadCSVTemplate)
}); });
// Exports group contents as a CSV file
function exportGroupAsCSV(groupId, groupName) {
var exportHTML = $("#exportGroupButton"+groupId).html()
var filename = groupName + '.csv'
var groupDetails = api.groupId.get(groupId)
if (!groupDetails) {
return
}
$("#exportGroupButton"+groupId).html('<i class="fa fa-spinner fa-spin"></i>')
var csvString = Papa.unparse(groupDetails.responseJSON.targets, {
'escapeFormulae': true
})
var csvData = new Blob([csvString], {
type: 'text/csv;charset=utf-8;'
});
if (navigator.msSaveBlob) {
navigator.msSaveBlob(csvData, filename);
} else {
var csvURL = window.URL.createObjectURL(csvData);
var dlLink = document.createElement('a');
dlLink.href = csvURL;
dlLink.setAttribute('download', filename)
document.body.appendChild(dlLink)
dlLink.click();
document.body.removeChild(dlLink)
}
$("#exportGroupButton"+groupId).html(exportHTML)
}