From nobody Sun Feb 8 06:05:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557748359; cv=none; d=zoho.com; s=zohoarc; b=X88PLXWNvxmQ5I0JGfs+xYp6JE/hQgretRcYGDoztoXZqq2fneiFsnb2ithqm/RW1kc2pxn9CCiQ/hx3uThwikm5x2Ti8NIEuBIPg+d2BVZcLEJUBQXM3Le+XALTpRTF1sNwrktmNMaibmUjXDIiEmgEb67zc4ymwPddDLS/N/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557748359; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=r+0NmqKC8Rm0USRHDYkNgtT7LRKvq34bFauGf2qgbX8=; b=VS12VeLCna980eYRMkd69K6HiiX1B/4oi+d3b9V5brn23rYv5GiEki8jyXEQv7brXl46WKsOwU0agrth3WAEn0Pk4Ky+aGjf9BxPBf2dc6hohsPhUP0dwbQ01WpLOY2eIUo3upWT7mjPIKTrvIfU5xe7O+EGfVQOGsWqZtTmRHA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1557748359658561.1002953556344; Mon, 13 May 2019 04:52:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 272755946B; Mon, 13 May 2019 11:52:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F218018A71; Mon, 13 May 2019 11:52:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AFE3D18052E3; Mon, 13 May 2019 11:52:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4DBqNgU031046 for ; Mon, 13 May 2019 07:52:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 00EDA196A8; Mon, 13 May 2019 11:52:23 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C8C36A482; Mon, 13 May 2019 11:52:22 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 13 May 2019 12:52:04 +0100 Message-Id: <20190513115206.1088-8-berrange@redhat.com> In-Reply-To: <20190513115206.1088-1-berrange@redhat.com> References: <20190513115206.1088-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [security-notice PATCH 7/9] scripts: add detection of cherry-picks in branches X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 13 May 2019 11:52:38 +0000 (UTC) Look at each fix on the branch to identify if it is a recorded cherry-pick from the fixes known for the master branch If all fixes from master are cherry-picked to the branch, then look at tags on the branch to identify if a bug fix release has been made containing all the fixes. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- scripts/report-vulnerable-tags.pl | 69 +++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/scripts/report-vulnerable-tags.pl b/scripts/report-vulnerable-= tags.pl index 43f344a..6a0f7dc 100644 --- a/scripts/report-vulnerable-tags.pl +++ b/scripts/report-vulnerable-tags.pl @@ -99,6 +99,28 @@ sub get_branches { return @branches; } =20 +sub get_cherry_picks { + my $branch =3D shift @_; + my $tag =3D shift @_; + + open GIT, "-|", "git", "log", "$tag..origin/$branch" or + die "cannot query 'git log $tag..origin/$branch': $!\n"; + + my $commit; + my %cherrypicks; + while () { + chomp; + + if (/^commit ([a-zA-Z0-9]+)/) { + $commit =3D $1; + } elsif (/cherry picked from commit ([a-zA-Z0-9]+)/) { + $cherrypicks{$1} =3D $commit; + } + } + + return %cherrypicks; +} + sub add_branch { my $name =3D shift @_; =20 @@ -177,7 +199,54 @@ if (defined $broken) { for my $branch (get_branches($broken)) { add_branch($branch); } +} + +if (defined $fixed) { + # Try to match up fixed commit with cherry-picks + for my $branch (sort versioncmp keys %branches) { + next if $branch eq "master"; + + my $basetag =3D $branch; + $basetag =3D~ s/-maint//; + my @bits =3D split /\./, $basetag; + + if (int(@bits) =3D=3D 2) { + $basetag =3D $basetag . ".0"; + } + + my %cherrypicks =3D get_cherry_picks($branch, $basetag); + + my @missing; + for my $commit (@fixed) { + if (exists $cherrypicks{$commit}) { + my $cherry =3D $cherrypicks{$commit}; + add_fixed_commit($branch, $cherry); + } else { + push @missing, $commit; + } + } + + # If all fixes on master exist on branch, then + # identify any tags holding the last cherry-pick + # so the branch gets marked as non-vulnerable. + if (int(@missing) =3D=3D 0) { + my $bfixed =3D $branches{$branch}->{fixedchanges}->[$#{$branches{$bra= nch}->{fixedchanges}}]; + # Mark any tags containing the fix as known so they + # get excluded when later finding vulnerable tags + for my $tag (get_tags("--contains", $bfixed)) { + $tags{$tag} =3D 0; + } + + # Record the first tag in master which has the fix, if any + my @fixedtags =3D sort versioncmp get_tags("--contains", $bfixed, "--= merged", $branch); + if (int(@fixedtags)) { + add_fixed_tag($branch, $fixedtags[0]); + } + } + } +} =20 +if (defined $broken) { # Now we need slower work to find branches for # few remaining tags for my $tag (get_tags("--contains", $broken)) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list