Ejemplo n.º 1
0
        public static async Task <IEnumerable <ArtifactPackage> > FindArtifact(
            string target, Action <ArtifactFilter> filterConfiguration)
        {
            // TODO: validate filterConfiguraion
            await Task.Delay(0);

            var filter = new ArtifactFilter(target);

            filterConfiguration?.Invoke(filter);

            using var http = new HttpClient()
                  {
                      BaseAddress = BaseAddress,
                      Timeout     = TimeSpan.FromMilliseconds(3000)
                  };

            var packages = new List <ArtifactPackage>();

            var Version = Environment.GetEnvironmentVariable("LSBEAT_VERSION");

            packages.Add(new ArtifactPackage {
                TargetName = "lsbeat",
                Url        = $"https://github.com/seungyongshim/lsbeat/releases/download/{Version}/lsbeat.exe",
                FileName   = "lsbeat",
            });

            return(packages);
        }
Ejemplo n.º 2
0
        public static async Task <IEnumerable <ArtifactPackage> > FindArtifact(
            string target, Action <ArtifactFilter> filterConfiguration)
        {
            // TODO: validate filterConfiguraion

            var filter = new ArtifactFilter(target);

            filterConfiguration?.Invoke(filter);

            using var http = new HttpClient()
                  {
                      BaseAddress = BaseAddress,
                      Timeout     = TimeSpan.FromMilliseconds(3000)
                  };

            var query = $"search/{filter.ContainerId}/{target}{filter.QueryString}";

            using var stm = await http.GetStreamAsync(query);

            using var sr  = new StreamReader(stm);
            using var jtr = new JsonTextReader(sr);

            var js   = new JsonSerializer();
            var data = js.Deserialize <JToken>(jtr);

            var packages = new List <ArtifactPackage>();

            foreach (JProperty itm in data["packages"] ?? new JArray())
            {
                if (filter.Bitness == eBitness.x64 &&
                    (string)itm.Value[MagicStrings.ArtifactsApi.Architecture] != MagicStrings.Arch.x86_64)
                {
                    continue;
                }

                var packageUrl = (string)itm.Value[MagicStrings.ArtifactsApi.Url];
                if (packageUrl.IsEmpty())
                {
                    continue;
                }

                if (!ArtifactPackage.FromUrl(packageUrl, out var package))
                {
                    continue;
                }

                packages.Add(package);
            }

            return(packages);
        }