home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2004 July / APC0407D1.iso / powerkit / firewall / files / NPF2004.exe / Setup / ISCommon / APP / fwUI.dll / HTML / RULETXT.JS < prev    next >
Encoding:
JavaScript  |  2003-09-06  |  4.0 KB  |  185 lines

  1. ////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // PRODUCT: Norton Internet Security/Symantec Desktop Firewall
  4. //
  5. // NAME:    Ruletxt.js 
  6. //
  7. // Copyright (c) 2001 by Symantec Corporation. All rights reserved.
  8. //
  9. ////////////////////////////////////////////////////////////////////////////////////////////
  10.  
  11. function getComputerListStr(rule)
  12. {
  13.  
  14.     var returnstring = StrID("computer_any");
  15.  
  16.     var remoteaddresses = rule.RemoteIPs;
  17.  
  18.     if(null != remoteaddresses)
  19.     {        
  20.         if(0 != remoteaddresses.ItemCount)
  21.             returnstring = StrID("computer_specific");
  22.     }
  23.  
  24.     return returnstring;
  25. }
  26.  
  27. function getAdapterText(rule)
  28. {
  29.  
  30.     var returnstring = StrID("adapter_any");
  31.  
  32.     var adapters = rule.LocalIPs;
  33.  
  34.     if(null != adapters)
  35.     {        
  36.         if(0 != adapters.ItemCount)
  37.             returnstring = StrID("adapter_specific");
  38.     }
  39.  
  40.     return returnstring;
  41. }
  42.  
  43. function getLoggingStr(rule)
  44. {
  45.     returnstring = "";
  46.  
  47.     val = rule.Logging;    
  48.  
  49.     if(val & 32)
  50.         returnstring += StrID("logging_atracker");
  51.     if(val & 1)
  52.     {
  53.         if ("" != returnstring)
  54.             returnstring += ", ";
  55.         returnstring += StrID("logging_log");
  56.     }
  57.     if(val & 18)
  58.     {
  59.         if ("" != returnstring)
  60.             returnstring += ", ";
  61.         returnstring += StrID("logging_alert");
  62.     }
  63.   
  64.     if("" != returnstring)
  65.         returnstring = StrID("tracking") + returnstring;
  66.     return returnstring;
  67. }
  68.  
  69. function getProtocolString(protocol)
  70. {
  71.     var strProt = "";
  72.  
  73.     switch(protocol)
  74.     {
  75.         case 0:
  76.             strProt = StrID("TCPANDUDP_Protocol");
  77.             break;
  78.  
  79.         case 1:
  80.             strProt = StrID("ICMP_Protocol");
  81.             break;
  82.  
  83.         case 6:
  84.             strProt = StrID("TCP_Protocol");
  85.             break;
  86.  
  87.         case 17:
  88.             strProt = StrID("UDP_Protocol");
  89.             break;
  90.     }    
  91.  
  92.     return strProt;
  93. }    
  94.  
  95. function getLocationsText(arrayLocations)
  96. {
  97.     var strLocations = StrID("LocationsColon");
  98.     var nLocations = arrayLocations.length;
  99.     for (var i=0; i<nLocations; i++)
  100.     {
  101.         if (i > 0) strLocations += ", ";
  102.         strLocations += arrayLocations[i];
  103.     }
  104.     return strLocations;
  105. }
  106.  
  107. function developRuleString(rule, arrayLocations)
  108. {
  109.     var sep = StrID("string_separation");
  110.  
  111.     return ruleString(rule, arrayLocations, sep);
  112. }
  113.  
  114. function ruleString(rule, arrayLocations, sep)
  115. {
  116.  
  117.     var Action = "";
  118.     var Direction = "";
  119.     var Services = "";
  120.     var ComputerType = "";
  121.     var Adapter = "";
  122.     var returnstring= "";    
  123.     var sLocations = "";
  124.  
  125.     switch (rule.Action)
  126.     {
  127.         case 2: // Permit
  128.             Action = "<span class=nisPermitTx>"+StrID("permit")+"</span>";
  129.             break;
  130.         case 1: // Block
  131.             Action = "<span class=nisBlockTx>"+StrID("block")+"</span>";
  132.             break;
  133.         case 4: // Monitor
  134.             Action = "<span class=nisMonitorTx>"+StrID("monitor")+"</span>";
  135.             break;
  136.         default:
  137.             Action = "";
  138.             break;
  139.     }
  140.  
  141.     switch (rule.Direction)
  142.     {
  143.         case 2: // In
  144.             Direction = StrID("direction_inbound_localhost_any");
  145.             break;
  146.         case 1: // Out
  147.             Direction = StrID("direction_outbound_localhost_any");
  148.             break;
  149.         case 3: // In-Out
  150.             Direction = StrID("direction_either_localhost_any");
  151.             break;
  152.         default:
  153.             Direction = "";
  154.             break;
  155.     }
  156.  
  157.     Services = getGenericServicesStr(rule);
  158.     ComputerType = getComputerListStr(rule);
  159.     Adapter = getAdapterText(rule);
  160.  
  161.     var Protocol = StrID("protocol") + getProtocolString(rule.Protocol);
  162.     var logging = getLoggingStr(rule);
  163.     if (logging != "")
  164.         logging = sep + logging;
  165.  
  166.     if (typeof(arrayLocations) != "undefined")
  167.     {
  168.         sLocations = getLocationsText(arrayLocations);
  169.         if (sLocations != "")
  170.             sLocations = sep + sLocations;
  171.     }
  172.     
  173.     returnstring =  Action + sep + 
  174.         Direction + sep + 
  175.         ComputerType + sep + 
  176.         Adapter + sep + 
  177.         Services + sep + 
  178.         Protocol +    // no sep becuase logging can be empty
  179.         logging +    // no sep becuase sLocations can be empty
  180.         sLocations;
  181.     
  182.     return     returnstring;
  183.  
  184. }
  185.