Skip to content

Revert "Partial CVE automation" #921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions scripts/check_for_new_al_version.sh

This file was deleted.

168 changes: 37 additions & 131 deletions scripts/generate_changelog.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
#!/bin/bash
set -xeuo pipefail

# Initialize variables
next_token=""
all_tags=()

# Get all amazonlinux container image tags
while true; do
if [ -z "$next_token" ]; then
response=$(curl -sSL \
--header "Content-Type: application/json" \
--request POST \
--data '{"registryAliasName":"amazonlinux","repositoryName":"amazonlinux","maxResults":250}' \
https://api.us-east-1.gallery.ecr.aws/describeImageTags)
else
response=$(curl -sSL \
--header "Content-Type: application/json" \
--request POST \
--data "{\"registryAliasName\":\"amazonlinux\",\"repositoryName\":\"amazonlinux\",\"nextToken\":\"$next_token\",\"maxResults\":250}" \
https://api.us-east-1.gallery.ecr.aws/describeImageTags)
fi

# Extract tags and add them to the array
tags=$(echo "$response" | jq -r '.imageTagDetails[].imageTag')
all_tags+=($tags)

# Check if there's a next token
next_token=$(echo "$response" | jq -r '.nextToken')
if [[ "$next_token" == "null" ]]; then
break
fi
done

# Find the most recent AL2 tag
most_recent_al2=$(./scripts/most_recent_al2.sh)
most_recent_al2=$(printf '%s\n' "${all_tags[@]}" | grep '^2\.' | grep -v minimal | grep -v arm | grep -v amd | sort -V | tail -n 1)

# Read the JSON file
json_file="linux.version"
Expand All @@ -15,142 +46,17 @@ cloudwatch_plugin_version=$(echo "$json_content" | jq -r '.linux."cloudwatch-plu
kinesis_plugin_version=$(echo "$json_content" | jq -r '.linux."kinesis-plugin"')
firehose_plugin_version=$(echo "$json_content" | jq -r '.linux."firehose-plugin"')

changelog_commit=$(git log -n1 --pretty=format:%h CHANGELOG.md)
changelog_commit_date="$(git show --no-patch --format=%ci $changelog_commit)"
current_commit=$(git log -n1 --pretty=format:%h)

# Test Overrides


upstream_changes=false
newer_upstream_changes=""
if [ "${#FLUENT_BIT_DIRECTORY}" -ge 1 ]; then
newer_upstream_changes=$(cd $FLUENT_BIT_DIRECTORY; git log --pretty=format:%s --after "$changelog_commit_date")
# If there are NOT newer changes
if [ ${#newer_upstream_changes} -le 1 ]; then
FLUENT_BIT_DIRECTORY=""
fi
fi

compared_string=""

add_changelog_changes=false
flb_has_changes=false
we_have_changes=false
if [ "${#FLUENT_BIT_DIRECTORY}" -ge 1 ]; then
flb_has_changes=true
fi
if [ "$changelog_commit" != "$current_commit" ]; then
we_have_changes=true
fi

if [ "$we_have_changes" = true ] || [ "$flb_has_changes" = true ]; then
compared_string="
Compared to the previous release, this release adds:"
commit_names=$(git log --pretty=format:%s "$changelog_commit".."$current_commit")
if [ "$flb_has_changes" = true ]; then
# Get commits from the upstream as well
# Add newline to separate from existing commits
commit_names+="
"
# Add FLB commit names to the list considered for changelog updates
commit_names+="$newer_upstream_changes"
fi
original_ifs=$IFS
IFS="
"
for line in $commit_names
do
IFS=" "
found_label=false
for word in $line
do
# Look for an indication of what this commit is about
# unless we already are at the stage of collecting
# the name
if [ "$found_label" = false ]; then
# Factor out setting this to true if a
# label is found, reducing boilerplate
found_label=true
if [ "$word" = "feature:" ]; then
compared_string+="
* Feature - "
continue
elif [ "$word" = "enhancement:" ]; then
compared_string+="
* Enhancement - "
continue
elif [ "$word" = "fix:" ] || [ "$word" = "bugfix:" ]; then
compared_string+="
* Fix - "
continue
elif [ "$word" = "Fix" ]; then
compared_string+="
* Fix - "
# We don't continue for the enclosing elif,
# i.e. we add "Fix" as the first word
elif [ $(echo "$word" | grep "\(aws:\|out_cloudwatch_logs:\|out_s3:\|out_kinesis:\|filter_ecs:\|filter_kubernetes:\)") ]; then
change_type="Enhancement"
for inner_word in $line
do
if [ $(echo "$inner_word" | grep '\(fix\|Fix\|bugfix\)') ]; then
change_type="Fix"
break
elif [ $(echo "$inner_word" | grep '\(add\|Add\)') ]; then
change_type="Feature"
break
elif [ $(echo "$inner_word" | grep '\(allow\|support\)') ]; then
# Enhancement is the default
break
fi
done

compared_string+="
* $change_type - "
continue
else
# No label was found
found_label=false
fi
fi
if [ "$found_label" = false ]; then
# If no label, skip this commit
break 1
else
# Add each word aside from the prefix to the commit changelog description
compared_string+=$word
compared_string+=" "
fi
done
IFS="
"
done
# Append newline to separate from the next changelog entry
compared_string+="
"
IFS=$original_ifs
fi

# Generate the changelog entry

new_changelog="
cat << EOF
### $version
This release includes:
* Fluent Bit [$fluent_bit_version](https://github.com/fluent/fluent-bit/tree/v$fluent_bit_version)
* Amazon CloudWatch Logs for Fluent Bit ${cloudwatch_plugin_version#v}
* Amazon Kinesis Streams for Fluent Bit ${kinesis_plugin_version#v}
* Amazon Kinesis Firehose for Fluent Bit ${firehose_plugin_version#v}
* Amazon Linux base container image version: $most_recent_al2
$compared_string"

heads=$(head -n 1 CHANGELOG.md)
tails=$(tail -n +3 CHANGELOG.md)

rm -f temp_changelog.txt
echo "$heads" >> temp_changelog.txt
echo "$new_changelog" >> temp_changelog.txt
echo "$tails" >> temp_changelog.txt

mv -f temp_changelog.txt CHANGELOG.md
rm -f temp_changelog.txt

Compared to the previous release, this release adds:
* Fix - TODO blah blah [#TODO](https://github.com/amazon-contributing/upstream-to-fluent-bit/pull/TODO)
* Enhancement - TODO blah blah [#TODO](https://github.com/aws/aws-for-fluent-bit/pull/TODO)
EOF
37 changes: 0 additions & 37 deletions scripts/most_recent_al2.sh

This file was deleted.

150 changes: 0 additions & 150 deletions scripts/publish_cve_update.py

This file was deleted.