public async Task <JsonResult> Save(PlatformConstant id, long specId, long?justificationId, SimplePortDirectionTypeConstant direction, PortTypeConstant portType,
                                            string justification, string ports)
        {
            if (!_justificationFactory.IsValidText(justification))
            {
                return(Json(JsonEnvelope.Error("The Justifcation cannot be empty whitespace.")));
            }

            if (!justificationId.HasValue)
            {
                Logger.LogInformation($"{UserSecurity.SamAccountName} added a new justification for ports: {justification}");
                justificationId =
                    await _justificationFactory.AddJustification(JustificationTypeConstant.Port, specId, justification);
            }
            else
            {
                Logger.LogInformation($"{UserSecurity.SamAccountName} updated justification {justificationId} for ports: {justification}");
                await _justificationFactory.UpdateJustification(justificationId.Value, justification);
            }

            await _portFactory.AddOrUpdatePorts(specId, justificationId.Value, direction == SimplePortDirectionTypeConstant.PortListeningToOutsideTraffic, direction == SimplePortDirectionTypeConstant.SendingTrafficToOusidePort, portType, ports);

            Logger.LogInformation($"{UserSecurity.SamAccountName} added or updated ports for spec {specId} ports are: {ports}");
            return(Json(JsonEnvelope.Success(new { url = Url.PartialOnePort(id, specId, justificationId.Value) })));
        }
        private static void RecurseSpecs(BuildSpecification spec, bool runningCoreOs, PciScopeConstant pciScope,
                                         int environmentId, out List <Port> ports, out List <SoftwareComponent> softwares,
                                         out string osName, out string osVersion, ref PlatformConstant pt)
        {
            softwares = new List <SoftwareComponent>();
            ports     = new List <Port>();
            osName    = spec.OperatingSystemName;
            osVersion = spec.OperatingSystemVersion;
            var it = spec;

            while (it != null)
            {
                osName    = it.OperatingSystemName;
                osVersion = it.OperatingSystemVersion;
                var softToAdd = runningCoreOs
                    ? it.SoftwareComponents.Where(p => !p.NonCore)
                    : it.SoftwareComponents;
                softToAdd = softToAdd.Where(p => p.PciScope == null || (p.PciScope & pciScope) != 0);
                softToAdd = softToAdd.Where(p => !p.SoftwareComponentEnvironments.Any() || p.SoftwareComponentEnvironments.Any(q => q.EnvironmentId == environmentId));
                softwares.AddRange(softToAdd);
                ports.AddRange(it.Ports.Where(p => !p.IsOutgoing));
                if (it.Platform.HasValue)
                {
                    pt = it.Platform.Value;
                }
                it = it.Parent;
            }
        }
 public OsSpecSearchResult(long id, string name, long ownerId, string owner, PlatformConstant platform, Counts counts)
 {
     Id       = id;
     Name     = name;
     OwnerId  = ownerId;
     Owner    = owner;
     Platform = platform;
     Counts   = counts;
 }
 public OwnerScoreCardRow(long id, string specName, long?parentId, string parentName, BuildSpecificationTypeConstant buildSpecificationType, PlatformConstant platform, int nodeCount, int passingNodeCount, int failingNodeCount,
                          ScoreCardCount totalSoftwareCount, ScoreCardCount unjustifiedSoftwareCount, ScoreCardCount portCount)
 {
     Id                       = id;
     SpecName                 = specName;
     ParentId                 = parentId;
     ParentName               = parentName;
     BuildSpecificationType   = buildSpecificationType;
     Platform                 = platform;
     NodeCount                = nodeCount;
     PassingNodeCount         = passingNodeCount;
     FailingNodeCount         = failingNodeCount;
     TotalSoftwareCount       = totalSoftwareCount;
     UnjustifiedSoftwareCount = unjustifiedSoftwareCount;
     PortCount                = portCount;
 }
 public NodeSearchResult(long id, string fqdn, string owner, string product, string function, PciScopeConstant pciScope, int environmentId, string environmentName, string environmentDescription, string environmentColor, PlatformConstant platform, long?buildSpecId, string buildSpecName, ComplianceStatusConstant complianceStatus, DateTime?lastComplianceDate, Guid?chefId, bool showButtons)
 {
     Id                     = id;
     Fqdn                   = fqdn;
     Owner                  = owner;
     Product                = product;
     Function               = function;
     SecurityClass          = pciScope.ToString();
     EnvironmentDescription = environmentDescription;
     EnvironmentColor       = environmentColor;
     EnvironmentName        = environmentName;
     EnvironmentId          = environmentId;
     Platform               = platform;
     BuildSpecId            = buildSpecId;
     BuildSpecName          = buildSpecName;
     ComplianceStatus       = complianceStatus;
     LastComplianceDate     = lastComplianceDate;
     ChefId                 = chefId;
     ShowButtons            = showButtons;
 }
