示例#1
0
        private async Task WriteIndexTags(SoftwareIdentity indexJsonTag, SoftwareIdentity indexXmlTag, CloudBlobDirectory sourceDirectory)
        {
            var blobJson = sourceDirectory.GetBlockBlobReference("index.json.SoftwareIdentity");

            var blobXml = sourceDirectory.GetBlockBlobReference("index.xml.SoftwareIdentity");

            var json = indexJsonTag.SwidTagJson;

            var xml = indexXmlTag.SwidTagXml;

            await Task.WhenAll(
                blobJson.UploadTextAsync(json),
                blobXml.UploadTextAsync(xml)
                );

            blobJson.Properties.CacheControl = "public, max-age=300"; // cache for 5 minutes.
            blobXml.Properties.CacheControl  = "public, max-age=300"; // cache for 5 minutes.

            blobJson.Properties.ContentType = FearTheCowboy.Iso19770.Schema.MediaType.SwidTagJsonLd;
            blobXml.Properties.ContentType  = FearTheCowboy.Iso19770.Schema.MediaType.SwidTagXml;

            await Task.WhenAll(
                blobJson.SetPropertiesAsync(),
                blobXml.SetPropertiesAsync()
                );
        }
示例#2
0
        public void EmptyPayloadAndEvidence()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                swid.AddPayload();
                swid.AddEvidence();

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
                Assert.Empty(swid.Payload.Files);
                Assert.Empty(swid.Payload.Directories);
                Assert.Empty(swid.Payload.Processes);
                Assert.Empty(swid.Payload.Resources);

                Assert.Empty(swid.Evidence.Files);
                Assert.Empty(swid.Evidence.Directories);
                Assert.Empty(swid.Evidence.Processes);
                Assert.Empty(swid.Evidence.Resources);

                Assert.Empty(swid.Payload.Attributes.Values);
                Assert.Empty(swid.Evidence.Attributes.Keys);

                Assert.Null(swid.Evidence.Date);
                Assert.Null(swid.Evidence.DeviceId);
            }
        }
示例#3
0
        /// <summary>
        ///  Validate if the package is a provider package.
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        protected bool ValidatePackageProvider(SoftwareIdentity package)
        {
            //no need to filter on the packages from the bootstrap site as only providers will be published out there.
            if (package.ProviderName.EqualsIgnoreCase("Bootstrap"))
            {
                return(true);
            }

            //get the tags info from the package's swid
            var tags = package.Metadata["tags"].ToArray();

            //Check if the provider has provider tags
            var found = false;

            foreach (var filter in ProviderFilters)
            {
                found = false;
                if (tags.Any(tag => tag.ContainsIgnoreCase(filter)))
                {
                    found = true;
                }
                else
                {
                    break;
                }
            }
            return(found);
        }
示例#4
0
        private bool UpdateIndexTags(SoftwareIdentity indexJsonTag, SoftwareIdentity indexXmlTag, List <AddedTagResult> addedTags, List <UpdatedTagResult> updatedTags, List <DeleteTagResult> deleteTags)
        {
            var any = false;

            foreach (var added in addedTags)
            {
                indexJsonTag.AddLink(added.NewSourceUris.JsonUri, "package");
                indexXmlTag.AddLink(added.NewSourceUris.XmlUri, "package");

                any = true;
            }

            foreach (var update in updatedTags)
            {
                indexJsonTag.RemoveLink(update.OldSourceUris.JsonUri);
                indexXmlTag.RemoveLink(update.OldSourceUris.XmlUri);

                indexJsonTag.AddLink(update.NewSourceUris.JsonUri, "package");
                indexXmlTag.AddLink(update.NewSourceUris.XmlUri, "package");

                any = true;
            }

            foreach (var uri in deleteTags)
            {
                indexJsonTag.RemoveLink(uri.DeleteSourceUris.JsonUri);
                indexXmlTag.RemoveLink(uri.DeleteSourceUris.XmlUri);

                any = true;
            }

            return(any);
        }
示例#5
0
        private string GetSoftwareIdentityTypeName(SoftwareIdentity package)
        {
            if (_initializedTypeName)
            {
                return(_softwareIdentityTypeName);
            }

            //check if a user specifies -source with a long source name such as http://www.powershellgallery.com/api/v2,
            // if so we will choose the longsource column format.
            if (!UseDefaultSourceFormat)
            {
                _softwareIdentityTypeName += "#DisplayLongSourceName";
                _hasTypeNameChanged        = true;
            }
            //provider has the "DisplayCulture" in the Get-DynamicOption()
            if (IsDisplayCulture)
            {
                _softwareIdentityTypeName += "#DisplayCulture";
                _hasTypeNameChanged        = true;
            }

            //provider defines the 'DisplayLongName' feature in the Get-Feature()
            if (package != null && (package.Provider != null && (package.Provider.Features != null && package.Provider.Features.ContainsKey("DisplayLongName"))))
            {
                _softwareIdentityTypeName += "#DisplayLongName";
                _hasTypeNameChanged        = true;
            }

            _initializedTypeName = true;

            return(_softwareIdentityTypeName);
        }
示例#6
0
        public void EmptyPayloadAndEvidence()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                swid.AddPayload();
                swid.AddEvidence();

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
                Assert.Empty(swid.Payload.Files);
                Assert.Empty(swid.Payload.Directories);
                Assert.Empty(swid.Payload.Processes);
                Assert.Empty(swid.Payload.Resources);

                Assert.Empty(swid.Evidence.Files);
                Assert.Empty(swid.Evidence.Directories);
                Assert.Empty(swid.Evidence.Processes);
                Assert.Empty(swid.Evidence.Resources);

                Assert.Empty(swid.Payload.Attributes.Values);
                Assert.Empty(swid.Evidence.Attributes.Keys);

                Assert.Null(swid.Evidence.Date);
                Assert.Null(swid.Evidence.DeviceId);
            }
        }
