Skip to content

Commit

Permalink
Merge pull request #106 from thalesgroup-cert/v2
Browse files Browse the repository at this point in the history
Fix Ticked ID Bug
  • Loading branch information
ygalnezri authored May 2, 2024
2 parents b22eb5a + bbecf31 commit f6f8d67
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class SuspiciousSites extends Component {
showExportModal: false,
id: 0,
domainName: "",
ticketId: "",
name: "",
rtir: "",
expiry: null,
Expand All @@ -34,6 +35,7 @@ export class SuspiciousSites extends Component {
exportLoading: false
};
this.inputDomainRef = React.createRef();
this.inputTicketRef = React.createRef();
this.inputRtirRef = React.createRef();
this.ipMonitoringRef = React.createRef();
this.webContentMonitoringRef = React.createRef();
Expand Down Expand Up @@ -128,6 +130,7 @@ export class SuspiciousSites extends Component {
showEditModal: true,
id: site.id,
domainName: site.domain_name,
ticketId: site.ticket_id,
rtir: site.rtir,
expiry: site.expiry,
ipMonitoring: site.ip_monitoring,
Expand All @@ -148,13 +151,14 @@ export class SuspiciousSites extends Component {
onSubmit = e => {
e.preventDefault();
const domain_name = this.inputDomainRef.current.value;
const ticket_id = this.inputTicketRef.current.value;
const rtir = this.inputRtirRef.current.value;
const expiry = this.state.expiry ? this.state.expiry : null;
const ip_monitoring = this.ipMonitoringRef.current.checked;
const content_monitoring = this.webContentMonitoringRef.current.checked;
const mail_monitoring = this.emailMonitoringRef.current.checked;

const site = {domain_name, rtir, expiry, ip_monitoring, content_monitoring, mail_monitoring};
const site = {domain_name, ticket_id, rtir, expiry, ip_monitoring, content_monitoring, mail_monitoring};

this.props.patchSite(this.state.id, site);
this.setState({
Expand Down Expand Up @@ -191,9 +195,19 @@ export class SuspiciousSites extends Component {
</Col>
<Form.Label column sm="4">Ticket ID</Form.Label>
<Col sm="8">
<Form.Control required ref={this.inputRtirRef} size="md"
<Form.Control
ref={this.inputTicketRef} size="md"
type="text"
pattern="(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]"
placeholder="240529-2e0a2"
defaultValue={this.state.ticketId}/>
</Col>
<Form.Label column sm="4">ID</Form.Label>
<Col sm="8">
<Form.Control ref={this.inputRtirRef} size="md"
type="number" placeholder="number"
defaultValue={this.state.rtir}/>
defaultValue={this.state.rtir}
readOnly/>
</Col>
<Form.Label column sm="4">Expiry Date</Form.Label>
<Col sm="8">
Expand Down Expand Up @@ -296,18 +310,20 @@ export class SuspiciousSites extends Component {
onSubmit = e => {
e.preventDefault();
const domain_name = this.inputDomainRef.current.value;
const ticket_id = this.inputTicketRef.current.value;
const rtir = this.inputRtirRef.current.value ? this.inputRtirRef.current.value : getMax(this.props.sites, "rtir")+1;
const expiry = this.state.day;
const ip_monitoring = this.ipMonitoringRef.current.checked;
const content_monitoring = this.webContentMonitoringRef.current.checked;
const mail_monitoring = this.emailMonitoringRef.current.checked;
const site = expiry ? {domain_name, rtir, expiry, ip_monitoring, content_monitoring, mail_monitoring} : {domain_name, rtir, ip_monitoring, content_monitoring, mail_monitoring};
const site = expiry ? {domain_name, ticket_id, rtir, expiry, ip_monitoring, content_monitoring, mail_monitoring} : {domain_name, ticket_id, rtir, ip_monitoring, content_monitoring, mail_monitoring};

this.props.addSite(site);
this.setState({
domainName: "",
day: "",
id: 0,
ticketId: "",
addLoading: true
});
handleClose();
Expand All @@ -331,9 +347,21 @@ export class SuspiciousSites extends Component {
placeholder="example.com"/>
</Col>
<Form.Label column sm="4">Ticket ID</Form.Label>
<Col sm="8">
<Form.Control
ref={this.inputTicketRef}
size="md"
type="text"
pattern="(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]"
placeholder="230509-200a2"
defaultValue={this.state.ticketId}/>
</Col>
<Form.Label column sm="4">ID</Form.Label>
<Col sm="8">
<Form.Control ref={this.inputRtirRef} size="md"
type="number" placeholder="number"/>
type="number" placeholder="number"
defaultValue={this.state.rtir}
readOnly/>
</Col>
<Form.Label column sm="4">Expiry Date</Form.Label>
<Col sm="8">
Expand Down Expand Up @@ -403,11 +431,12 @@ export class SuspiciousSites extends Component {
};


displayExportModal = (id, domainName, theHiveCaseId, mispEventId) => {
displayExportModal = (id, domainName, ticketId, theHiveCaseId, mispEventId) => {
this.setState({
showExportModal: true,
id: id,
domainName: domainName,
ticketId: ticketId,
theHiveCaseId: theHiveCaseId,
mispEventId: mispEventId
});
Expand All @@ -430,6 +459,7 @@ export class SuspiciousSites extends Component {
this.props.exportToTheHive(site);
this.setState({
domainName: "",
ticketId: "",
id: 0,
exportLoading: id
});
Expand All @@ -445,6 +475,7 @@ export class SuspiciousSites extends Component {
this.props.exportToMISP(site);
this.setState({
domainName: "",
ticketId: "",
id: 0,
exportLoading: id
});
Expand Down Expand Up @@ -529,7 +560,7 @@ export class SuspiciousSites extends Component {
<button className="btn btn-outline-primary btn-sm mr-2"
data-toggle="tooltip"
data-placement="top" title="Export" onClick={() => {
this.displayExportModal(site.id, site.domain_name, site.the_hive_case_id, site.misp_event_id)
this.displayExportModal(site.id, site.domain_name, site.ticket_id, site.the_hive_case_id, site.misp_event_id)
}} disabled={this.state.exportLoading === site.id}>

{this.state.exportLoading === site.id && (
Expand Down Expand Up @@ -571,8 +602,8 @@ export class SuspiciousSites extends Component {
<table className="table table-striped table-hover">
<thead>
<tr>
<th>Ticket ID</th>
<th>Domain Name</th>
<th>Ticket ID</th>
<th>Ip</th>
<th>Ip Second</th>
<th>MX Records</th>
Expand All @@ -587,8 +618,8 @@ export class SuspiciousSites extends Component {
<tbody>
{this.props.sites.map(site => (
<tr key={site.id}>
<td><h5>#{site.rtir}</h5></td>
<td><h5>{site.domain_name}</h5></td>
<td><h5>{site.ticket_id ? site.ticket_id : "-"}</h5></td>
<td>{site.ip ? site.ip : "-"}</td>
<td>{site.ip_second ? site.ip_second : "-"}</td>
<td>{site.MX_records ? site.MX_records.replace('[', '').replace(']', '').split("'").map(record => record) : "-"}</td>
Expand Down
4 changes: 2 additions & 2 deletions Watcher/Watcher/site_monitoring/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Meta:

@admin.register(Site)
class Site(ExportMixin, admin.ModelAdmin):
list_display = ['rtir', 'domain_name', 'ip', 'ip_second', 'monitored', 'web_status', 'misp_event_id',
list_display = ['rtir', 'domain_name', 'ticket_id','ip', 'ip_second', 'monitored', 'web_status', 'misp_event_id',
'the_hive_case_id', 'created_at', 'expiry']
list_filter = ['created_at', 'expiry', 'monitored', 'web_status']
search_fields = ['rtir', 'domain_name', 'ip', 'ip_second', 'the_hive_case_id', 'misp_event_id']
Expand All @@ -81,4 +81,4 @@ def has_add_permission(self, request):
class Subscriber(admin.ModelAdmin):
list_display = ['user_rec', 'created_at']
list_filter = ['created_at']
search_fields = ['user_rec']
search_fields = ['user_rec']
3 changes: 2 additions & 1 deletion Watcher/Watcher/site_monitoring/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Site(models.Model):
Stores a site which will be monitor (discrepancy in the hosting or in its DNS resolution, content hosted).
"""
domain_name = models.CharField(max_length=100, unique=True)
ticket_id = models.CharField(max_length=20, blank=True, null=True)
rtir = models.IntegerField()
ip = models.GenericIPAddressField(blank=True, null=True)
ip_second = models.GenericIPAddressField(blank=True, null=True)
Expand Down Expand Up @@ -83,4 +84,4 @@ class Subscriber(models.Model):
List of the email alert subscriber(s).
"""
user_rec = models.ForeignKey(User, on_delete=models.CASCADE, related_name='site_monitoring')
created_at = models.DateTimeField(default=timezone.now)
created_at = models.DateTimeField(default=timezone.now)

0 comments on commit f6f8d67

Please sign in to comment.