github.com/google/osv-scalibr@v0.4.1/detector/endoflife/linuxdistro/fedora.go (about)

     1  // Copyright 2025 Google LLC
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package linuxdistro
    16  
    17  import (
    18  	"strconv"
    19  	"time"
    20  
    21  	scalibrfs "github.com/google/osv-scalibr/fs"
    22  )
    23  
    24  func checkSupportEnd(eos string) bool {
    25  	date, err := time.Parse("2006-01-02", eos)
    26  	if err != nil {
    27  		return false
    28  	}
    29  	return date.Before(now())
    30  }
    31  
    32  func fedoraEOL(osRelease map[string]string, _ scalibrfs.FS) bool {
    33  	if eos, ok := osRelease["SUPPORT_END"]; ok && checkSupportEnd(eos) {
    34  		return true
    35  	}
    36  	if id, ok := osRelease["VERSION_ID"]; ok {
    37  		i, err := strconv.Atoi(id)
    38  		if err != nil {
    39  			return false
    40  		}
    41  		// See: https://docs.fedoraproject.org/en-US/releases/eol/
    42  		// Fedora 40 is currently the latest EoL release
    43  		return i <= 40
    44  	}
    45  	return false
    46  }