示例#7
0
        private IEnumerable <SoftwareIdentity> GetDependenciesToInstall(SoftwareIdentity package, ref bool hasDependencyLoop)
        {
            // No dependency
            if (package.Dependencies == null || package.Dependencies.Count() == 0)
            {
                return(Enumerable.Empty <SoftwareIdentity>());
            }

            // Returns list of dependency to be installed in the correct order that we should install them
            List <SoftwareIdentity> dependencyToBeInstalled = new List <SoftwareIdentity>();

            HashSet <SoftwareIdentity> permanentlyMarked = new HashSet <SoftwareIdentity>(new SoftwareIdentityNameVersionComparer());
            HashSet <SoftwareIdentity> temporarilyMarked = new HashSet <SoftwareIdentity>(new SoftwareIdentityNameVersionComparer());

            // checks that there are no dependency loop
            hasDependencyLoop = !DepthFirstVisit(package, temporarilyMarked, permanentlyMarked, dependencyToBeInstalled);

            if (!hasDependencyLoop)
            {
                // remove the last item of the list because that is the package itself
                dependencyToBeInstalled.RemoveAt(dependencyToBeInstalled.Count - 1);
                return(dependencyToBeInstalled);
            }

            // there are dependency loop.
            return(Enumerable.Empty <SoftwareIdentity>());
        }
示例#8
0
文件: HostTest.cs 项目: FLGMwt/oneget
        public void Provider_InstallandUninstallPackage()
        {
            lock (_lock) {
                var pkgs = TestPSProvider.FindPackageByFile(@"c:\test\x.testpkg", 0, Request).ToArray();
                Assert.Equal(1, pkgs.Length);

                SoftwareIdentity installedPkg = null;

                foreach (var pkg in pkgs)
                {
                    pkgs = TestPSProvider.InstallPackage(pkg, Request).ToArray();
                    Assert.Equal(1, pkgs.Length);
                    installedPkg = pkgs.FirstOrDefault();
                }

                pkgs = TestPSProvider.GetInstalledPackages(null, Request).ToArray();
                Assert.Equal(4, pkgs.Length);

                pkgs = TestPSProvider.UninstallPackage(installedPkg, Request).ToArray();
                Assert.Equal(1, pkgs.Length);

                pkgs = TestPSProvider.GetInstalledPackages(null, Request).ToArray();
                Assert.Equal(3, pkgs.Length);
            }
        }
示例#9
0
        //Calling PowerShell Telemetry APIs
        protected void TraceMessage(string message, SoftwareIdentity swidObject)
        {
            try
            {
                if (!OSInformation.IsWindowsPowerShell)
                {
                    return;
                }

                if (!telemetryAPIInitialized)
                {
                    telemetryAPIInitialized = true;

                    // try to load telemetry api from sma
                    // we have to check for telemetry type instead of just running try catch because if telemetryapi cannot be loaded, the error
                    // will not be caught in this try catch
                    Assembly sma = typeof(Cmdlet).GetTypeInfo().Assembly;

                    TelemetryAPIType = sma.GetType("Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI");
                }

                if (TelemetryAPIType != null)
                {
                    // if the type exists
                    TraceMessageHelper(message, swidObject);
                }
            }
            catch (Exception ex)
            {
                Verbose(ex.Message);
            }
        }
示例#10
0
        public ICancellableEnumerable <SoftwareIdentity> InstallPackage(SoftwareIdentity softwareIdentity, RequestImpl requestImpl)
        {
            if (requestImpl == null)
            {
                throw new ArgumentNullException("requestImpl");
            }

            if (softwareIdentity == null)
            {
                throw new ArgumentNullException("softwareIdentity");
            }

            var request = ExtendRequest(requestImpl);

            ;

            // if the provider didn't say this was trusted, we should ask the user if it's ok.
            if (!softwareIdentity.FromTrustedSource)
            {
                try {
                    if (!request.ShouldContinueWithUntrustedPackageSource(softwareIdentity.Name, softwareIdentity.Source))
                    {
                        request.Warning(request.FormatMessageString(Constants.UserDeclinedUntrustedPackageInstall, softwareIdentity.Name));
                        return(new CancellableEnumerable <SoftwareIdentity>(new CancellationTokenSource(), Enumerable.Empty <SoftwareIdentity>()));
                    }
                } catch {
                    return(new CancellableEnumerable <SoftwareIdentity>(new CancellationTokenSource(), Enumerable.Empty <SoftwareIdentity>()));
                }
            }

            return(new Response <SoftwareIdentity>(requestImpl, this, Constants.Installed, response => Provider.InstallPackage(softwareIdentity.FastPackageReference, response)).Result);
        }
