Giter Site home page Giter Site logo

코멘트 요청 about tumblbug_clone_be HOT 4 OPEN

DreamherB avatar DreamherB commented on September 10, 2024
코멘트 요청

from tumblbug_clone_be.

Comments (4)

Gitakkkk avatar Gitakkkk commented on September 10, 2024
  1. routes - article.js 내에 있는 코드 중 ' 랜덤 게시글 8개 발송 ' 이라고 주석 달린 코드가 있는데
    이미 aggregate를 사용한 결과물인 posting에 대해서 contents 항목을 false로 해서 보내고 싶은데 그게 안됩니다
    일단은 전부 보내고 프론트에서 필요한 내용만 쓰는 걸로 기능을 구현했는데 어떻게 하면 contensts 항목만 false로 보낼 수 있을까요?

비교 코드도 함께 올리겠습니다.

// 랜덤 게시글 8개 발송
router.get("/articles/mainProjects", async (req, res) => {
const postings = await articles.aggregate([{ $sample: { size: 8 } }]);
res.json({ result: true, mainProjects: postings });
});

// 인기 프로젝트 조회
router.get("/articles/popularProjects", async (req, res) => {
const postings = await articles
.find(
{},
{
contents: 0,
}
)
.sort({ totalAmount: -1 });
res.json({ result: true, popularProjects: postings });
});

  1. 보안적으로는 cors나 비밀번호 저장 시 bcrypt만 사용되었습니다.
    혹시 이런 사이트에서 보안적으로는 어떤 부분을 더 신경쓰면 좋을까요?

from tumblbug_clone_be.

golddong98 avatar golddong98 commented on September 10, 2024

(1)
https://stackoverflow.com/questions/14559200/how-to-exclude-one-particular-field-from-a-collection-in-mongoose
여기에 나온 방법 중 하나인데
const products = await Product.find().select(['-image'])
select 문으로 필드를 제외해보세요
(2)
서버에 있는 mongodb의 버전이 낮아서 생기는 문제일 수도 있습니다.
개인적으로 이런 비슷한 문제를 겪은 적이 있어서 그 때 저는 버전을 높여서 해결했습니다.

(1)요청에 rate-limit을 걸어 white list에 등록된 사이트에서의 무한 요청막기

http://tumblbugclone.s3-website.ap-northeast-2.amazonaws.com
위 사이트에서 콘솔창에 이 코드를 쳐보세요ㅎㅎ
let point = 0; while (point<1000){ const response = await fetch('http://3.35.176.155:8080/api/articles/mainProjects'); const result = await response.json(); console.log(result); point+=1; }

(2) 포트포워딩하기
현재 사이트에서 서버에 요청하는 네트워크를 보시면 포트가 그대로 나와있는데 이것 또한 해킹의 위험성을 높여줍니다.

(3) express 도큐멘터리에서 권장하는 보안
https://expressjs.com/ko/advanced/best-practice-security.html
express에서 권장하는 보안우수사례이므로 읽어보시면 좋을 것 같습니다ㅎㅎ

(4) 등등

일단 보안적으로 한 눈에 보이는 부분은 이정도네요
저도 사실 보안적으로는 많이 공부하질 않아서 하나씩 하나씩 알아가는 중 입니다.
보안을 신경쓰다보면 파면 팔수록 알면 알수록 깊고 방대하기 때문에 꾸준히 알아가는게 좋은 것 같습니다ㅎㅎ

프로젝트 잘 만들으셨네요 영혼을 갈으신게 느껴집니다 프로젝트 수고하셨습니다ㅎㅎ

from tumblbug_clone_be.

DreamherB avatar DreamherB commented on September 10, 2024

아아 네넵! 감사합니다 ㅎㅎㅎㅎ 열공해볼게요!

from tumblbug_clone_be.

Lee-ChongMyeong avatar Lee-ChongMyeong commented on September 10, 2024

1번

  1. mongoose 에서 제공하는 virtual 값을 사용해서, 원하는 key, value 값을 reponse로 내려줄 수 있습니다.
  2. res.json 으로 aggregate 한 데이터들을 통째로 받아서 내보내주는데, 이때 DB 설계에 대한 부분이 노출될수 있습니다. 그래서 보통은 res.json 으로 통째로 내려주기보다는 DB 의 컬럼과 response 해주는 key 값을 다르게 해서 내려주는게 보안적으로 안전하며, 이런것을 매핑해준다고 합니다. 매핑할때 contents 항목에 대한 key값을 만들어주고 value 로 false 내려주면 해결되는 문제입니다.

2번. bcrypt 로 충분히 보안적으로 사용 가능하지만, 다른 암호화 방법에 대해서 비교해보시고 왜 사용하는지에 대한 이유를 알면 더 도움이 될것 같습니다.

프로젝트 하시느라 수고 많으셨습니다~

from tumblbug_clone_be.

Related Issues (1)

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.