Exemplo n.º 6
0
 public static string PartialBulkNewPorts(this IUrlHelper helper, PlatformConstant platform, long specId)
 {
     return(helper.RouteUrl("default", new { controller = "Ports", action = "Bulk", id = platform, specId }));
 }
Exemplo n.º 7
0
 public static string PartialPortsScreen(this IUrlHelper helper, PlatformConstant platform)
 {
     return(helper.RouteUrl("default", new { controller = "Ports", action = "ForSpec", id = platform }));
 }
 public static IQueryable<Node> ByPlatform(this IQueryable<Node> nodes, PlatformConstant platform)
 {
     return nodes.Where(p => p.Platform == platform);
 }
Exemplo n.º 9
0
 public ViewPort(PlatformConstant platform, long specId, SimplePort port) : base(platform, specId, port)
 {
 }
Exemplo n.º 10
0
 public PortsScreen(PlatformConstant platform, long specId)
 {
     Platform = platform;
     SpecId   = specId;
 }
        public async Task <PartialViewResult> One(PlatformConstant id, long specId, long justificationId)
        {
            var port = await _portFactory.GetPort(justificationId);

            return(PartialView(new ViewPort(id, specId, port)));
        }
        public async Task <PartialViewResult> Get(PlatformConstant id, long specId)
        {
            var ports = await _portFactory.GetPorts(specId);

            return(PartialView(new SimplePorts(id, ports.Select(p => new ViewPort(id, specId, p)))));
        }
 public PartialViewResult ForSpec(PlatformConstant id, long specId)
 {
     return(PartialView(new PortsScreen(id, specId)));
 }
Exemplo n.º 14
0
 public SimplePorts(PlatformConstant platform, IEnumerable <ViewPort> ports) : base(ports)
 {
     Platform = platform;
 }
Exemplo n.º 15
0
 public static string JsonSavePort(this IUrlHelper helper, PlatformConstant platform)
 {
     return(helper.RouteUrl("default", new { controller = "Ports", action = "Save", id = platform }));
 }
Exemplo n.º 16
0
 public static string PartialOnePort(this IUrlHelper helper, PlatformConstant platform, long specId, long justificationId)
 {
     return(helper.RouteUrl("default", new { controller = "Ports", action = "One", id = platform, specId, justificationId }));
 }
 public PartialViewResult New(PlatformConstant id, long specId)
 {
     return(PartialView(new NewPort(id, specId)));
 }
Exemplo n.º 18
0
 public NewPort(PlatformConstant platform, long specId)
 {
     Platform = platform;
     SpecId   = specId;
 }
 public PartialViewResult Bulk(PlatformConstant id, long specId)
 {
     return(PartialView(new BulkNewPorts(id, specId)));
 }
Exemplo n.º 20
0
 public BulkNewPorts(PlatformConstant platform, long specId) : base(platform, specId)
 {
 }
Exemplo n.º 21
0
 public EditPort(PlatformConstant platform, long specId, SimplePort port) : base(platform, specId)
 {
     Port = port;
 }