示例#11
0
        public void Metadata()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                swid.AddAttribute(XNamespace.Get("http://oneget.org/swidtag") + "test", "value");

                // add some data
                var meta1 = swid.AddMeta();
                meta1.AddAttribute("Key", "Value");
                meta1.AddAttribute("Key2", "Value");
                meta1.AddAttribute(XNamespace.Get("http://oneget.org/swidtag") + "other", "somevalue");

                var meta2 = swid.AddMeta();
                meta2.AddAttribute(XNamespace.Get("http://oneget.org/swidtag") + "other2", "somevalue2");

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
                Assert.Equal(3, meta1.Attributes.Keys.Count());
                Assert.Equal(1, meta2.Attributes.Keys.Count());

                Assert.Equal("Value", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta[1]/@Key").Value);
                Assert.Equal("Value", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta[1]/@Key2").Value);
                Assert.Equal("somevalue", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta[1]/@oneget:other").Value);
            }
        }
示例#12
0
        public IAsyncEnumerable <SoftwareIdentity> InstallPackage(SoftwareIdentity softwareIdentity, IRequestObject requestObject)
        {
            if (requestObject == null)
            {
                throw new ArgumentNullException("requestObject");
            }

            if (softwareIdentity == null)
            {
                throw new ArgumentNullException("softwareIdentity");
            }
            var hostApi = requestObject.As <IHostApi>();

            // if the provider didn't say this was trusted, we should ask the user if it's ok.
            if (!softwareIdentity.FromTrustedSource)
            {
                try {
                    if (!hostApi.ShouldContinueWithUntrustedPackageSource(softwareIdentity.Name, softwareIdentity.Source))
                    {
                        hostApi.Warning(hostApi.FormatMessageString(Constants.Messages.UserDeclinedUntrustedPackageInstall, softwareIdentity.Name));
                        return(new EmptyAsyncEnumerable <SoftwareIdentity>());
                    }
                } catch {
                    return(new EmptyAsyncEnumerable <SoftwareIdentity>());
                }
            }

            return(new SoftwareIdentityRequestObject(this, requestObject.As <IHostApi>(), request => Provider.InstallPackage(softwareIdentity.FastPackageReference, request), Constants.PackageStatus.Installed));
        }
示例#13
0
        private async Task <UpdatedTagResult> UpdateTag(string sourceAzid, CloudBlobDirectory sourceDirectory, TagTable tagsTable, TagTransactionEntity tagTx)
        {
            var oldTagEntity = tagsTable.GetPrimaryTag(sourceAzid, tagTx.Id);

            var json = await this.GetBlobAsString(tagTx.StagedBlobUri);

            var softwareIdentity = SoftwareIdentity.LoadJson(json);

            var tagEntity = this.CreateTagEntityFromSoftwareIdentity(sourceAzid, tagTx, softwareIdentity);

            var redirects = UpdateInstallationMediaLinksInSoftwareIdentityAndReturnWithRedirects(sourceAzid, tagEntity.TagAzid, tagEntity.Uid, softwareIdentity);

            var tagUris = await WriteVersionedTag(sourceDirectory, tagEntity, softwareIdentity);

            tagEntity.JsonBlobName = tagUris.JsonUri.AbsoluteUri;

            tagEntity.XmlBlobName = tagUris.XmlUri.AbsoluteUri;

            var primaryTag = tagEntity.AsPrimary();

            primaryTag.DownloadCount = oldTagEntity.DownloadCount;

            return(new UpdatedTagResult()
            {
                NewSourceUris = tagUris,
                OldSourceUris = new TagBlobUris
                {
                    JsonUri = new Uri(oldTagEntity.JsonBlobName),
                    XmlUri = new Uri(oldTagEntity.XmlBlobName)
                },
                Redirects = redirects,
                Tag = tagEntity,
                PrimaryTag = primaryTag
            });
        }
示例#14
0
        private bool InstallPackageReference(Package provider, string fastPath, BootstrapRequest request, SoftwareIdentity[] packages)
        {
            IHostApi installRequest = request;

            if (packages[0].Provider.Name.EqualsIgnoreCase("PowerShellGet") && !request.ProviderServices.IsElevated)
            {
                // if we're not elevated, we want powershellget to install to the user scope

                installRequest = new object[] {
                    new {
                        GetOptionKeys   = new Func <IEnumerable <string> >(() => request.OptionKeys.ConcatSingleItem("Scope")),
                        GetOptionValues = new Func <string, IEnumerable <string> >((key) => {
                            if (key != null && key.EqualsIgnoreCase("Scope"))
                            {
                                return("CurrentUser".SingleItemAsEnumerable());
                            }
                            return(request.GetOptionValues(key));
                        })
                    }
                    , installRequest
                }.As <IHostApi>();
            }

            var installing = packages[0].Provider.InstallPackage(packages[0], installRequest);

            SoftwareIdentity lastPackage = null;

            foreach (var i in installing)
            {
                lastPackage = i;
                // should we echo each package back as it comes back?
                request.YieldSoftwareIdentity(i.FastPackageReference, i.Name, i.Version, i.VersionScheme, i.Summary, i.Source, i.SearchKey, i.FullPath, i.PackageFilename);

                if (request.IsCanceled)
                {
                    installing.Cancel();
                }
            }

            if (!request.IsCanceled && lastPackage != null)
            {
                if (provider.Name.EqualsIgnoreCase("PowerShellGet"))
                {
                    // special case. PSModules we can just ask the PowerShell provider to pick it up
                    // rather than try to scan for it.
                    PackageManagementService.TryLoadProviderViaMetaProvider("PowerShell", lastPackage.FullPath, request);
                    request.YieldFromSwidtag(provider, fastPath);
                    return(true);
                }

                // looks like it installed ok.
                request.YieldFromSwidtag(provider, fastPath);

                // rescan providers
                PackageManagementService.LoadProviders(request.As <IRequest>());
                return(true);
            }
            return(false);
        }
示例#15
0
 protected virtual void ProcessPackage(SoftwareIdentity package)
 {
     // Check for duplicates
     if (!IsDuplicate(package))
     {
         WriteObject(AddPropertyToSoftwareIdentity(package));
     }
 }
示例#16
0
 private void CommitSoftwareIdentity()
 {
     if (_currentSoftwareIdentity != null && typeof(T) == typeof(SoftwareIdentity))
     {
         _result.Add((T)(object)_currentSoftwareIdentity);
     }
     _currentSoftwareIdentity = null;
 }
示例#17
0
 protected virtual void ProcessPackage(string query, SoftwareIdentity package)
 {
     // Check for duplicates
     if (!IsDuplicate(package))
     {
         WriteObject(package);
     }
 }
示例#18
0
 protected override void ProcessPackage(SoftwareIdentity package)
 {
     if (null != package && !package.CanonicalId.IsNullOrEmpty())
     {
         // mark down that we found something for that query
         // Need a identifier for maintaining the list of packages to uninstall in a dictionary.
         // Canonical ID consists of packagename, version, repo which is unique
         _resultsPerName.GetOrAdd(package.CanonicalId, () => new List <SoftwareIdentity>()).Add(package);
     }
 }
示例#19
0
 //Calling PowerShell Telemetry APIs
 protected void TraceMessage(string message, SoftwareIdentity swidObject)
 {
     TelemetryAPI.TraceMessage(message,
                               new {
         PackageName         = swidObject.Name,
         PackageVersion      = swidObject.Version,
         PackageProviderName = swidObject.ProviderName,
         Repository          = swidObject.Source,
         ExuectionStatus     = swidObject.Status,
         ExecutionTime       = DateTime.Today
     });
 }
示例#20
0
        private static bool TryLoadXmlTag(string text, out SoftwareIdentity tag)
        {
            try
            {
                tag = SoftwareIdentity.LoadXml(text);
            }
            catch (Exception)
            {
                tag = null;
            }

            return(tag != null);
        }
示例#21
0
        public void SimpleTag()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity()
                {
                    Name                 = "SamplePackage",
                    FullPath             = "c:\\tmp\\path",
                    FastPackageReference = "some-string",
                    IsPatch              = false,
                    Source               = "test-source",
                    SearchKey            = "search-key",
                    Status               = "test-status",
                    TagId                = "some-tag-id",
                    Version              = "1.0",
                    VersionScheme        = "multipart-numeric",
                    FromTrustedSource    = true,
                    IsSupplemental       = false,
                    IsCorpus             = false,
                    Summary              = "Summary Text",
                    AppliesToMedia       = "Windows",
                    PackageFilename      = "c:\\tmp\\path\\filename.txt",
                    TagVersion           = "1",
                };

                // add some arbitrary metadata
                var meta = swid.AddMetadataValue(swid.FastPackageReference, "sample", "value");
                Assert.NotNull(meta);

                var xml = XDocument.Parse(swid.SwidTagText);

                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                Assert.Equal("SamplePackage", xml.XPathToAttribute("/swid:SoftwareIdentity/@name").Value);

                var v = xml.XPathToAttribute("/swid:SoftwareIdentity/@tagId").Value;

                Assert.Equal("some-tag-id", xml.XPathToAttribute("/swid:SoftwareIdentity/@tagId").Value);
                Assert.Equal("1.0", xml.XPathToAttribute("/swid:SoftwareIdentity/@version").Value);
                Assert.Equal("multipart-numeric", xml.XPathToAttribute("/swid:SoftwareIdentity/@versionScheme").Value);
                Assert.Equal("1", xml.XPathToAttribute("/swid:SoftwareIdentity/@tagVersion").Value);
                Assert.Equal("Windows", xml.XPathToAttribute("/swid:SoftwareIdentity/@media").Value);

                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@patch").Value.IsFalse());
                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@supplemental").Value.IsFalse());
                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@corpus").Value.IsFalse());

                Assert.Equal("Summary Text", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta/@summary").Value);

                Assert.Equal("value", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta/@sample").Value);
            }
        }
示例#22
0
        public void DownloadPackage(SoftwareIdentity softwareIdentity, string destinationFilename, RequestImpl requestImpl)
        {
            if (requestImpl == null)
            {
                throw new ArgumentNullException("requestImpl");
            }

            if (softwareIdentity == null)
            {
                throw new ArgumentNullException("softwareIdentity");
            }

            Provider.DownloadPackage(softwareIdentity.FastPackageReference, destinationFilename, ExtendRequest(requestImpl));
        }
示例#23
0
        protected virtual void ProcessPackage(SoftwareIdentity package)
        {
            // Check for duplicates
            if (!IsDuplicate(package))
            {
                // Display the SoftwareIdentity object in a format: Name, Version, Source and Provider
                var swidTagAsPsobj = PSObject.AsPSObject(package);
                var noteProperty   = new PSNoteProperty("PropertyOfSoftwareIdentity", "PropertyOfSoftwareIdentity");
                swidTagAsPsobj.Properties.Add(noteProperty, true);
                swidTagAsPsobj.TypeNames.Insert(0, _newSoftwareIdentityTypeName);

                WriteObject(swidTagAsPsobj);
            }
        }
示例#24
0
 private void TraceMessageHelper(string message, SoftwareIdentity swidObject)
 {
     #if !CORECLR
     Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI.TraceMessage(message, new
     {
         PackageName         = swidObject.Name,
         PackageVersion      = swidObject.Version,
         PackageProviderName = swidObject.ProviderName,
         Repository          = swidObject.Source,
         ExecutionStatus     = swidObject.Status,
         ExecutionTime       = DateTime.Today
     });
     #endif
 }
示例#25
0
        public IAsyncAction DownloadPackage(SoftwareIdentity softwareIdentity, string destinationFilename, IRequestObject requestObject)
        {
            if (requestObject == null)
            {
                throw new ArgumentNullException("requestObject");
            }

            if (softwareIdentity == null)
            {
                throw new ArgumentNullException("softwareIdentity");
            }

            return(new ActionRequestObject(this, requestObject.As <IHostApi>(), request => Provider.DownloadPackage(softwareIdentity.FastPackageReference, destinationFilename, request)));
        }
示例#26
0
        public IAsyncEnumerable <SoftwareIdentity> DownloadPackage(SoftwareIdentity softwareIdentity, string destinationFilename, IHostApi requestObject)
        {
            if (requestObject == null)
            {
                throw new ArgumentNullException("requestObject");
            }

            if (softwareIdentity == null)
            {
                throw new ArgumentNullException("softwareIdentity");
            }

            return(new SoftwareIdentityRequestObject(this, requestObject, request => Provider.DownloadPackage(softwareIdentity.FastPackageReference, destinationFilename, request), Constants.PackageStatus.Downloaded));
        }
示例#27
0
        public void Evidence()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                var evidence = swid.AddEvidence();

                var now = DateTime.Now;
                evidence.Date = now;

                evidence.DeviceId = "someid";

                var dir1 = evidence.AddDirectory("dir1");
                dir1.Location = "myapp";
                dir1.Root     = "PROGRAMFILES";
                dir1.IsKey    = false;

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions

                // verify only one element is actually created.
                Assert.Equal(evidence.ElementUniqueId, swid.AddEvidence().ElementUniqueId);

                // most is the same code as Payload...

                // check to make sure the object we got back is the same as we put in.
                dir1 = evidence.Directories.FirstOrDefault();
                Assert.Equal("dir1", dir1.Name);
                Assert.Equal("myapp", dir1.Location);
                Assert.Equal("PROGRAMFILES", dir1.Root);
                Assert.False(dir1.IsKey);

                Assert.Equal(now.ToUniversalTime(), ((DateTime)evidence.Date).ToUniversalTime());
                Assert.Equal("someid", evidence.DeviceId);

                // some xml validations:
                Assert.Equal("dir1", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Evidence/swid:Directory[1]/@name").Value);

                // check for the device id
                Assert.Equal("someid", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Evidence/@deviceId").Value);

                // validate the format of the date
                Assert.Equal(now.ToUniversalTime().ToString("o"), xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Evidence/@date").Value);
            }
        }
示例#28
0
        public void WhatHappensWithDuplicateMetadata()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                var meta = swid.AddMetadataValue(swid.FastPackageReference, "sample", "value");
                Assert.NotNull(meta);

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
            }
        }
