[ 
https://issues.apache.org/jira/browse/METRON-1724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16588904#comment-16588904
 ] 

ASF GitHub Bot commented on METRON-1724:
----------------------------------------

Github user ruffle1986 commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1172#discussion_r211970078
  
    --- Diff: metron-interface/metron-alerts/src/app/pcap/model/pcap.request.ts 
---
    @@ -17,13 +17,13 @@
      */
     
     export class PcapRequest {
    -  startTimeMs: number = 0;
    -  endTimeMs: number = 150000000000000000;
    -  ipSrcAddr: string = '';
    -  ipSrcPort: number;
    -  ipDstAddr: string = '';
    -  ipDstPort: number;
    -  protocol: string = '';
    -  packetFilter: string = '';
    -  includeReverse: boolean = false;
    +  startTimeMs = 0;
    +  endTimeMs = 150000000000000000;
    --- End diff --
    
    Why the magic number?
    
    We use this value to produce a formatted date string by using the Date 
constructor. But
    
    ```js
    new Date(150000000000000000) // -> Invalid Date
    ```
    
    so we have to do extra checks to avoid showing "Invalid Date" in the date 
range selector:
    
https://github.com/tiborm/metron/blob/METRON-1724/metron-interface/metron-alerts/src/app/pcap/pcap-filters/pcap-filters.component.ts#L59
    
    which makes it hard to understand and maintain the code.
    
    Using magic numbers is a bad practice because it's hard to understand their 
meaning. We should add a hint as a code comment at least. Or use another, more 
straightforward value. 
    My first thought was `Date.now()` but it would introduce side effects so I 
let it go.
    
    What do you think?


> Date/time validation missing in PCAP query
> ------------------------------------------
>
>                 Key: METRON-1724
>                 URL: https://issues.apache.org/jira/browse/METRON-1724
>             Project: Metron
>          Issue Type: Bug
>            Reporter: Tibor Meller
>            Priority: Major
>
> Validation formula should be the following: 
>  From < To < current date/time
>  
> Validation messages:
> Selected date range is invalid. The "To" date must be later than the "From" 
> date and the "To" date cannot be in the future.
> Source IP address format is invalid. Use valid v4IP format, for example, 
> [192.168.0.1|http://192.168.0.1/].
> Source port is invalid. Port number must be within the range of 0-65535.
> Destination IP address format is invalid. Use valid v4IP format, for example, 
> [192.168.0.1|http://192.168.0.1/].
> Destination port is invalid. Port number must be within the range of 0-65535.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to