示例#29
0
        public SoftwareIdentity GetPackageDetails(SoftwareIdentity softwareIdentity, IHostApi requestObject)
        {
            if (requestObject == null)
            {
                throw new ArgumentNullException("requestObject");
            }

            if (softwareIdentity == null)
            {
                throw new ArgumentNullException("softwareIdentity");
            }

            new PackageDetailsRequestObject(this, requestObject, softwareIdentity, request => Provider.GetPackageDetails(softwareIdentity.FastPackageReference, request)).Wait();

            return(softwareIdentity);
        }
示例#30
0
        /// <summary>
        /// Do a dfs visit. returns false if a cycle is encountered. Add the packageItem to the list at the end of each visit
        /// </summary>
        /// <param name="packageItem"></param>
        /// <param name="dependencyToBeInstalled"></param>
        /// <param name="permanentlyMarked"></param>
        /// <param name="temporarilyMarked"></param>
        /// <returns></returns>
        internal bool DepthFirstVisit(SoftwareIdentity packageItem, HashSet <SoftwareIdentity> temporarilyMarked,
                                      HashSet <SoftwareIdentity> permanentlyMarked, List <SoftwareIdentity> dependencyToBeInstalled)
        {
            // dependency loop detected because the element is temporarily marked
            if (temporarilyMarked.Contains(packageItem))
            {
                return(false);
            }

            // this is permanently marked. So we don't have to visit it.
            // This is to resolve a case where we have: A->B->C and A->C. Then we need this when we visit C again from either B or A.
            if (permanentlyMarked.Contains(packageItem))
            {
                return(true);
            }

            // Mark this node temporarily so we can detect cycle.
            temporarilyMarked.Add(packageItem);

            // Visit the dependency
            foreach (var dependency in packageItem.Dependencies)
            {
                var dependencies = PackageManagementService.FindPackageByCanonicalId(dependency, this);
                var depPkg       = dependencies.OrderByDescending(pp => pp, SoftwareIdentityVersionComparer.Instance).FirstOrDefault();

                if (!DepthFirstVisit(depPkg, temporarilyMarked, permanentlyMarked, dependencyToBeInstalled))
                {
                    // if dfs returns false then we have encountered a loop
                    return(false);
                }
                // otherwise visit the next dependency
            }

            // Add the package to the list so we can install later
            dependencyToBeInstalled.Add(packageItem);

            // Done with this node so mark it permanently
            permanentlyMarked.Add(packageItem);

            // Unmark it temporarily
            temporarilyMarked.Remove(packageItem);

            return(true);
        }
示例#31
0
        public void Links()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                var link = swid.AddLink(new Uri("http://foo.com"), "homepage");

                var link2 = swid.AddLink(new Uri("swid:/somepackage-v1.0"), "dependency");
                link2.Artifact  = "somepkg";
                link2.Media     = "Windows";
                link2.MediaType = "text/none";
                link2.Ownership = "abandon";
                link2.Use       = "required";

                var link3 = swid.AddLink(new Uri("http://foo.com/somepackage.msi"), "package");
                link3.Artifact  = "somepkg";
                link3.Media     = "Windows";
                link3.MediaType = "binary/package";
                link3.Use       = "required";

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
                Assert.Equal(3, swid.Links.Count());
                Assert.Equal("http://foo.com/", link.HRef.ToString());
                Assert.Equal("homepage", link.Relationship);
                Assert.Equal(2, link.Attributes.Count);

                Assert.Equal(link3.Artifact, link2.Artifact);

                // some xml-based assertions:
                Assert.Equal("http://foo.com/", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[1]//@href").Value);

                Assert.Equal("swid:/somepackage-v1.0", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@href").Value);
                Assert.Equal("somepkg", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@artifact").Value);
                Assert.Equal("Windows", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@media").Value);
                Assert.Equal("text/none", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@type").Value);
                Assert.Equal("abandon", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@ownership").Value);
                Assert.Equal("required", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@use").Value);
            }
        }
示例#32
0
        public void EmptyTag()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // validate that an empty tag isn't broken (although, aruguably not entirely valid)
                Assert.Null(swid.Name);
                Assert.Null(swid.IsCorpus);
                Assert.Null(swid.IsPatch);
                Assert.Null(swid.CanonicalId);

                Assert.Null(swid.IsSupplemental);
                Assert.Null(swid.PackageFilename);
                Assert.Null(swid.Provider);
                Assert.Null(swid.ProviderName);
                Assert.Null(swid.SearchKey);
                Assert.Null(swid.Source);
                Assert.Null(swid.Status);
                Assert.Null(swid.Summary);

                Assert.Null(swid.FullPath);
                Assert.Null(swid.TagId);
                Assert.Null(swid.TagVersion);
                Assert.Null(swid.Version);
                Assert.Null(swid.VersionScheme);

                Assert.False(swid.FromTrustedSource);

                Assert.Empty(swid.Meta);
                Assert.Empty(swid.Links);
                Assert.Empty(swid.Entities);
                Assert.Null(swid.Payload);
                Assert.Null(swid.Evidence);
            }
        }
示例#33
0
        public void WhatHappensWithDuplicateMetadata()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                var meta = swid.AddMetadataValue(swid.FastPackageReference, "sample", "value");
                Assert.NotNull(meta);

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
            }
        }
示例#34
0
        private bool InstallPackageReference(Package provider, string fastPath, BootstrapRequest request, SoftwareIdentity[] packages)
        {
            IHostApi installRequest = request;
            if (packages[0].Provider.Name.EqualsIgnoreCase("PSModule") && !request.ProviderServices.IsElevated) {
                // if we're not elevated, we want powershellget to install to the user scope

                installRequest = new object[] {
                    new {
                        GetOptionKeys = new Func<IEnumerable<string>>(() => request.OptionKeys.ConcatSingleItem("Scope")),
                        GetOptionValues = new Func<string, IEnumerable<string>>((key) => {
                            if (key != null && key.EqualsIgnoreCase("Scope")) {
                                return "CurrentUser".SingleItemAsEnumerable();
                            }
                            return request.GetOptionValues(key);
                        })
                    }
                    , installRequest
                }.As<IHostApi>();
            }

            var installing = packages[0].Provider.InstallPackage(packages[0], installRequest);

            SoftwareIdentity lastPackage = null;

            foreach (var i in installing) {
                lastPackage = i;
                // should we echo each package back as it comes back?
                request.YieldSoftwareIdentity(i.FastPackageReference, i.Name, i.Version, i.VersionScheme, i.Summary, i.Source, i.SearchKey, i.FullPath, i.PackageFilename);

                if (request.IsCanceled) {
                    installing.Cancel();
                }
            }

            if (!request.IsCanceled && lastPackage != null) {
                if (provider.Name.EqualsIgnoreCase("PSModule")) {
                    // special case. PSModules we can just ask the PowerShell provider to pick it up
                    // rather than try to scan for it.
                    PackageManagementService.TryLoadProviderViaMetaProvider("PowerShell", lastPackage.FullPath, request);
                    request.YieldFromSwidtag(provider, fastPath);
                    return true;
                }

                // looks like it installed ok.
                request.YieldFromSwidtag(provider, fastPath);

                // rescan providers
                PackageManagementService.LoadProviders(request.As<IRequest>());
                return true;
            }
            return false;
        }
 public PackageDetailsRequestObject(ProviderBase provider, IHostApi hostApi, SoftwareIdentity softwareIdentity, Action<RequestObject> action)
     : base(provider, hostApi, action) {
     _softwareIdentity = softwareIdentity;
     InvokeImpl();
 }
示例#36
0
        public void EntitiesTag()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity() {
                    Name = "SamplePackage",
                    FastPackageReference = "some-string",
                    Source = "test-source",
                    SearchKey = "search-key",
                    Status = "test-status",
                    TagId = "some-tag-id",
                    Version = "1.0",
                    VersionScheme = "multipart-numeric",
                    TagVersion = "1",
                };

                // add some data
                swid.AddEntity("garrett", "http://fearthecowboy.com/", "author");

                var entity = swid.AddEntity("bob", "http://bob.com/", "contributor");
                entity.AddRole("consultant");

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                Assert.Equal("garrett", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Entity[1]/@name").Value);
                Assert.Equal("http://fearthecowboy.com/", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Entity[1]/@regId").Value);
                Assert.Equal("author", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Entity[1]/@role").Value);

                Assert.Equal(2, entity.Roles.Count());
                Assert.Contains("contributor", entity.Roles);
                Assert.Contains("consultant", entity.Roles);

                Assert.Equal("contributor consultant", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Entity[2]/@role").Value);
            }
        }
示例#37
0
        public void Evidence()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                var evidence = swid.AddEvidence();

                var now = DateTime.Now;
                evidence.Date = now;

                evidence.DeviceId = "someid";

                var dir1 = evidence.AddDirectory("dir1");
                dir1.Location = "myapp";
                dir1.Root = "PROGRAMFILES";
                dir1.IsKey = false;

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions

                // verify only one element is actually created.
                Assert.Equal(evidence.ElementUniqueId, swid.AddEvidence().ElementUniqueId);

                // most is the same code as Payload...

                // check to make sure the object we got back is the same as we put in.
                dir1 = evidence.Directories.FirstOrDefault();
                Assert.Equal("dir1", dir1.Name);
                Assert.Equal("myapp", dir1.Location);
                Assert.Equal("PROGRAMFILES", dir1.Root);
                Assert.False(dir1.IsKey);

                Assert.Equal(now.ToUniversalTime(), ((DateTime)evidence.Date).ToUniversalTime());
                Assert.Equal("someid", evidence.DeviceId);

                // some xml validations:
                Assert.Equal("dir1", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Evidence/swid:Directory[1]/@name").Value);

                // check for the device id
                Assert.Equal("someid", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Evidence/@deviceId").Value);

                // validate the format of the date
                Assert.Equal(now.ToUniversalTime().ToString("o"), xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Evidence/@date").Value);
            }
        }
示例#38
0
        public void Links()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                var link = swid.AddLink(new Uri("http://foo.com"), "homepage");

                var link2 = swid.AddLink(new Uri("swid:/somepackage-v1.0"), "dependency");
                link2.Artifact = "somepkg";
                link2.Media = "Windows";
                link2.MediaType = "text/none";
                link2.Ownership = "abandon";
                link2.Use = "required";

                var link3 = swid.AddLink(new Uri("http://foo.com/somepackage.msi"), "package");
                link3.Artifact = "somepkg";
                link3.Media = "Windows";
                link3.MediaType = "binary/package";
                link3.Use = "required";

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
                Assert.Equal(3, swid.Links.Count());
                Assert.Equal("http://foo.com/", link.HRef.ToString());
                Assert.Equal("homepage", link.Relationship);
                Assert.Equal(2, link.Attributes.Count);

                Assert.Equal(link3.Artifact, link2.Artifact);

                // some xml-based assertions:
                Assert.Equal("http://foo.com/", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[1]//@href").Value);

                Assert.Equal("swid:/somepackage-v1.0", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@href").Value);
                Assert.Equal("somepkg", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@artifact").Value);
                Assert.Equal("Windows", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@media").Value);
                Assert.Equal("text/none", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@type").Value);
                Assert.Equal("abandon", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@ownership").Value);
                Assert.Equal("required", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Link[2]/@use").Value);
            }
        }
示例#39
0
        public void SimpleTag()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity() {
                    Name = "SamplePackage",
                    FullPath = "c:\\tmp\\path",
                    FastPackageReference = "some-string",
                    IsPatch = false,
                    Source = "test-source",
                    SearchKey = "search-key",
                    Status = "test-status",
                    TagId = "some-tag-id",
                    Version = "1.0",
                    VersionScheme = "multipart-numeric",
                    FromTrustedSource = true,
                    IsSupplemental = false,
                    IsCorpus = false,
                    Summary = "Summary Text",
                    AppliesToMedia = "Windows",
                    PackageFilename = "c:\\tmp\\path\\filename.txt",
                    TagVersion = "1",
                };

                // add some arbitrary metadata
                var meta = swid.AddMetadataValue(swid.FastPackageReference, "sample", "value");
                Assert.NotNull(meta);

                var xml = XDocument.Parse(swid.SwidTagText);

                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                Assert.Equal("SamplePackage", xml.XPathToAttribute("/swid:SoftwareIdentity/@name").Value);

                var v = xml.XPathToAttribute("/swid:SoftwareIdentity/@tagId").Value;

                Assert.Equal("some-tag-id", xml.XPathToAttribute("/swid:SoftwareIdentity/@tagId").Value);
                Assert.Equal("1.0", xml.XPathToAttribute("/swid:SoftwareIdentity/@version").Value);
                Assert.Equal("multipart-numeric", xml.XPathToAttribute("/swid:SoftwareIdentity/@versionScheme").Value);
                Assert.Equal("1", xml.XPathToAttribute("/swid:SoftwareIdentity/@tagVersion").Value);
                Assert.Equal("Windows", xml.XPathToAttribute("/swid:SoftwareIdentity/@media").Value);

                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@patch").Value.IsFalse());
                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@supplemental").Value.IsFalse());
                Assert.True(xml.XPathToAttribute("/swid:SoftwareIdentity/@corpus").Value.IsFalse());

                Assert.Equal("Summary Text", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta/@summary").Value);

                Assert.Equal("value", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta/@sample").Value);
            }
        }
示例#40
0
        public void Metadata()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                swid.AddAttribute(XNamespace.Get("http://oneget.org/swidtag") + "test", "value");

                // add some data
                var meta1 = swid.AddMeta();
                meta1.AddAttribute("Key", "Value");
                meta1.AddAttribute("Key2", "Value");
                meta1.AddAttribute(XNamespace.Get("http://oneget.org/swidtag") + "other", "somevalue");

                var meta2 = swid.AddMeta();
                meta2.AddAttribute(XNamespace.Get("http://oneget.org/swidtag") + "other2", "somevalue2");

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
                Assert.Equal(3, meta1.Attributes.Keys.Count());
                Assert.Equal(1, meta2.Attributes.Keys.Count());

                Assert.Equal("Value", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta[1]/@Key").Value);
                Assert.Equal("Value", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta[1]/@Key2").Value);
                Assert.Equal("somevalue", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Meta[1]/@oneget:other").Value);
            }
        }
示例#41
0
        public void Payload()
        {
            using (CaptureConsole) {
                var swid = new SoftwareIdentity();

                // add some data
                var payload = swid.AddPayload();

                var dir1 = payload.AddDirectory("dir1");
                dir1.Location = "myapp";
                dir1.Root = "PROGRAMFILES";
                dir1.IsKey = false;

                var dir2 = payload.AddDirectory("dir2");
                var nested1 = dir2.AddDirectory("nested1");
                var file1 = nested1.AddFile("file1");
                file1.Size = 12345;
                file1.Version = "1.0";
                file1.IsKey = true;

                var file2 = payload.AddFile("file2");

                var file3 = payload.AddFile("file3");
                file3.Location = "dir1";
                file3.Root = "SYSTEMDRIVE";

                var process = swid.Payload.AddProcess("foo.exe");
                process.AddAttribute("commandline", "--daemon");

                var regkey = swid.Payload.AddResource("regkey");
                regkey.AddAttribute("key", "hklm/foo/bar/bin/baz");
                regkey.AddAttribute("value", "chocolate");

                var payload2 = swid.AddPayload();

                // to xml
                var xml = XDocument.Parse(swid.SwidTagText);
                Console.WriteLine("SWID: {0} ", swid.SwidTagText);

                // assertions
                // verify only one element is actually created.
                Assert.Equal(payload.ElementUniqueId, payload2.ElementUniqueId);

                Assert.Equal("dir1", dir1.Name);
                Assert.Equal("myapp", dir1.Location);
                Assert.Equal("PROGRAMFILES", dir1.Root);
                Assert.False(dir1.IsKey);

                Assert.Empty(dir1.Files);
                Assert.Empty(dir1.Directories);

                Assert.Equal(1, dir2.Directories.Count());
                Assert.Empty(dir2.Files);
                Assert.Equal(1, dir2.Directories.FirstOrDefault().Files.Count());
                Assert.Equal("file1", dir2.Directories.FirstOrDefault().Files.FirstOrDefault().Name);
                Assert.Equal(12345, dir2.Directories.FirstOrDefault().Files.FirstOrDefault().Size);

                Assert.Equal("1.0", dir2.Directories.FirstOrDefault().Files.FirstOrDefault().Version);
                Assert.True(dir2.Directories.FirstOrDefault().Files.FirstOrDefault().IsKey);

                Assert.Equal(2, swid.Payload.Files.Count());
                Assert.Equal(1, swid.Payload.Processes.Count());
                Assert.Equal(1, swid.Payload.Resources.Count());

                Assert.Equal("foo.exe", swid.Payload.Processes.FirstOrDefault().Name);
                Assert.Equal("--daemon", swid.Payload.Processes.FirstOrDefault().GetAttribute("commandline"));

                Assert.Null(swid.Payload.Processes.FirstOrDefault().GetAttribute("notpresent"));

                Assert.Equal("regkey", swid.Payload.Resources.FirstOrDefault().Type);
                Assert.Equal("hklm/foo/bar/bin/baz", swid.Payload.Resources.FirstOrDefault().GetAttribute("key"));
                Assert.Equal("chocolate", swid.Payload.Resources.FirstOrDefault().GetAttribute("value"));

                // try via indexing accessor
                Assert.Equal("chocolate", swid.Payload.Resources.FirstOrDefault().Attributes["value"]);

                //
                Assert.Equal(3, swid.Payload.Resources.FirstOrDefault().Attributes.Count);
                Assert.Contains("type", swid.Payload.Resources.FirstOrDefault().Attributes.Keys);
                Assert.Contains("key", swid.Payload.Resources.FirstOrDefault().Attributes.Keys);
                Assert.Contains("value", swid.Payload.Resources.FirstOrDefault().Attributes.Keys);

                Assert.DoesNotContain("not-present", swid.Payload.Resources.FirstOrDefault().Attributes.Keys);

                // some xml-based assertions:
                Assert.Equal("dir1", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Payload/swid:Directory[1]/@name").Value);
                Assert.Equal("dir2", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Payload/swid:Directory[2]/@name").Value);
                Assert.Equal("nested1", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Payload/swid:Directory[2]/swid:Directory[1]/@name").Value);

                Assert.Equal("file1", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Payload/swid:Directory[2]/swid:Directory[1]/swid:File[1]/@name").Value);
                Assert.Equal("12345", xml.XPathToAttribute("/swid:SoftwareIdentity/swid:Payload/swid:Directory[2]/swid:Directory[1]/swid:File[1]/@size").Value);

                Assert.Equal(1, xml.XPathToElements("/swid:SoftwareIdentity/swid:Payload").Count());
                Assert.Equal(1, xml.XPathToElements("//swid:Payload").Count());

                Assert.Equal(3, xml.XPathToElements("//swid:File").Count());
                Assert.Equal(1, xml.XPathToElements("//swid:Process").Count());
                Assert.Equal(1, xml.XPathToElements("//swid:Resource").Count());
                Assert.Equal(3, xml.XPathToElements("//swid:Directory").Count());
            }
        }